home/hyprland: rewrite in nix (#48)
Some checks are pending
flakehub / flakehub-publish (push) Waiting to run
git-mirror / gitlab-sync (push) Waiting to run
nix-build / default-build (push) Waiting to run
nix-build / fallarbor-build (push) Waiting to run
nix-build / lavaridge-build (push) Waiting to run
nix-build / mauville-build (push) Waiting to run
nix-build / petalburg-build (push) Waiting to run
nix-build / rustboro-build (push) Waiting to run
nix-check / fmt-check (push) Waiting to run
nix-check / eval-check (push) Waiting to run

* home/hyprland: move scripts to scripts.nix

* home/hyprland: rewirte config in nix

* home/hyprland: moved all easily possible variables to nix

* nix fmt

* home/hyprland: move everything except usbmaps to nix

* aly: move hyprland config to nix

* petalburg: move hyprland config to nix

* home/hyprland: move submap starters to nix

* home/hyprland: inherit window and layer rules from vars.nix

* nix fmt

* home/hyprland: moved all hyprland settings to vars.nix

* home/hyprland: add options for default workspaces and window manager binds

* home/hyprland: remove workspaces option

* home/hyprland: vars.nix -> settings.nix

* home/hyprland: nixify extraConfig

* home/hyprland: standardize hyprland argument calls

* home/hyprland: get rid of defaultApps
This commit is contained in:
Aly Raffauf 2024-07-19 13:59:48 -04:00 committed by GitHub
parent b8c403cf8a
commit b53a94c121
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 426 additions and 491 deletions

View file

@ -7,384 +7,25 @@
cfg = config.ar.home; cfg = config.ar.home;
in { in {
config = lib.mkIf cfg.desktop.hyprland.enable { config = lib.mkIf cfg.desktop.hyprland.enable {
wayland.windowManager = { wayland.windowManager.hyprland = {
hyprland.enable = true; enable = true;
settings = import ./settings.nix {inherit config lib pkgs;};
hyprland.extraConfig = let extraConfig = let
inherit moveMonitorBinds =
(import ./vars.nix) lib.attrsets.mapAttrsToList (
defaultWorkspaces key: direction: "bind=CONTROL,${key},movecurrentworkspacetomonitor,${direction}"
layerRules
modifier
windowManagerBinds
windowRules
;
# Hyprland desktop utilities
hyprnome = lib.getExe pkgs.hyprnome;
hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl";
# Default apps
defaultApps = {
browser = lib.getExe cfg.defaultApps.webBrowser;
editor = lib.getExe cfg.defaultApps.editor;
fileManager = lib.getExe cfg.defaultApps.fileManager;
launcher = lib.getExe pkgs.fuzzel;
lock = lib.getExe pkgs.swaylock;
logout = lib.getExe pkgs.wlogout;
terminal = lib.getExe cfg.defaultApps.terminal;
virtKeyboard = lib.getExe' pkgs.squeekboard "squeekboard";
};
wallpaperd =
if cfg.desktop.hyprland.randomWallpaper
then
pkgs.writers.writeRuby "hyprland-randomWallpaper" {} ''
require 'fileutils'
directory = "${config.xdg.dataHome}/backgrounds/"
hyprctl = "${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"}"
current_pids = {}
known_monitors = {}
last_update_time = {}
update_interval = 900 # 15 minutes in seconds
sleep 1
if Dir.exist?(directory)
loop do
outputs = IO.popen([hyprctl, 'monitors']).read
active_monitors = outputs.each_line.map { |line| line.split[1] if line.include?('Monitor') }.compact
added_monitors = active_monitors - known_monitors.keys
removed_monitors = known_monitors.keys - active_monitors
# Handle newly added monitors
added_monitors.each do |monitor|
random_background = Dir.glob(File.join(directory, '*.{png,jpg}')).sample
pid = spawn("/nix/store/azvrjs0k5ap90dcqw280xrbqlm6nkibv-swaybg-1.2.1/bin/swaybg", '-o', monitor, '-i', random_background, '-m', 'fill')
current_pids[monitor] = pid
last_update_time[monitor] = Time.now
known_monitors[monitor] = random_background
end
# Remove wallpapers from removed monitors
removed_monitors.each do |monitor|
Process.kill('TERM', current_pids[monitor]) if current_pids[monitor]
current_pids.delete(monitor)
last_update_time.delete(monitor)
known_monitors.delete(monitor)
end
# Update wallpapers after the set interval
active_monitors.each do |monitor|
if Time.now - last_update_time[monitor] >= update_interval
random_background = Dir.glob(File.join(directory, '*.{png,jpg}')).sample
pid = spawn("${lib.getExe pkgs.swaybg}", '-o', monitor, '-i', random_background, '-m', 'fill')
sleep 1
Process.kill('TERM', current_pids[monitor]) if current_pids[monitor]
current_pids[monitor] = pid
last_update_time[monitor] = Time.now
known_monitors[monitor] = random_background
end
end
sleep 5 # Check for monitor changes and update intervals every 5 seconds
end
end
''
else "${lib.getExe pkgs.swaybg} -i ${cfg.theme.wallpaper}";
startupApps =
[
wallpaperd
(lib.getExe pkgs.waybar)
idled
(lib.getExe pkgs.wayland-pipewire-idle-inhibit)
(lib.getExe' pkgs.blueman "blueman-applet")
(lib.getExe' pkgs.networkmanagerapplet "nm-applet")
(lib.getExe' pkgs.playerctl "playerctld")
(lib.getExe' pkgs.swayosd "swayosd-server")
(lib.getExe pkgs.mako)
"${pkgs.mate.mate-polkit}/libexec/polkit-mate-authentication-agent-1"
]
++ lib.lists.optional (cfg.desktop.hyprland.redShift)
"${lib.getExe pkgs.gammastep} -l 33.74:-84.38";
screenshot = rec {
bin = lib.getExe pkgs.hyprshot;
folder = "${config.xdg.userDirs.pictures}/screenshots";
screen = "${bin} -m output -o ${folder}";
region = "${bin} -m region -o ${folder}";
};
clamshell = pkgs.writeShellScript "hyprland-clamshell" ''
NUM_MONITORS=$(${hyprctl} monitors all | grep Monitor | wc --lines)
if [ "$1" == "on" ]; then
if [ $NUM_MONITORS -gt 1 ]; then
${hyprctl} keyword monitor "eDP-1, disable"
fi
elif [ "$1" == "off" ]; then
${
lib.strings.concatMapStringsSep "\n"
(monitor: ''${hyprctl} keyword monitor "${monitor}"'')
cfg.desktop.hyprland.laptopMonitors
}
fi
'';
tablet = pkgs.writeShellScript "hyprland-tablet" ''
STATE=`${lib.getExe pkgs.dconf} read /org/gnome/desktop/a11y/applications/screen-keyboard-enabled`
if [ $STATE -z ] || [ $STATE == "false" ]; then
if ! [ `pgrep -f ${defaultApps.virtKeyboard}` ]; then
${defaultApps.virtKeyboard} &
fi
${lib.getExe pkgs.dconf} write /org/gnome/desktop/a11y/applications/screen-keyboard-enabled true
elif [ $STATE == "true" ]; then
${lib.getExe pkgs.dconf} write /org/gnome/desktop/a11y/applications/screen-keyboard-enabled false
fi
'';
# Media/hardware commands
brightness = rec {
bin = lib.getExe' pkgs.swayosd "swayosd-client";
up = "${bin} --brightness=raise";
down = "${bin} --brightness=lower";
};
volume = rec {
bin = lib.getExe' pkgs.swayosd "swayosd-client";
up = "${bin} --output-volume=raise";
down = "${bin} --output-volume=lower";
mute = "${bin} --output-volume=mute-toggle";
micMute = "${bin} --input-volume=mute-toggle";
};
media = rec {
bin = lib.getExe pkgs.playerctl;
play = "${bin} play-pause";
paus = "${bin} pause";
next = "${bin} next";
prev = "${bin} previous";
};
idled = pkgs.writeShellScript "hyprland-idled" ''
${lib.getExe pkgs.swayidle} -w \
before-sleep '${media.paus}' \
before-sleep '${defaultApps.lock}' \
timeout 240 '${lib.getExe pkgs.brightnessctl} -s set 10' \
resume '${lib.getExe pkgs.brightnessctl} -r' \
timeout 300 '${defaultApps.lock}' \
timeout 330 '${hyprctl} dispatch dpms off' \
resume '${hyprctl} dispatch dpms on' \
${
if cfg.desktop.hyprland.autoSuspend
then ''timeout 900 'sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend' \''
else ''\''
}
'';
in ''
${
lib.strings.concatMapStringsSep "\n"
(monitor: ''monitor = ${monitor}'')
(cfg.desktop.hyprland.laptopMonitors
++ cfg.desktop.hyprland.monitors)
}
monitor = ,preferred,auto,auto
${lib.optionalString (cfg.desktop.hyprland.laptopMonitors != []) ''
# Turn off the internal display when lid is closed.
bindl = ,switch:on:Lid Switch,exec,${clamshell} on
bindl = ,switch:off:Lid Switch,exec,${clamshell} off
''}
# Enable virtual keyboard in tablet mode
${
lib.strings.concatMapStringsSep "\n"
(switch: ''bindl = ,switch:${switch},exec,${tablet}'')
cfg.desktop.hyprland.tabletMode.tabletSwitches
}
# unscale XWayland apps
xwayland {
force_zero_scaling = true
}
# Some default env vars.
env = XCURSOR_SIZE,${toString config.home.pointerCursor.size}
env = QT_QPA_PLATFORMTHEME,qt6ct
# Execute necessary apps
${
lib.strings.concatMapStringsSep
"\n"
(x: "exec-once = ${x}")
startupApps
}
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {
kb_layout = us
kb_variant = altgr-intl
follow_mouse = 1
sensitivity = 0 # -1.0 to 1.0, 0 means no modification.
touchpad {
clickfinger_behavior = true
drag_lock = true
middle_button_emulation = true
natural_scroll = true
tap-to-click = true
}
}
gestures {
workspace_swipe = true
workspace_swipe_touch = true
}
general {
gaps_in = 5
gaps_out = 6
border_size = 2
col.active_border = rgba(${lib.strings.removePrefix "#" cfg.theme.colors.secondary}EE) rgba(${lib.strings.removePrefix "#" cfg.theme.colors.primary}EE) 45deg
col.inactive_border = rgba(${lib.strings.removePrefix "#" cfg.theme.colors.inactive}AA)
layout = dwindle
allow_tearing = false
}
decoration {
rounding = 10
blur {
enabled = true
size = 8
passes = 1
}
drop_shadow = yes
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(${lib.strings.removePrefix "#" cfg.theme.colors.shadow}EE)
dim_special = 0.5
${layerRules}
}
animations {
enabled = yes
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
animation = border, 1, 10, default
animation = borderangle, 1, 8, default
animation = fade, 1, 7, default
animation = specialWorkspace, 1, 6, default, slidevert
animation = windows, 1, 7, myBezier
animation = windowsOut, 1, 7, default, popin 80%
animation = workspaces, 1, 6, default
}
dwindle {
preserve_split = yes
}
master {
always_center_master = true
new_status = false
}
misc {
disable_hyprland_logo = true
disable_splash_rendering = true
focus_on_activate = true
vfr = true
}
# Window Rules
${windowRules}
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = ${modifier}, B, exec, ${defaultApps.browser}
bind = ${modifier}, E, exec, ${defaultApps.editor}
bind = ${modifier}, F, exec, ${defaultApps.fileManager}
bind = ${modifier}, R, exec, ${defaultApps.launcher}
bind = ${modifier}, T, exec, ${defaultApps.terminal}
# Manage session.
bind = ${modifier}, C, killactive,
bind = ${modifier} CONTROL, L, exec, ${defaultApps.lock}
bind = ${modifier}, M, exec, ${defaultApps.logout}
# Basic window management.
bind = ${modifier} SHIFT, W, fullscreen
bind = ${modifier} SHIFT, V, togglefloating,
# bind = ${modifier} SHIFT, P, pseudo, # dwindle
bind = ${modifier} SHIFT, backslash, togglesplit, # dwindle
# Move focus with mainMod + keys ++
# Move window with mainMod SHIFT + keys ++
# Move workspace to another output with mainMod CONTROL SHIFT + keys.
${
lib.strings.concatLines
(
lib.attrsets.mapAttrsToList (key: direction: ''
bind = ${modifier}, ${key}, movefocus, ${direction}
bind = ${modifier} SHIFT, ${key}, movewindow, ${direction}
bind = ${modifier} CONTROL SHIFT, ${key}, movecurrentworkspacetomonitor, ${direction}
'')
windowManagerBinds
) )
} cfg.desktop.hyprland.windowManagerBinds;
# Gnome-like workspaces. moveWindowBinds =
bind = ${modifier}, comma, exec, ${hyprnome} --previous lib.attrsets.mapAttrsToList (
bind = ${modifier}, period, exec, ${hyprnome} key: direction: "bind=,${key},movewindow,${direction}"
bind = ${modifier} SHIFT, comma, exec, ${hyprnome} --previous --move )
bind = ${modifier} SHIFT, period, exec, ${hyprnome} --move cfg.desktop.hyprland.windowManagerBinds;
# Switch workspaces with mainMod + [1-9] ++ moveWorkspaceBinds = builtins.map (x: "bind=,${toString x},workspace,${toString x}") [1 2 3 4 5 6 7 8 9];
# Move active window to a workspace with mainMod + SHIFT + [1-9]. in ''
${
lib.strings.concatMapStringsSep "\n"
(x: ''
bind = ${modifier}, ${toString x}, workspace, ${toString x}
bind = ${modifier} SHIFT, ${toString x}, movetoworkspace, ${toString x}
'')
defaultWorkspaces
}
# Scratchpad show and move
bind = ${modifier}, S, togglespecialworkspace, magic
bind = ${modifier} SHIFT, S, movetoworkspace, special:magic
# Scroll through existing workspaces with mainMod + scroll
bind = ${modifier}, mouse_down, workspace, +1
bind = ${modifier}, mouse_up, workspace, -1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = ${modifier}, mouse:272, movewindow
bindm = ${modifier}, mouse:273, resizewindow
# Display, volume, microphone, and media keys.
bindle = , xf86monbrightnessup, exec, ${brightness.up}
bindle = , xf86monbrightnessdown, exec, ${brightness.down}
bindle = , xf86audioraisevolume, exec, ${volume.up};
bindle = , xf86audiolowervolume, exec, ${volume.down};
bindl = , xf86audiomute, exec, ${volume.mute}
bindl = , xf86audiomicmute, exec, ${volume.micMute}
bindl = , xf86audioplay, exec, ${media.play}
bindl = , xf86audioprev, exec, ${media.prev}
bindl = , xf86audionext, exec, ${media.next}
# Screenshot with hyprshot.
bind = , PRINT, exec, ${screenshot.screen}
bind = ${modifier}, PRINT, exec, ${screenshot.region}
bind = CONTROL, F12, exec, ${screenshot.screen}
bind = ${modifier} CONTROL, F12, exec, ${screenshot.region}
# Show/hide waybar.
bind = ${modifier}, F11, exec, pkill -SIGUSR1 waybar
bind=CTRL ALT,R,submap,resize
submap=resize submap=resize
binde=,down,resizeactive,0 10 binde=,down,resizeactive,0 10
binde=,left,resizeactive,-10 0 binde=,left,resizeactive,-10 0
@ -397,31 +38,12 @@ in {
bind=,escape,submap,reset bind=,escape,submap,reset
submap=reset submap=reset
bind=CTRL ALT,M,submap,move
submap=move submap=move
# Move window with keys ++ ${lib.strings.concatLines moveMonitorBinds}
# Move workspaces across monitors with CONTROL + keys. ${lib.strings.concatLines moveWindowBinds}
${ ${lib.strings.concatLines moveWorkspaceBinds}
lib.strings.concatLines bind=,comma,exec,${lib.getExe pkgs.hyprnome} --previous --move
( bind=,period,exec,${lib.getExe pkgs.hyprnome} --move
lib.attrsets.mapAttrsToList (key: direction: ''
bind = , ${key}, movewindow, ${direction}
bind = CONTROL, ${key}, movecurrentworkspacetomonitor, ${direction}
'')
windowManagerBinds
)
}
# Move active window to a workspace with [1-9]
${
lib.strings.concatMapStringsSep "\n"
(x: "bind = , ${toString x}, movetoworkspace, ${toString x}")
defaultWorkspaces
}
# hyprnome
bind = , comma, exec, ${hyprnome} --previous --move
bind = , period, exec, ${hyprnome} --move
bind=,escape,submap,reset bind=,escape,submap,reset
submap=reset submap=reset
''; '';

View file

@ -0,0 +1,114 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.ar.home;
hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl";
virtKeyboard = lib.getExe' pkgs.squeekboard "squeekboard";
in {
clamshell = pkgs.writeShellScript "hyprland-clamshell" ''
NUM_MONITORS=$(${hyprctl} monitors all | grep Monitor | wc --lines)
if [ "$1" == "on" ]; then
if [ $NUM_MONITORS -gt 1 ]; then
${hyprctl} keyword monitor "eDP-1, disable"
fi
elif [ "$1" == "off" ]; then
${
lib.strings.concatMapStringsSep "${hyprctl}\n"
(monitor: ''${hyprctl} keyword monitor "${monitor}"'')
cfg.desktop.hyprland.laptopMonitors
}
fi
'';
idleD = pkgs.writeShellScript "hyprland-idled" ''
${lib.getExe pkgs.swayidle} -w \
before-sleep '${lib.getExe pkgs.playerctl} play-pause' \
before-sleep '${lib.getExe pkgs.swaylock}' \
timeout 240 '${lib.getExe pkgs.brightnessctl} -s set 10' \
resume '${lib.getExe pkgs.brightnessctl} -r' \
timeout 300 '${lib.getExe pkgs.swaylock}' \
timeout 330 '${hyprctl} dispatch dpms off' \
resume '${hyprctl} dispatch dpms on' \
${
if cfg.desktop.hyprland.autoSuspend
then ''timeout 900 'sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend' \''
else ''\''
}
'';
tablet = pkgs.writeShellScript "hyprland-tablet" ''
STATE=`${lib.getExe pkgs.dconf} read /org/gnome/desktop/a11y/applications/screen-keyboard-enabled`
if [ $STATE -z ] || [ $STATE == "false" ]; then
if ! [ `pgrep -f ${virtKeyboard}` ]; then
${virtKeyboard} &
fi
${lib.getExe pkgs.dconf} write /org/gnome/desktop/a11y/applications/screen-keyboard-enabled true
elif [ $STATE == "true" ]; then
${lib.getExe pkgs.dconf} write /org/gnome/desktop/a11y/applications/screen-keyboard-enabled false
fi
'';
wallpaperD =
if cfg.desktop.hyprland.randomWallpaper
then
pkgs.writers.writeRuby "hyprland-randomWallpaper" {} ''
require 'fileutils'
directory = "${config.xdg.dataHome}/backgrounds/"
hyprctl = "${hyprctl}"
current_pids = {}
known_monitors = {}
last_update_time = {}
update_interval = 900 # 15 minutes in seconds
sleep 1
if Dir.exist?(directory)
loop do
outputs = IO.popen([hyprctl, 'monitors']).read
active_monitors = outputs.each_line.map { |line| line.split[1] if line.include?('Monitor') }.compact
added_monitors = active_monitors - known_monitors.keys
removed_monitors = known_monitors.keys - active_monitors
# Handle newly added monitors
added_monitors.each do |monitor|
random_background = Dir.glob(File.join(directory, '*.{png,jpg}')).sample
pid = spawn("/nix/store/azvrjs0k5ap90dcqw280xrbqlm6nkibv-swaybg-1.2.1/bin/swaybg", '-o', monitor, '-i', random_background, '-m', 'fill')
current_pids[monitor] = pid
last_update_time[monitor] = Time.now
known_monitors[monitor] = random_background
end
# Remove wallpapers from removed monitors
removed_monitors.each do |monitor|
Process.kill('TERM', current_pids[monitor]) if current_pids[monitor]
current_pids.delete(monitor)
last_update_time.delete(monitor)
known_monitors.delete(monitor)
end
# Update wallpapers after the set interval
active_monitors.each do |monitor|
if Time.now - last_update_time[monitor] >= update_interval
random_background = Dir.glob(File.join(directory, '*.{png,jpg}')).sample
pid = spawn("${lib.getExe pkgs.swaybg}", '-o', monitor, '-i', random_background, '-m', 'fill')
sleep 1
Process.kill('TERM', current_pids[monitor]) if current_pids[monitor]
current_pids[monitor] = pid
last_update_time[monitor] = Time.now
known_monitors[monitor] = random_background
end
end
sleep 5 # Check for monitor changes and update intervals every 5 seconds
end
end
''
else "${lib.getExe pkgs.swaybg} -i ${cfg.theme.wallpaper}";
}

View file

@ -0,0 +1,236 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.ar.home;
inherit (import ./scripts.nix {inherit config lib pkgs;}) clamshell idleD tablet wallpaperD;
# Media/hardware commands
brightness = rec {
bin = lib.getExe' pkgs.swayosd "swayosd-client";
up = "${bin} --brightness=raise";
down = "${bin} --brightness=lower";
};
media = rec {
bin = lib.getExe pkgs.playerctl;
play = "${bin} play-pause";
paus = "${bin} pause";
next = "${bin} next";
prev = "${bin} previous";
};
screenshot = rec {
bin = lib.getExe pkgs.hyprshot;
folder = "${config.xdg.userDirs.pictures}/screenshots";
screen = "${bin} -m output -o ${folder}";
region = "${bin} -m region -o ${folder}";
};
volume = rec {
bin = lib.getExe' pkgs.swayosd "swayosd-client";
up = "${bin} --output-volume=raise";
down = "${bin} --output-volume=lower";
mute = "${bin} --output-volume=mute-toggle";
micMute = "${bin} --input-volume=mute-toggle";
};
in {
"$mod" = "SUPER";
animations = {
enabled = true;
bezier = "myBezier,0.05,0.9,0.1,1.05";
animation = [
"border,1,10,default"
"borderangle,1,8,default"
"fade,1,7,default"
"specialWorkspace,1,6,default,slidevert"
"windows,1,7,myBezier"
"windowsOut,1,7,default,popin 80%"
"workspaces,1,6,default"
];
};
bind =
[
"$mod CONTROL,F12,exec,${screenshot.region}"
"$mod CONTROL,L,exec,${lib.getExe pkgs.swaylock}"
"$mod SHIFT,S,movetoworkspace,special:magic"
"$mod SHIFT,V,togglefloating"
"$mod SHIFT,W,fullscreen"
"$mod SHIFT,backslash,togglesplit"
"$mod SHIFT,comma,exec,${lib.getExe pkgs.hyprnome} --previous --move"
"$mod SHIFT,period,exec,${lib.getExe pkgs.hyprnome} --move"
"$mod,B,exec,${lib.getExe cfg.defaultApps.webBrowser}"
"$mod,C,killactive"
"$mod,E,exec,${lib.getExe cfg.defaultApps.editor}"
"$mod,F,exec,${lib.getExe cfg.defaultApps.fileManager}"
"$mod,F11,exec,pkill -SIGUSR1 waybar"
"$mod,M,exec,${lib.getExe pkgs.wlogout}"
"$mod,PRINT,exec,${screenshot.region}"
"$mod,R,exec,${lib.getExe pkgs.fuzzel}"
"$mod,S,togglespecialworkspace,magic"
"$mod,T,exec,${lib.getExe cfg.defaultApps.terminal}"
"$mod,comma,exec,${lib.getExe pkgs.hyprnome} --previous"
"$mod,mouse_down,workspace,+1"
"$mod,mouse_up,workspace,-1"
"$mod,period,exec,${lib.getExe pkgs.hyprnome}"
",PRINT,exec,${screenshot.screen}"
"CONTROL,F12,exec,${screenshot.screen}"
"CTRL ALT,M,submap,move"
"CTRL ALT,R,submap,resize"
]
++ builtins.map (x: "$mod SHIFT, ${toString x}, movetoworkspace, ${toString x}") [1 2 3 4 5 6 7 8 9]
++ builtins.map (x: "$mod, ${toString x}, workspace, ${toString x}") [1 2 3 4 5 6 7 8 9]
++ lib.attrsets.mapAttrsToList (key: direction: "$mod CONTROL SHIFT, ${key}, movecurrentworkspacetomonitor, ${direction}") cfg.desktop.hyprland.windowManagerBinds
++ lib.attrsets.mapAttrsToList (key: direction: "$mod SHIFT, ${key}, movewindow, ${direction}") cfg.desktop.hyprland.windowManagerBinds
++ lib.attrsets.mapAttrsToList (key: direction: "$mod, ${key}, movefocus, ${direction}") cfg.desktop.hyprland.windowManagerBinds;
bindm = [
# Move/resize windows with mainMod + LMB/RMB and dragging
"$mod,mouse:272,movewindow"
"$mod,mouse:273,resizewindow"
];
bindl =
[
# Volume, microphone, and media keys.
",xf86audiomute,exec,${volume.mute}"
",xf86audiomicmute,exec,${volume.micMute}"
",xf86audioplay,exec,${media.play}"
",xf86audioprev,exec,${media.prev}"
",xf86audionext,exec,${media.next}"
]
++ builtins.map (switch: ",switch:${switch},exec,${tablet}") cfg.desktop.hyprland.tabletMode.tabletSwitches
++ lib.lists.optionals (cfg.desktop.hyprland.laptopMonitors != [])
[
",switch:on:Lid Switch,exec,${clamshell} on"
",switch:off:Lid Switch,exec,${clamshell} off"
];
bindle = [
# Display, volume, microphone, and media keys.
", xf86monbrightnessup,exec,${brightness.up}"
", xf86monbrightnessdown,exec,${brightness.down}"
", xf86audioraisevolume,exec,${volume.up}"
", xf86audiolowervolume,exec,${volume.down}"
];
decoration = {
blur = {
enabled = true;
passes = 1;
size = 8;
};
"col.shadow" = "rgba(${lib.strings.removePrefix "#" cfg.theme.colors.shadow}EE)";
dim_special = 0.5;
drop_shadow = true;
layerrule = [
"blur,launcher"
"blur,logout_dialog"
"blur,notifications"
"blur,swayosd"
"blur,waybar"
"ignorezero,notifications"
"ignorezero,swayosd"
"ignorezero,waybar"
];
rounding = 10;
shadow_range = 4;
shadow_render_power = 3;
};
dwindle.preserve_split = true;
env = [
"QT_QPA_PLATFORMTHEME,qt6ct"
"XCURSOR_SIZE,${toString config.home.pointerCursor.size}"
];
exec-once =
[
wallpaperD
(lib.getExe pkgs.waybar)
idleD
(lib.getExe pkgs.wayland-pipewire-idle-inhibit)
(lib.getExe' pkgs.blueman "blueman-applet")
(lib.getExe' pkgs.networkmanagerapplet "nm-applet")
(lib.getExe' pkgs.playerctl "playerctld")
(lib.getExe' pkgs.swayosd "swayosd-server")
(lib.getExe pkgs.mako)
"${pkgs.mate.mate-polkit}/libexec/polkit-mate-authentication-agent-1"
]
++ lib.lists.optional (cfg.desktop.hyprland.redShift)
"${lib.getExe pkgs.gammastep} -l 33.74:-84.38";
input = {
follow_mouse = 1;
kb_layout = "us";
kb_variant = "altgr-intl";
sensitivity = 0; # -1.0 to 1.0, 0 means no modification.
touchpad = {
clickfinger_behavior = true;
drag_lock = true;
middle_button_emulation = true;
natural_scroll = true;
tap-to-click = true;
};
};
general = {
"col.active_border" = "rgba(${lib.strings.removePrefix "#" cfg.theme.colors.secondary}EE) rgba(${lib.strings.removePrefix "#" cfg.theme.colors.primary}EE) 45deg";
"col.inactive_border" = "rgba(${lib.strings.removePrefix "#" cfg.theme.colors.inactive}AA)";
allow_tearing = false;
border_size = 2;
gaps_in = 5;
gaps_out = 6;
layout = "dwindle";
};
gestures = {
workspace_swipe = true;
workspace_swipe_touch = true;
};
master = {
always_center_master = true;
new_status = false;
};
misc = {
disable_hyprland_logo = true;
disable_splash_rendering = true;
focus_on_activate = true;
vfr = true;
};
monitor =
[",preferred,auto,auto"]
++ cfg.desktop.hyprland.laptopMonitors
++ cfg.desktop.hyprland.monitors;
windowrulev2 = [
"center(1),class:(.blueman-manager-wrapped)"
"center(1),class:(com.github.wwmm.easyeffects)"
"center(1),class:(pavucontrol)"
"float, class:^(firefox)$, title:^(Picture-in-Picture)$"
"float,class:(.blueman-manager-wrapped)"
"float,class:(com.github.wwmm.easyeffects)"
"float,class:(pavucontrol)"
"move 70% 20%, class:^(firefox)$, title:^(Picture-in-Picture)$"
"pin,class:^(firefox)$, title:^(Picture-in-Picture)$"
"size 40% 60%,class:(.blueman-manager-wrapped)"
"size 40% 60%,class:(com.github.wwmm.easyeffects)"
"size 40% 60%,class:(pavucontrol)"
"suppressevent maximize, class:.*"
];
xwayland.force_zero_scaling = true;
}

View file

@ -1,48 +0,0 @@
{
defaultWorkspaces = [1 2 3 4 5 6 7 8 9];
layerRules = ''
# Window-specific rules
layerrule = blur, waybar
layerrule = ignorezero, waybar
layerrule = blur, launcher
layerrule = blur, notifications
layerrule = ignorezero, notifications
layerrule = blur, logout_dialog
layerrule = blur, swayosd
layerrule = ignorezero, swayosd
'';
modifier = "SUPER";
windowManagerBinds = {
down = "d";
left = "l";
right = "r";
up = "u";
h = "l";
j = "d";
k = "u";
l = "r";
};
windowRules = ''
windowrulev2 = center(1),class:(.blueman-manager-wrapped)
windowrulev2 = float,class:(.blueman-manager-wrapped)
windowrulev2 = size 40% 60%,class:(.blueman-manager-wrapped})
windowrulev2 = center(1),class:(com.github.wwmm.easyeffects)
windowrulev2 = float,class:(com.github.wwmm.easyeffects)
windowrulev2 = size 40% 60%,class:(com.github.wwmm.easyeffects})
windowrulev2 = center(1),class:(pavucontrol)
windowrulev2 = float,class:(pavucontrol)
windowrulev2 = size 40% 60%,class:(pavucontrol})
windowrulev2 = float, class:^(firefox)$, title:^(Picture-in-Picture)$
windowrulev2 = move 70% 20%, class:^(firefox)$, title:^(Picture-in-Picture)$
windowrulev2 = pin, class:^(firefox)$, title:^(Picture-in-Picture)$
windowrulev2 = suppressevent maximize, class:.*
'';
}

View file

@ -151,6 +151,21 @@ in {
type = lib.types.bool; type = lib.types.bool;
}; };
windowManagerBinds = lib.mkOption {
description = "Default binds for window management.";
default = {
down = "d";
left = "l";
right = "r";
up = "u";
h = "l";
j = "d";
k = "u";
l = "r";
};
type = lib.types.attrs;
};
tabletMode = { tabletMode = {
enable = lib.mkEnableOption "Tablet mode for hyprland."; enable = lib.mkEnableOption "Tablet mode for hyprland.";

View file

@ -19,40 +19,36 @@
]; ];
}; };
hyprland.extraConfig = '' hyprland.settings = {
exec-once = sleep 1 && ${lib.getExe' pkgs.keepassxc "keepassxc"} bind = [
bind = SUPER, P, exec, ${lib.getExe' pkgs.keepassxc "keepassxc"} "SUPER SHIFT,N,movetoworkspace,special:notes"
windowrulev2 = center(1),class:(org.keepassxc.KeePassXC) "SUPER,N,togglespecialworkspace,notes"
windowrulev2 = float,class:(org.keepassxc.KeePassXC) "SUPER,P,exec,${lib.getExe' pkgs.keepassxc "keepassxc"}"
windowrulev2 = size 80% 80%,class:(org.keepassxc.KeePassXC) ];
# Workspace - Browser exec-once = ["sleep 1 && ${lib.getExe' pkgs.keepassxc "keepassxc"}"];
workspace = 1, defaultName:web, on-created-empty:${lib.getExe config.ar.home.defaultApps.webBrowser}
windowrulev2 = workspace 1,class:(firefox)
windowrulev2 = workspace 1,class:(brave-browser)
# Workspace - Coding windowrulev2 = [
workspace = 2, defaultName:code, on-created-empty:${lib.getExe config.ar.home.defaultApps.editor} "center(1),class:(org.keepassxc.KeePassXC)"
windowrulev2 = workspace 2,class:(codium-url-handler) "float,class:(org.keepassxc.KeePassXC)"
windowrulev2 = workspace 2,class:(dev.zed.Zed) "size 80% 80%,class:(org.keepassxc.KeePassXC)"
"workspace 1,class:(brave-browser)"
"workspace 1,class:(firefox)"
"workspace 2,class:(codium-url-handler)"
"workspace 2,class:(dev.zed.Zed)"
"workspace 3,class:(firework)"
"workspace 3,class:(google-chrome)"
"workspace special:magic,class:(WebCord)"
"workspace special:magic,class:(org.gnome.Fractal)"
];
# Workspace - Work workspace = [
windowrulev2 = workspace 3,class:(google-chrome) "1,defaultName:web,on-created-empty:${lib.getExe config.ar.home.defaultApps.webBrowser}"
windowrulev2 = workspace 3,class:(firework) "2,defaultName:code,on-created-empty:${lib.getExe config.ar.home.defaultApps.editor}"
"special:magic,on-created-empty:${lib.getExe pkgs.fractal}"
# Scratchpad Chat "special:notes,on-created-empty:${lib.getExe' pkgs.obsidian "obsidian"}"
# bind = SUPER, S, togglespecialworkspace, magic ];
# bind = SUPER SHIFT, W, movetoworkspace, special:magic };
workspace = special:magic, on-created-empty:${lib.getExe pkgs.fractal}
windowrulev2 = workspace special:magic,class:(org.gnome.Fractal)
windowrulev2 = workspace special:magic,class:(WebCord)
# Scratchpad Notes
bind = SUPER, N, togglespecialworkspace, notes
bind = SUPER SHIFT, N, movetoworkspace, special:notes
workspace = special:notes, on-created-empty:${lib.getExe' pkgs.obsidian "obsidian"}
# windowrulev2 = workspace special:notes,class:(obsidian)
'';
}; };
ar.home.desktop.hyprland.monitors = [ ar.home.desktop.hyprland.monitors = [

View file

@ -6,25 +6,25 @@
}: { }: {
home-manager.sharedModules = [ home-manager.sharedModules = [
{ {
wayland.windowManager.hyprland.extraConfig = '' wayland.windowManager.hyprland.settings = {
input { bind = [
tablet { ",xf86launch4,exec,${lib.getExe self.inputs.pp-adjuster.packages.${pkgs.system}.default}"
output = eDP-1 ",xf86launch2,exec,${lib.getExe pkgs.playerctl} play-pause"
} ];
touchdevice {
output = eDP-1
}
}
# Extra bindings for petalburg. exec-once = [''${
bind = , xf86launch4, exec, ${lib.getExe self.inputs.pp-adjuster.packages.${pkgs.system}.default} lib.getExe self.inputs.iio-hyprland.packages.${pkgs.system}.default
bind = , xf86launch2, exec, ${lib.getExe pkgs.playerctl} play-pause } "desc:Samsung Display Corp. 0x4152''];
exec-once = ${lib.getExe self.inputs.iio-hyprland.packages.${pkgs.system}.default} "desc:Samsung Display Corp. 0x4152" input = {
''; tablet.output = "eDP-1";
touchdevice.output = "eDP-1";
};
};
ar.home.desktop.hyprland = { ar.home.desktop.hyprland = {
laptopMonitors = ["desc:Samsung Display Corp. 0x4152,preferred,auto,2,transform,0"]; laptopMonitors = ["desc:Samsung Display Corp. 0x4152,preferred,auto,2,transform,0"];
tabletMode = { tabletMode = {
enable = true; enable = true;
tabletSwitches = ["Lenovo Yoga Tablet Mode Control switch"]; tabletSwitches = ["Lenovo Yoga Tablet Mode Control switch"];