-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REBASE: Window Management keybindings
- Loading branch information
Sukant Hajra
committed
Feb 4, 2024
1 parent
d5428f9
commit 8f47dcf
Showing
9 changed files
with
509 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ nix-project-lib | ||
, coreutils | ||
, i3 | ||
, jq | ||
}: | ||
|
||
let | ||
progName = "i3-scratchpad"; | ||
meta.description = "Manage I3 scratchpad"; | ||
in | ||
|
||
nix-project-lib.writeShellCheckedExe progName | ||
{ | ||
inherit meta; | ||
|
||
path = [ | ||
coreutils | ||
i3 | ||
jq | ||
]; | ||
} | ||
'' | ||
set -eu | ||
set -o pipefail | ||
main() | ||
{ | ||
case "''${1:-}" in | ||
move) move ;; | ||
*) cycle ;; | ||
esac | ||
} | ||
move() | ||
{ | ||
if is_in_scratchpad | ||
then | ||
i3-msg floating toggle | ||
else | ||
i3-msg move scratchpad | ||
i3-msg scratchpad show | ||
fi | ||
} | ||
cycle() | ||
{ | ||
if is_in_scratchpad | ||
then i3-msg "scratchpad show; scratchpad show" | ||
else i3-msg focus next | ||
fi | ||
} | ||
is_in_scratchpad() | ||
{ | ||
i3-msg -t get_tree \ | ||
| jq --exit-status ' | ||
.. | ||
| select(.scratchpad_state? != "none") | ||
| .nodes[]? | ||
| select(.focused == true) | ||
| .id' >/dev/null | ||
} | ||
main "$@" | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.