aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaúl Benencia <id@rbenencia.name>2024-10-16 08:38:21 -0700
committerRaúl Benencia <id@rbenencia.name>2024-10-16 08:38:21 -0700
commit8f3245c4e32dde8d6b39977badad427f5ae20b50 (patch)
tree4a7e9a86828d68766b9bd9f93bbd7ac8df196e25
parentec1f59939498ef7ac94fd58ebac535cfe5a6af65 (diff)
gnome: move windows programatically
-rwxr-xr-xbin/gnome-move-windows24
-rwxr-xr-xbin/gnome-set-config6
2 files changed, 29 insertions, 1 deletions
diff --git a/bin/gnome-move-windows b/bin/gnome-move-windows
new file mode 100755
index 0000000..2eb9462
--- /dev/null
+++ b/bin/gnome-move-windows
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Move windows according to my workflow. Check bin/gnome-set-config to
+# see its key-binding. Needs wmctrl.
+
+emacs_main="$(wmctrl -l | awk '/ main$/ {print $1}')"
+emacs_communications="$(wmctrl -l | awk '/ communications$/ {print $1}')"
+emacs_terminals="$(wmctrl -l | awk '/ terminals$/ {print $1}')"
+browsers="$(wmctrl -l | grep -i -e firefox -e chrom | awk '{print $1}' | tr '\n' ' ')"
+
+if [ -n "$emacs_main" ]; then
+ wmctrl -i -r $emacs_main -t 0
+fi
+
+if [ -n "$emacs_communications" ]; then
+ wmctrl -i -r $emacs_communications -t 2
+fi
+
+if [ -n "$emacs_terminals" ]; then
+ wmctrl -i -r $emacs_terminals -t 3
+fi
+
+for browser in $browsers; do
+ wmctrl -i -r $browser -t 1
+done
diff --git a/bin/gnome-set-config b/bin/gnome-set-config
index 1ac9fc0..983bdee 100755
--- a/bin/gnome-set-config
+++ b/bin/gnome-set-config
@@ -15,7 +15,7 @@ for i in $(seq 1 $NUM_WORKSPACES); do
done
# This configuration is not present in gsettings; we need to fall back to dconf
-bindings="emacs org-mode"
+bindings="emacs org-mode move-windows"
keybindings_key="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings"
keybindings=$(echo $bindings | awk -v key="$keybindings_key" '{for(i=1;i<=NF;i++) printf("'\''" key "/" $i "/'\''%s", (i==NF ? "" : ","))}')
keybindings="[$keybindings]"
@@ -29,3 +29,7 @@ dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/ema
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/org-mode/binding "'<Shift><Super>o'"
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/org-mode/command "'emacsclient -e \"(prot-window-popup-org-capture)\"'"
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/org-mode/name "'org-capture'"
+
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/move-windows/binding "'<Shift><Super>m'"
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/move-windows/command "'/home/rul/bin/gnome-move-windows'"
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/move-windows/name "'move-windows'"
nihil fit ex nihilo