home/hyprland: add options for default workspaces and window manager binds
Some checks are pending
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

This commit is contained in:
Aly Raffauf 2024-07-19 12:50:03 -04:00
parent ab5081b910
commit cf5ce8202f
5 changed files with 76 additions and 91 deletions

View file

@ -9,13 +9,10 @@ in {
config = lib.mkIf cfg.desktop.hyprland.enable { config = lib.mkIf cfg.desktop.hyprland.enable {
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
enable = true; enable = true;
settings = settings =
import ./vars.nix {inherit config lib pkgs;}; import ./vars.nix {inherit config lib pkgs;};
extraConfig = let extraConfig = ''
inherit (import ./helpers.nix {inherit config lib pkgs;}) defaultWorkspaces windowManagerBinds;
in ''
submap=resize submap=resize
binde=,down,resizeactive,0 10 binde=,down,resizeactive,0 10
binde=,left,resizeactive,-10 0 binde=,left,resizeactive,-10 0
@ -38,7 +35,7 @@ in {
bind = , ${key}, movewindow, ${direction} bind = , ${key}, movewindow, ${direction}
bind = CONTROL, ${key}, movecurrentworkspacetomonitor, ${direction} bind = CONTROL, ${key}, movecurrentworkspacetomonitor, ${direction}
'') '')
windowManagerBinds cfg.desktop.hyprland.windowManagerBinds
) )
} }
@ -46,7 +43,7 @@ in {
${ ${
lib.strings.concatMapStringsSep "\n" lib.strings.concatMapStringsSep "\n"
(x: "bind = , ${toString x}, movetoworkspace, ${toString x}") (x: "bind = , ${toString x}, movetoworkspace, ${toString x}")
defaultWorkspaces cfg.desktop.hyprland.workspaces
} }
# hyprnome # hyprnome

View file

@ -1,63 +0,0 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.ar.home;
in {
# Media/hardware commands
brightness = rec {
bin = lib.getExe' pkgs.swayosd "swayosd-client";
up = "${bin} --brightness=raise";
down = "${bin} --brightness=lower";
};
# 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";
};
defaultWorkspaces = [1 2 3 4 5 6 7 8 9];
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";
};
windowManagerBinds = {
down = "d";
left = "l";
right = "r";
up = "u";
h = "l";
j = "d";
k = "u";
l = "r";
};
}

View file

