summaryrefslogtreecommitdiffstats
path: root/pkgs/simple/xextras.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2025-07-17 12:00:05 +0200
committertv <tv@krebsco.de>2025-07-17 12:04:47 +0200
commit34ea4cacef3c12a45d774cff652651557d422161 (patch)
tree18d622bef31fc7074b5e0f89348b67a07266985d /pkgs/simple/xextras.nix
parentb2bc4253dc57a42b9a05aa1feea878cde24d2f2b (diff)
xextras: init with net-current-desktop
Diffstat (limited to 'pkgs/simple/xextras.nix')
-rw-r--r--pkgs/simple/xextras.nix19
1 files changed, 19 insertions, 0 deletions
diff --git a/pkgs/simple/xextras.nix b/pkgs/simple/xextras.nix
new file mode 100644
index 0000000..c9c0308
--- /dev/null
+++ b/pkgs/simple/xextras.nix
@@ -0,0 +1,19 @@
+{ pkgs }:
+
+pkgs.write "xextras" {
+ "/bin/net-current-desktop".link =
+ pkgs.writeDash "net-current-desktop" ''
+ # SYNOPSIS
+ # net-current-desktop
+ #
+ ${pkgs.xorg.xprop}/bin/xprop -notype -root 32i _NET_CURRENT_DESKTOP 8s _NET_DESKTOP_NAMES |
+ ${pkgs.jq}/bin/jq -Rrs '
+ split("\n") | map(select(.!="") | split(" = ") | { name: .[0], value: .[1] }) | from_entries |
+ {
+ _NET_CURRENT_DESKTOP: (._NET_CURRENT_DESKTOP | tonumber),
+ _NET_DESKTOP_NAMES: (._NET_DESKTOP_NAMES | "[\(ltrimstr("._NET_DESKTOP_NAMES = "))]" | fromjson)
+ } |
+ ._NET_DESKTOP_NAMES[._NET_CURRENT_DESKTOP]
+ '
+ '';
+}