summaryrefslogtreecommitdiffstats
path: root/pkgs/haskell/xmonad-tv
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2024-06-05 14:38:19 +0200
committertv <tv@krebsco.de>2024-06-05 14:38:19 +0200
commit5f09c04951f5c028c7e65f737afbd95808b84992 (patch)
treef4b46a5ba8a1c972c49d1ed44ed5098ec807dd42 /pkgs/haskell/xmonad-tv
parentaf6f1de6d1c1eb4f4cd9510e1826042ed265b776 (diff)
xmonad shell: admit multiple displays
Diffstat (limited to 'pkgs/haskell/xmonad-tv')
-rw-r--r--pkgs/haskell/xmonad-tv/shell.nix33
1 files changed, 21 insertions, 12 deletions
diff --git a/pkgs/haskell/xmonad-tv/shell.nix b/pkgs/haskell/xmonad-tv/shell.nix
index c50bdd9..859d1ea 100644
--- a/pkgs/haskell/xmonad-tv/shell.nix
+++ b/pkgs/haskell/xmonad-tv/shell.nix
@@ -20,6 +20,12 @@ in
lib.overrideDerivation xmonadDrv.env (oldAttrs: {
shellHook = ''
+ display=$(echo "$DISPLAY" | sed -rn 's/^:([0-9]+)(\.[0-9]+)?$/\1/p')
+ if test -z "$display"; then
+ echo "Error: unsupported display name “$DISPLAY”" >&2
+ exit -1
+ fi
+
pkg_name=${mylib.shell.escape (builtins.baseNameOf (toString ./.))}
WORKDIR=${toString ./src}
@@ -28,12 +34,15 @@ in
mkdir -p "$CACHEDIR"
- config_XMONAD_CACHE_DIR=${mylib.shell.escape
- config.systemd.services.xmonad.environment.XMONAD_CACHE_DIR
- }
-
+ service=xmonad@$display.service
xmonad=$CACHEDIR/xmonad-${builtins.currentSystem}
+ service_XMONAD_CACHE_DIR=$(
+ systemctl show "$service" --property=Environment |
+ tr \ \\n |
+ sed -rn 's/^XMONAD_CACHE_DIR=//p'
+ )
+
xmonad_build() {(
set -efu
cd "$WORKDIR"
@@ -50,9 +59,9 @@ in
xmonad_restart() {(
set -efu
cd "$WORKDIR"
- if systemctl --quiet is-active xmonad; then
- sudo systemctl stop xmonad
- cp -b "$config_XMONAD_CACHE_DIR"/xmonad.state "$CACHEDIR"/
+ if systemctl --quiet is-active "$service"; then
+ systemctl stop "$service"
+ cp -b "$service_XMONAD_CACHE_DIR"/xmonad.state "$CACHEDIR"/
echo "xmonad.state: $(cat "$CACHEDIR"/xmonad.state)"
else
"$xmonad" --shutdown || :
@@ -63,17 +72,17 @@ in
xmonad_yield() {(
set -efu
- if ! systemctl --quiet is-active xmonad; then
+ if ! systemctl --quiet is-active "$service"; then
"$xmonad" --shutdown
- cp -b "$CACHEDIR"/xmonad.state "$config_XMONAD_CACHE_DIR"/
- sudo systemctl start xmonad
+ cp -b "$CACHEDIR"/xmonad.state "$service_XMONAD_CACHE_DIR"/
+ systemctl start "$service"
else
- echo "xmonad.service is already running" >&2
+ echo "$service is already running" >&2
exit -1
fi
)}
- export PATH=${config.systemd.services.xmonad.path}:$PATH
+ export PATH=${lib.makeBinPath (config.systemd.services."xmonad@".path)}:$PATH
export SHELL=/run/current-system/sw/bin/bash
export XMONAD_CACHE_DIR="$CACHEDIR"