aboutsummaryrefslogtreecommitdiff
path: root/gui/pkgs/uictrl.nix
diff options
context:
space:
mode:
Diffstat (limited to 'gui/pkgs/uictrl.nix')
-rw-r--r--gui/pkgs/uictrl.nix19
1 files changed, 18 insertions, 1 deletions
diff --git a/gui/pkgs/uictrl.nix b/gui/pkgs/uictrl.nix
index 0c965ad..c85e2bc 100644
--- a/gui/pkgs/uictrl.nix
+++ b/gui/pkgs/uictrl.nix
@@ -5,5 +5,22 @@ pkgs.writeTextFile {
executable = true;
destination = "/bin/uictrl";
- text = builtins.readFile ./bin/uictrl.sh;
+ text = with pkgs; ''
+ #!${fish}/bin/fish
+
+ function cycle
+ set nsp_ws (${wmctrl}/bin/wmctrl -d | awk '{if ($9 == "NSP") {print $1}}')
+ set current_ws (${wmctrl}/bin/wmctrl -d | awk '{if ($2 == "*") {print $1}}')
+
+ ${wmctrl}/bin/wmctrl -l | awk -v current_ws=$current_ws -v nsp_ws=$nsp_ws '{if ($2 > current_ws && $2 != nsp_ws) {print $2}}' | uniq
+ ${wmctrl}/bin/wmctrl -l | awk -v current_ws=$current_ws -v nsp_ws=$nsp_ws '{if ($2 < current_ws && $2 != nsp_ws) {print $2}}' | uniq
+ end
+
+ switch $argv[1]
+ case next
+ ${wmctrl}/bin/wmctrl -s (cycle)[1]
+ case prev
+ ${wmctrl}/bin/wmctrl -s (cycle | tac)[1]
+ end
+ '';
}