add(jellyfin): immersion mode

immersion turns off all other monitor. great for movies
This commit is contained in:
kenji
2026-07-03 20:54:02 -05:00
parent fd1bea0e6e
commit 1b06c411ef
3 changed files with 63 additions and 7 deletions
+44
View File
@@ -0,0 +1,44 @@
{
config,
pkgs,
...
}: let
# Dynamically turns off all unfocused monitors, and restores them on toggle
toggleImmersive = pkgs.writeShellScriptBin "toggle-immersive" ''
STATE_FILE="$XDG_RUNTIME_DIR/hypr_immersive_mode"
if [ -f "$STATE_FILE" ]; then
# 1. Restore: Reloading Hyprland snaps monitors back to your declared Nix defaults
hyprctl reload
rm "$STATE_FILE"
${pkgs.libnotify}/bin/notify-send -u low "Immersive Mode" "Deactivated Displays restored."
else
# 2. Activate: Mark state and dynamically disable all non-focused monitors
touch "$STATE_FILE"
# Use jq to find every monitor that does NOT currently have focus
for mon in $(${pkgs.hyprland}/bin/hyprctl monitors -j | ${pkgs.jq}/bin/jq -r '.[] | select(.focused == false) | .name'); do
${pkgs.hyprland}/bin/hyprctl keyword monitor "$mon, disable"
done
# OPTIONAL: Remove borders and gaps for a true cinema experience
# ${pkgs.hyprland}/bin/hyprctl keyword general:gaps_in 0
# ${pkgs.hyprland}/bin/hyprctl keyword general:gaps_out 0
# ${pkgs.hyprland}/bin/hyprctl keyword general:border_size 0
# ${pkgs.hyprland}/bin/hyprctl keyword decoration:rounding 0
${pkgs.libnotify}/bin/notify-send -u low "Immersive Mode" "Activated Focused display only."
fi
'';
in {
wayland.windowManager.hyprland = {
enable = true;
settings = {
# Bind to your preferred combo (e.g., Super + Alt + M)
bind = [
"$mod ALT, M, exec, ${toggleImmersive}/bin/toggle-immersive"
];
};
};
}