{ config , lib , pkgs , ... }: let kanshi = pkgs.kanshi; writeShellScript = pkgs.writeShellScript; wallpapersPath = "/home/${config.system.singleUser}/Data/Wallpaper"; wallpapersHorizontal = "${wallpapersPath}/horizontal"; wallpapersVertical = "${wallpapersPath}/vertical"; wallpaperScript = writeShellScript "wallpaper.sh" '' set -x [[ $# -lt 1 ]] && echo "No profile specified" && exit 1 random_file() { find "$1" -maxdepth 1 -type f | shuf -n 1 } setbg() { # Sets the background of $1 to $2 swaymsg "output \"$1\" background $2 fill" } case $1 in homeMultihead) horiz=$(random_file ${wallpapersHorizontal}) vert=$(random_file ${wallpapersVertical}) setbg "DP-2" $horiz setbg "HDMI-A-3" $vert ;; genericMultihead) horiz1=$(random_file ${wallpapersHorizontal}) horiz2=$(random_file ${wallpapersHorizontal}) setbg "eDP-1" $horiz1 setbg "HDMI-A-1" $horiz2 ;; laptop) horiz=$(random_file ${wallpapersHorizontal}) setbg "eDP-1" $horiz ;; esac ''; mkProfile = name: outputs: { outputs = outputs; exec = "${wallpaperScript} ${name}"; }; in { environment.systemPackages = [ kanshi ]; home-manager.users."${config.system.singleUser}".services.kanshi = { enable = true; profiles = let horizontal = "Samsung Electric Company C27F398 H4ZR101145"; vertical = "Goldstar Company Ltd IPS235 305NDPHKN600"; in { homeMultihead = mkProfile "homeMultihead" [ { criteria = vertical; status = "enable"; mode = "1920x1080"; transform = "90"; position = "-1080,0"; } { criteria = horizontal; status = "enable"; mode = "1920x1080"; position = "0,0"; } #{ # criteria = "eDP-1"; # status = "enable"; # mode = "1920x1080"; # position = "0,0"; #} ]; #genericMultihead = mkProfile "genericMultihead" [ # { # criteria = "eDP-1"; # mode = "1920x1080"; # status = "enable"; # } # { # criteria = "HDMI-A-1"; # status = "enable"; # } #]; #laptop = mkProfile "laptop" [ # { # criteria = "eDP-1"; # status = "enable"; # mode = "1920x1080"; # position = "0,0"; # } #]; }; }; }