Skip to content

Instantly share code, notes, and snippets.

@lidgnulinux
Created January 6, 2023 23:06
Show Gist options
  • Save lidgnulinux/b9a892e7e6cf60979bc34d84bb1f8dc5 to your computer and use it in GitHub Desktop.
Save lidgnulinux/b9a892e7e6cf60979bc34d84bb1f8dc5 to your computer and use it in GitHub Desktop.
Toggle desktop for sway.
#!/usr/bin/bash
unminimize () {
swaymsg [app_id='.*'] focus
}
minimize () {
swaymsg [app_id='.*'] move scratchpad
}
focus () {
swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)' | jq -r '.app_id'
}
if [[ $(focus) == null ]]; then
unminimize
else
minimize
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment