Skip to content

Instantly share code, notes, and snippets.

@iguanajuice
Created October 16, 2024 05:21
Show Gist options
  • Save iguanajuice/a4a795eb7362bb00035552d9e57c988e to your computer and use it in GitHub Desktop.
Save iguanajuice/a4a795eb7362bb00035552d9e57c988e to your computer and use it in GitHub Desktop.
Use fuzzel to focus windows in sway's scratchpad
#!/bin/sh
pkill fuzzel && exit
TREE=`swaymsg -t get_tree | jq -r '.nodes[].nodes[]'`
SCRATCHPAD=`echo $TREE | jq -r 'select(.name=="__i3_scratch") | .focus[]'`
if [ `echo $SCRATCHPAD | wc -w` -lt 2 ]
then
swaymsg "scratchpad show"
exit
fi
for i in $SCRATCHPAD
do
LIST=$LIST"[$i] "`echo $TREE | jq -r '.floating_nodes[] | select(.id=='$i') | .name'`"\n"
done
CONID=`printf "$LIST" | fuzzel -dw150 | awk '{print $1}' | tr [] \ `
swaymsg "[con_id=$CONID] scratchpad show"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment