From 2db3689308f57c99b4df61f0e2dea9b44e68c97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Fri, 23 Sep 2022 05:12:16 +0300 Subject: sway windows switcher/swapper --- dotfiles/.local/bin/menuwin | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 dotfiles/.local/bin/menuwin (limited to 'dotfiles/.local/bin') 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) \(.app_id) - \(.name) \u0000icon\u001f\(.app_id)"' \ +| sed 's/&/&/g' \ +| rofi -i -dmenu -show-icons -markup-rows -p "$prompt") + +if [ ! -z "$row" ]; then + winid=$(echo "$row" | sed 's/.*.*/\1/') + if [ "$1" = "-s" ]; then + swaymsg "swap container with con_id $winid" + else + swaymsg "[con_id=$winid] focus" + fi +fi -- cgit v1.2.3