@ -6,7 +6,7 @@
}: let }: let
cfg = config.ar.home; cfg = config.ar.home;
hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"; hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl";
inherit (import ./helpers.nix {inherit config lib pkgs;}) defaultApps media; virtKeyboard = lib.getExe' pkgs.squeekboard "squeekboard";
in { in {
clamshell = pkgs.writeShellScript "hyprland-clamshell" '' clamshell = pkgs.writeShellScript "hyprland-clamshell" ''
NUM_MONITORS=$(${hyprctl} monitors all | grep Monitor | wc --lines) NUM_MONITORS=$(${hyprctl} monitors all | grep Monitor | wc --lines)
@ -25,11 +25,11 @@ in {
idleD = pkgs.writeShellScript "hyprland-idled" '' idleD = pkgs.writeShellScript "hyprland-idled" ''
${lib.getExe pkgs.swayidle} -w \ ${lib.getExe pkgs.swayidle} -w \
before-sleep '${media.paus}' \ before-sleep '${lib.getExe pkgs.playerctl} play-pause' \
before-sleep '${defaultApps.lock}' \ before-sleep '${lib.getExe pkgs.swaylock}' \
timeout 240 '${lib.getExe pkgs.brightnessctl} -s set 10' \ timeout 240 '${lib.getExe pkgs.brightnessctl} -s set 10' \
resume '${lib.getExe pkgs.brightnessctl} -r' \ resume '${lib.getExe pkgs.brightnessctl} -r' \
timeout 300 '${defaultApps.lock}' \ timeout 300 '${lib.getExe pkgs.swaylock}' \
timeout 330 '${hyprctl} dispatch dpms off' \ timeout 330 '${hyprctl} dispatch dpms off' \
resume '${hyprctl} dispatch dpms on' \ resume '${hyprctl} dispatch dpms on' \
${ ${
@ -43,8 +43,8 @@ in {
STATE=`${lib.getExe pkgs.dconf} read /org/gnome/desktop/a11y/applications/screen-keyboard-enabled` STATE=`${lib.getExe pkgs.dconf} read /org/gnome/desktop/a11y/applications/screen-keyboard-enabled`
if [ $STATE -z ] || [ $STATE == "false" ]; then if [ $STATE -z ] || [ $STATE == "false" ]; then
if ! [ `pgrep -f ${defaultApps.virtKeyboard}` ]; then if ! [ `pgrep -f ${virtKeyboard}` ]; then
${defaultApps.virtKeyboard} & ${virtKeyboard} &
fi fi
${lib.getExe pkgs.dconf} write /org/gnome/desktop/a11y/applications/screen-keyboard-enabled true ${lib.getExe pkgs.dconf} write /org/gnome/desktop/a11y/applications/screen-keyboard-enabled true
elif [ $STATE == "true" ]; then elif [ $STATE == "true" ]; then

View file

@ -6,16 +6,46 @@
}: let }: let
cfg = config.ar.home; cfg = config.ar.home;
inherit (import ./scripts.nix {inherit config lib pkgs;}) clamshell idleD tablet wallpaperD; inherit (import ./scripts.nix {inherit config lib pkgs;}) clamshell idleD tablet wallpaperD;
inherit
(import ./helpers.nix {inherit config lib pkgs;}) # Media/hardware commands
brightness brightness = rec {
defaultApps bin = lib.getExe' pkgs.swayosd "swayosd-client";
defaultWorkspaces up = "${bin} --brightness=raise";
media down = "${bin} --brightness=lower";
screenshot };
volume
windowManagerBinds # 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;
logout = lib.getExe pkgs.wlogout;
terminal = lib.getExe cfg.defaultApps.terminal;
};
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 { in {
"$mod" = "SUPER"; "$mod" = "SUPER";
@ -37,7 +67,7 @@ in {
bind = bind =
[ [
"$mod CONTROL, F12, exec, ${screenshot.region}" "$mod CONTROL, F12, exec, ${screenshot.region}"
"$mod CONTROL, L, exec, ${defaultApps.lock}" "$mod CONTROL, L, exec, ${lib.getExe pkgs.swaylock}"
"$mod SHIFT, S, movetoworkspace, special:magic" "$mod SHIFT, S, movetoworkspace, special:magic"
"$mod SHIFT, V, togglefloating" "$mod SHIFT, V, togglefloating"
"$mod SHIFT, W, fullscreen" "$mod SHIFT, W, fullscreen"
@ -63,11 +93,11 @@ in {
"CTRL ALT,M,submap,move" "CTRL ALT,M,submap,move"
"CTRL ALT,R,submap,resize" "CTRL ALT,R,submap,resize"
] ]
++ builtins.map (x: "$mod, ${toString x}, workspace, ${toString x}") defaultWorkspaces ++ builtins.map (x: "$mod, ${toString x}, workspace, ${toString x}") cfg.desktop.hyprland.workspaces
++ builtins.map (x: "$mod SHIFT, ${toString x}, movetoworkspace, ${toString x}") defaultWorkspaces ++ builtins.map (x: "$mod SHIFT, ${toString x}, movetoworkspace, ${toString x}") cfg.desktop.hyprland.workspaces
++ lib.attrsets.mapAttrsToList (key: direction: "$mod, ${key}, movefocus, ${direction}") windowManagerBinds ++ lib.attrsets.mapAttrsToList (key: direction: "$mod, ${key}, movefocus, ${direction}") cfg.desktop.hyprland.windowManagerBinds
++ lib.attrsets.mapAttrsToList (key: direction: "$mod SHIFT, ${key}, movewindow, ${direction}") windowManagerBinds ++ lib.attrsets.mapAttrsToList (key: direction: "$mod SHIFT, ${key}, movewindow, ${direction}") cfg.desktop.hyprland.windowManagerBinds
++ lib.attrsets.mapAttrsToList (key: direction: "$mod CONTROL SHIFT, ${key}, movecurrentworkspacetomonitor, ${direction}") windowManagerBinds; ++ lib.attrsets.mapAttrsToList (key: direction: "$mod CONTROL SHIFT, ${key}, movecurrentworkspacetomonitor, ${direction}") cfg.desktop.hyprland.windowManagerBinds;
bindm = [ bindm = [
# Move/resize windows with mainMod + LMB/RMB and dragging # Move/resize windows with mainMod + LMB/RMB and dragging

View file

@ -151,6 +151,27 @@ in {
type = lib.types.bool; type = lib.types.bool;
}; };
workspaces = lib.mkOption {
description = "Default numbered workspaces to create.";
default = [1 2 3 4 5 6 7 8 9];
type = lib.types.listOf lib.types.int;
};
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.";