aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gnome-move-windows46
-rwxr-xr-xbin/gnome-set-config87
-rwxr-xr-xbin/rofi30
-rwxr-xr-xbin/setup-install-fonts26
4 files changed, 189 insertions, 0 deletions
diff --git a/bin/gnome-move-windows b/bin/gnome-move-windows
new file mode 100755
index 0000000..f3a5e34
--- /dev/null
+++ b/bin/gnome-move-windows
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Move windows according to my workflow. Check bin/gnome-set-config to
+# see its key-binding. Needs wmctrl.
+
+# Move all windows to the primary display. If they're on the secondary
+# display, and we try to move them to a workspace, it won't work.
+for window_id in $(wmctrl -l | awk '{print $1}'); do
+ wmctrl -i -r $window_id -e 0,0,0,-1,-1
+done
+
+# Assign windows to predetermined workplaces
+misc=$(wmctrl -l | awk '/isco|eepa/ {print $1}')
+main="$(wmctrl -xl | awk '/ emacs/ {print $1}')"
+communications="$(wmctrl -xl | awk 'tolower($0) ~ /(ebex|lack|communications|notmuch|outlook|elfeed|thunderbird)/ {print $1}')"
+media="$(wmctrl -l | awk '/YouTube|Spotify/ {print $1}')"
+terminals="$(wmctrl -l | awk '/Alacritty|kitty|terminal/ {print $1}')"
+teleport="$(wmctrl -xl | awk 'tolower($0) ~ /teleport/ {print $1}')"
+browsers="$(wmctrl -xl | awk '/irefox|hrom/ {print $1}')"
+
+for window_id in $misc; do
+ wmctrl -i -r $window_id -t 4
+done
+
+for window_id in $main; do
+ wmctrl -i -r $window_id -t 0
+done
+
+for window_id in $browsers; do
+ wmctrl -i -r $window_id -t 1
+done
+
+for window_id in $communications; do
+ wmctrl -i -r $window_id -t 2
+done
+
+for window_id in $terminals; do
+ wmctrl -i -r $window_id -t 3
+done
+
+for window_id in $teleport; do
+ wmctrl -i -r $window_id -t 5
+done
+
+for window_id in $media; do
+ wmctrl -i -r $window_id -t 8
+done
diff --git a/bin/gnome-set-config b/bin/gnome-set-config
index 5bfb476..509d542 100755
--- a/bin/gnome-set-config
+++ b/bin/gnome-set-config
@@ -1,12 +1,99 @@
#!/bin/sh
+# Sets my preferred Gnome config.
+# Find existing bindings with:
+# for e in $(gsettings list-schemas | grep bind); do gsettings list-recursively $e; done
NUM_WORKSPACES=9
+WORKSPACE_ROUTER_UUID=workspace-router@rbenencia.name
+ORG_AGENDA_INDICATOR_UUID=org-agenda-indicator@rbenencia.name
+
+ensure_extension_enabled() {
+ uuid="$1"
+ extension_dir=""
+
+ for candidate in \
+ "$HOME/.local/share/gnome-shell/extensions/$uuid" \
+ "$HOME/.local/gnome-shell/extensions/$uuid"; do
+ if [ -d "$candidate" ]; then
+ extension_dir="$candidate"
+ break
+ fi
+ done
+
+ if [ -z "$extension_dir" ]; then
+ return 0
+ fi
+
+ if [ -d "$extension_dir/schemas" ] && command -v glib-compile-schemas >/dev/null 2>&1; then
+ glib-compile-schemas "$extension_dir/schemas" >/dev/null 2>&1 || true
+ fi
+
+ enabled_extensions=$(
+ python3 - "$uuid" "$(gsettings get org.gnome.shell enabled-extensions)" <<'PY'
+import ast
+import sys
+
+uuid = sys.argv[1]
+enabled_extensions = ast.literal_eval(sys.argv[2])
+
+if uuid not in enabled_extensions:
+ enabled_extensions.append(uuid)
+
+print(enabled_extensions)
+PY
+ )
+ gsettings set org.gnome.shell enabled-extensions "$enabled_extensions"
+
+ if command -v gnome-extensions >/dev/null 2>&1; then
+ gnome-extensions enable "$uuid" >/dev/null 2>&1 || true
+ fi
+}
gsettings set org.gnome.mutter dynamic-workspaces false
gsettings set org.gnome.desktop.wm.preferences num-workspaces $NUM_WORKSPACES
+ensure_extension_enabled "$WORKSPACE_ROUTER_UUID"
+ensure_extension_enabled "$ORG_AGENDA_INDICATOR_UUID"
+
+ROFI_CMD="$HOME/bin/rofi"
+
+# Disable the default <Super>p. I don't use it, and it's disruptive when I accidentally trigger it.
+gsettings set org.gnome.mutter.keybindings switch-monitor '[]'
+
for i in $(seq 1 $NUM_WORKSPACES); do
gsettings set org.gnome.shell.keybindings switch-to-application-$i '[]'
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-$i "['<Super>$i']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-$i "['<Shift><Super>$i']"
done
+
+# This configuration is not present in gsettings; we need to fall back to dconf
+bindings="emacs org-mode move-windows rofi rofi-run"
+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]"
+
+dconf write "$keybindings_key" "$keybindings"
+
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/emacs/binding "'<Shift><Super>e'"
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/emacs/command "'emacsclient -c'"
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/emacs/name "'Emacs'"
+
+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 "'gnome-move-windows'"
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/move-windows/name "'move-windows'"
+
+# Disable default for <Super>space.
+gsettings set org.gnome.desktop.wm.keybindings switch-input-source "[]"
+gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward '[]'
+
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/rofi/binding "'<Super>space'"
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/rofi/command "'$ROFI_CMD -show window'"
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/rofi/name "'rofi'"
+
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/rofi-run/binding "'<Super>f2'"
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/rofi-run/command "'$ROFI_CMD -show run'"
+dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/rofi-run/name "'rofi-run'"
diff --git a/bin/rofi b/bin/rofi
new file mode 100755
index 0000000..cfa5a8f
--- /dev/null
+++ b/bin/rofi
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# GNOME on Wayland does not support the layer-shell protocol that rofi's
+# native Wayland backend requires, so fall back to Xwayland there.
+
+self_path=$(readlink -f "$0" 2>/dev/null || printf '%s\n' "$0")
+rofi_bin=""
+
+for candidate in /usr/bin/rofi /bin/rofi; do
+ candidate_path=$(readlink -f "$candidate" 2>/dev/null || printf '%s\n' "$candidate")
+ if [ -x "$candidate" ] && [ "$candidate_path" != "$self_path" ]; then
+ rofi_bin="$candidate"
+ break
+ fi
+done
+
+if [ -z "$rofi_bin" ]; then
+ printf '%s\n' "rofi: unable to find the system rofi binary" >&2
+ exit 127
+fi
+
+if [ "${XDG_SESSION_TYPE:-}" = "wayland" ] && [ -n "${WAYLAND_DISPLAY:-}" ]; then
+ case "${XDG_CURRENT_DESKTOP:-}:${DESKTOP_SESSION:-}" in
+ *GNOME*:*|*:gnome|GNOME:*|gnome:*)
+ set -- -x11 "$@"
+ ;;
+ esac
+fi
+
+exec "$rofi_bin" "$@"
diff --git a/bin/setup-install-fonts b/bin/setup-install-fonts
new file mode 100755
index 0000000..ea96873
--- /dev/null
+++ b/bin/setup-install-fonts
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+set -e
+
+FONT_DIR="$HOME/.local/share/fonts"
+TEMP_DIR=$(mktemp -d)
+
+mkdir -p "$FONT_DIR"
+
+pushd $TEMP_DIR
+curl -s 'https://api.github.com/repos/be5invis/Iosevka/releases/latest' | \
+ jq -r ".assets[] | .browser_download_url" | \
+ grep PkgTTC-Iosevka | \
+ xargs -n 1 curl -L -O --fail --silent --show-error
+
+for f in *.zip; do
+ unzip "$f"
+done
+
+mv *.ttc "$FONT_DIR/"
+fc-cache -f -v "$FONT_DIR"
+
+popd
+rm -rf "$TEMP_DIR"
+
+echo "Iosevka fonts have been installed."
nihil fit ex nihilo