aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2022-09-23 05:12:16 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2022-09-23 05:12:16 +0300
commit2db3689308f57c99b4df61f0e2dea9b44e68c97d (patch)
tree5c6469af30c10d8a23f62761fb0a85c87eabd59a
parent0251f98c0f71eb0028c5ad3a50cd9dc2825745e6 (diff)
downloadswayrice-2db3689308f57c99b4df61f0e2dea9b44e68c97d.tar.gz
swayrice-2db3689308f57c99b4df61f0e2dea9b44e68c97d.zip
sway windows switcher/swapper
-rw-r--r--dotfiles/.config/sway/config5
-rwxr-xr-xdotfiles/.local/bin/menuwin26
2 files changed, 29 insertions, 2 deletions
diff --git a/dotfiles/.config/sway/config b/dotfiles/.config/sway/config
index 029ee97..a96f627 100644
--- a/dotfiles/.config/sway/config
+++ b/dotfiles/.config/sway/config
@@ -19,7 +19,7 @@ mouse_warping container
# Configure border style <normal|1pixel|pixel xx|none|pixel>
default_border pixel 2
-default_floating_border pixel 2
+default_floating_border normal 2
# Hide borders
# hide_edge_borders both
@@ -200,7 +200,8 @@ bindsym --to-code {
$mod+Shift+apostrophe exec "menupass -l"
$mod+Ctrl+apostrophe exec "menupass -f"
$mod+Ctrl+Shift+apostrophe exec "menupass -s"
- $mod+backslash exec "menuworkspace"
+ $mod+backslash exec "menuwin"
+ $mod+Shift+backslash exec "menuwin -s"
# Screenshot and recording
Print exec screensht "full screen"
diff --git a/dotfiles/.local/bin/menuwin b/dotfiles/.local/bin/menuwin
new file mode 100755
index 0000000..c3c8f57
--- /dev/null
+++ b/dotfiles/.local/bin/menuwin
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+# Based on https://gist.github.com/lbonn/89d064cde963cfbacabd77e0d3801398
+
+prompt="Switch to"
+[ "$1" = "-s" ] && prompt="Swap with"
+
+row=$(swaymsg -t get_tree | jq -r '
+ ..
+ | objects
+ | select(.type == "workspace") as $ws
+ | ..
+ | objects
+ | select(has("app_id"))
+ | (if .focused == true then "*" else " " end) as $asterisk
+ | "[\($ws.name)] \($asterisk) <span weight=\"bold\">\(.app_id)</span> - \(.name) <!-- \(.id) -->\u0000icon\u001f\(.app_id)"' \
+| sed 's/&/&amp;/g' \
+| rofi -i -dmenu -show-icons -markup-rows -p "$prompt")
+
+if [ ! -z "$row" ]; then
+ winid=$(echo "$row" | sed 's/.*<!-- \([0-9]*\) -->.*/\1/')
+ if [ "$1" = "-s" ]; then
+ swaymsg "swap container with con_id $winid"
+ else
+ swaymsg "[con_id=$winid] focus"
+ fi
+fi