stockholm/lass/5pkgs/xephyrify/default.nix

63 lines
1.7 KiB
Nix
Raw Normal View History

2018-03-06 20:30:05 +00:00
{ writeDashBin, writeHaskell, coreutils, xorg, virtualgl, ... }:
2018-03-03 17:28:05 +00:00
2018-03-06 20:30:05 +00:00
let
2018-03-28 19:08:35 +00:00
xephyrify-xmonad = writeHaskell "xephyrify-xmonad" {
2018-03-06 20:30:05 +00:00
executables.xmonad = {
extra-depends = [
"containers"
2018-03-28 19:08:35 +00:00
"unix"
2018-03-06 20:30:05 +00:00
"xmonad"
];
text = /* haskell */ ''
module Main where
import XMonad
2018-03-28 19:08:35 +00:00
import Data.Monoid
import System.Posix.Process (executeFile)
2018-03-06 20:30:05 +00:00
import qualified Data.Map as Map
main :: IO ()
main = do
xmonad def
{ workspaces = [ "1" ]
, layoutHook = myLayoutHook
, keys = myKeys
, normalBorderColor = "#000000"
, focusedBorderColor = "#000000"
2018-03-28 19:08:35 +00:00
, handleEventHook = myEventHook
2018-03-06 20:30:05 +00:00
}
2018-03-28 19:08:35 +00:00
myEventHook :: Event -> X All
myEventHook (ConfigureEvent { ev_event_type = 22 }) = do
spawn "${xorg.xrandr}/bin/xrandr >/dev/null 2>&1"
return (All True)
myEventHook _ = do
return (All True)
2018-03-06 20:30:05 +00:00
myLayoutHook = Full
myKeys _ = Map.fromList []
'';
};
};
in writeDashBin "xephyrify" ''
NDISPLAY=''${NDISPLAY:-$(${coreutils}/bin/shuf -i 100-65536 -n 1)}
2018-03-06 20:30:05 +00:00
echo "using DISPLAY $NDISPLAY"
${xorg.xorgserver}/bin/Xephyr -br -ac -reset -terminate -resizeable -dpi 60 -nolisten local :$NDISPLAY &
if test -n $DROP_TO_USER; then
sleep 1
ls /tmp/.X11-unix/
id
${coreutils}/bin/chgrp "$DROP_TO_USER" "/tmp/.X11-unix/X$NDISPLAY"
${coreutils}/bin/chmod 770 "/tmp/.X11-unix/X$NDISPLAY"
fi
2018-03-03 17:28:05 +00:00
XEPHYR_PID=$!
DISPLAY=:$NDISPLAY ${xephyrify-xmonad}/bin/xmonad &
2018-03-06 20:30:05 +00:00
XMONAD_PID=$!
DISPLAY=:$NDISPLAY ${virtualgl}/bin/vglrun "$@"
2018-03-06 20:30:05 +00:00
kill $XMONAD_PID
2018-03-03 17:28:05 +00:00
kill $XEPHYR_PID
''