nixos/home/common/optional/desktop/dwm/scripts/get-focused-monitor.nix
Sam 8f1e6bc630 Add xdg desktop entries and update scripts
- Add xdg desktop entries for Firefox, Zathura, Nsxiv-wrapper, Nvim-wrapper, and Mpv-wrapper
- Update clipboard-recall and get-focused-monitor scripts to use xorg.xrandr and xdotool
- Include restic-backup.nix and enable fuse.userAllowOther in citadel configuration.
2025-01-06 19:05:20 +00:00

25 lines
784 B
Nix

{ pkgs, ... }:
{
home.packages = with pkgs; [
(writeShellScriptBin "get-focused-monitor" ''
# get the current cursor location into X and Y variables
eval $(${xdotool}/bin/xdotool getmouselocation --shell)
# compare mouse location to monitor coordinates
while IFS= read -r line; do
if [[ $line =~ " connected" ]]; then
display=$(echo "$line" | awk '{print $1}')
coords=$(echo "$line" | grep -oP "\d+x\d+" | tr 'x+' ' ')
read width height x_offset y_offset <<< $coords
if (( X >= x_offset && X <= width + x_offset )) && (( Y >= y_offset && Y <= height + y_offset )); then
echo "$display"
break
fi
fi
done < <(xrandr)
'')
];
}