dotfiles/NixOS/modules/hyprland/config.nix

254 lines
8.5 KiB
Nix
Raw Normal View History

2024-06-01 16:56:07 +02:00
{ inputs
, config
, pkgs
, ...
}:
let
hyprland = inputs.hyprland.packages.${pkgs.system}.hyprland;
playerctl = "${pkgs.playerctl}/bin/playerctl";
wl-paste = "${pkgs.wl-clipboard}/bin/wl-paste";
hyprpaper = "${pkgs.hyprpaper}/bin/hyprpaper";
waybar = "${pkgs.waybar}/bin/waybar";
scripts = "${config.xdg.configHome}/scripts";
wpctl = "${pkgs.wireplumber}/bin/wpctl";
alacritty = "${pkgs.alacritty}/bin/alacritty";
swaylock = "${pkgs.swaylock}/bin/swaylock";
rofi = "${pkgs.rofi}/bin/rofi";
jq = "${pkgs.jq}/bin/jq";
launch_alacritty = pkgs.writeShellScriptBin "launch_alacritty" ''
RUNNING_WAYPIPE=false
SSH_CLIENT=""
CHILD_PID=$(pgrep -P "$1")
2024-06-01 16:35:37 +02:00
2024-06-01 16:56:07 +02:00
if [ "$GRAND_CHILD_PID" != "" ]; then
GRAND_CHILD_NAME=$(ps -p "$GRAND_CHILD_PID" -o comm=)
if [ "$GRAND_CHILD_NAME" == "ssh" ]; then
CHILD_PID=$GRAND_CHILD_PID
SSH_CLIENT=$(ps -p "$CHILD_PID" -o args --no-headers | awk '{ print $2 }')
fi
if [ "$GRAND_CHILD_NAME" == "waypipe" ]; then
RUNNING_WAYPIPE=true
CHILD_PID=$(pgrep -P "$GRAND_CHILD_PID")
SSH_CLIENT=$(ps -p "$GRAND_CHILD_PID" -o args --no-headers | awk '{ print $4 }')
fi
fi
2024-06-01 16:35:37 +02:00
2024-06-01 16:56:07 +02:00
if [ $RUNNING_WAYPIPE == true ]; then
PREVIOUS_SESSION_ID=$(grep -z "SSH_SESSION_ID" "/proc/$CHILD_PID/environ" | xargs -0 -n 1 | grep -oP "[0-9]*")
SSH_SESSION_ID=$RANDOM
${alacritty} -e zsh -c "SSH_SESSION_ID=$SSH_SESSION_ID waypipe ssh -t \"$SSH_CLIENT\" env SSH_SESSION_ID=\"$SSH_SESSION_ID\" PREVIOUS_SESSION_ID=\"$PREVIOUS_SESSION_ID\" \"zsh --login\""
else
if [ "$(ps -p "$1" -o comm=)" == "alacritty" ]; then
CWD=$(readlink -e /proc/"$CHILD_PID"/cwd)
if [ "$CWD" != "" ]; then
${alacritty} --working-directory "$CWD"
else
${alacritty}
fi
else
${alacritty}
fi
fi
'';
in
{
services.kdeconnect = {
enable = true;
package = pkgs.kdePackages.kdeconnect-kde;
indicator = true;
};
2024-05-31 23:44:20 +02:00
2024-06-01 17:10:24 +02:00
services.hyprpaper = {
enable = true;
settings = {
2024-06-01 17:19:39 +02:00
ipc = "on";
splash = false;
preload =
[ "${./files/wallpaper.png}" ];
2024-06-01 17:10:24 +02:00
2024-06-01 17:19:39 +02:00
wallpaper = [
"DP-3,${./files/wallpaper.png}"
"DP-2,${./files/wallpaper.png}"
"HDMI-A-1,${./files/wallpaper.png}"
];
2024-06-01 17:10:24 +02:00
};
};
2024-06-01 16:56:07 +02:00
wayland.windowManager.hyprland = {
enable = true;
systemd.variables = [ "--all" ];
systemd.enable = true;
systemd.enableXdgAutostart = true;
xwayland.enable = true;
package = inputs.hyprland.packages.${pkgs.system}.hyprland;
plugins = [
inputs.split-monitor-workspaces.packages.${pkgs.system}.split-monitor-workspaces
];
settings = {
"$mainMod" = "SUPER";
exec-once = [
"hyprpaper"
"${wl-paste} --type text --watch cliphist store"
"${wl-paste} --type image --watch cliphist store"
# "${waybar}"
];
env = [
"WLR_NO_HARDWARE_CURSORS,1"
"TERMINAL,${alacritty}"
"WLR_RENDERER_ALLOW_SOFTWARE,1"
];
debug = {
disable_logs = false;
};
windowrulev2 = [
"float, title:^(rofi)(.*)$"
"center, title:^(rofi)(.*)$"
"noborder, title:^(rofi)(.*)$"
"stayfocused, title:^()$,class:^(steam)$"
"minsize 1 1, title:^()$,class:^(steam)$"
"stayfocused, title:^()$,class:^(steam)$"
];
windowrule = [
"noanim,waybar"
];
monitor = [
"DP-3,preferred,0x550,1"
"DP-2,preferred,1920x0,1"
"HDMI-A-1,preferred,5760x550,1"
];
general = {
gaps_in = 1;
gaps_out = 5;
border_size = 2;
"col.active_border" = "rgba(002f5fee)";
"col.inactive_border" = "rgba(ffffff00)";
layout = "dwindle";
};
input = {
kb_layout = "us";
follow_mouse = 1;
kb_options = "compose:rctrl, caps:super, altwin:swap_alt_win";
numlock_by_default = true;
};
binds = {
scroll_event_delay = 1;
};
xwayland = {
force_zero_scaling = true;
};
misc = {
disable_hyprland_logo = 1;
};
decoration = {
rounding = 1;
blur = {
enabled = false;
};
};
animations = {
enabled = "yes";
bezier = "myBezier, 0.05, 0.9, 0.1, 1.05";
animation = [
"windows, 1, 2, myBezier"
"windowsOut, 1, 2, default, popin 80%"
"border, 1, 2, default"
"borderangle, 1, 2, default"
"fade, 1, 2, default"
"workspaces, 1, 1, default"
2024-05-31 23:44:20 +02:00
];
2024-06-01 16:56:07 +02:00
};
dwindle = {
preserve_split = "yes";
no_gaps_when_only = 1;
force_split = 2;
};
gestures = {
workspace_swipe = "on";
workspace_swipe_invert = false;
};
bindr = [
"$mainMod, SUPER_L, exec, pkill rofi || ${rofi} -show drun"
"$mainMod, SUPER_R, exec, pkill rofi || ${rofi} -show drun"
];
bindm = [
"$mainMod, mouse:272, movewindow"
"$mainMod, mouse:273, resizewindow"
];
bind = [
"$mainMod, return, exec, ${launch_alacritty}/bin/launch_alacritty $(hyprctl activewindow -j | ${jq} .pid)"
"$mainMod SHIFT, return, exec, ${alacritty}"
"$mainMod, Q, killactive,"
"$mainMod, A, exec, nautilus"
"$mainMod, S, exec, gnome-calendar"
"$mainMod, B, exec, MOZ_ENABLE_WAYLAND=1 firefox"
"$mainMod, M, fullscreen, 1"
"$mainMod, F11, fullscreen"
"$mainMod, F, togglefloating,"
"$mainMod, SPACE, togglesplit, # dwindle"
"CONTROL_L ALT_L, L, exec, ${swaylock}"
"$mainMod, C, exec, cliphist list | awk '{print $0, \"\0icon\x1fcom.github.davidmhewitt.clipped\"}' | ${rofi} -dmenu -display-columns 2 | cliphist decode | wl-copy"
"$mainMod, Y, exec, ${config.xdg.configHome}/rofi/rofi-ykman.sh"
"$mainMod, N, exec, ${config.xdg.configHome}/rofi/rofi-ssh.sh"
2024-05-31 23:44:20 +02:00
2024-06-01 16:56:07 +02:00
"$mainMod, Escape, exec, ${rofi} -show power-menu -modi power-menu:${scripts}/rofi-power-menu"
2024-05-31 23:44:20 +02:00
2024-06-01 16:56:07 +02:00
",XF86MonBrightnessUp, exec, xbacklight -inc 10"
",XF86MonBrightnessDown, exec, xbacklight -dec 10"
",XF86AudioRaiseVolume, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 10%+ --limit 1.0"
",XF86AudioLowerVolume, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 10%-"
",XF86AudioMicMute, exec, ${wpctl} set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
",mouse_right, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 1%+ --limit 1.0"
",mouse_left, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 1%-"
",XF86AudioMute, exec, ${wpctl} set-mute @DEFAULT_AUDIO_SINK@ toggle"
",XF86AudioNext, exec, ${playerctl} next"
",XF86AudioPrev, exec, ${playerctl} previous"
"$mainMod,XF86AudioMute, exec, ${playerctl} play-pause"
"$mainMod,XF86AudioRaiseVolume, exec, ${playerctl} next"
"$mainMod,XF86AudioLowerVolume, exec, ${playerctl} previous"
", Print, exec, grim -g \"$(slurp -d)\" - | wl-copy"
2024-05-31 23:44:20 +02:00
2024-06-01 16:56:07 +02:00
"$mainMod, H, exec, ${scripts}/vim-hypr-nav.sh l"
"$mainMod, L, exec, ${scripts}/vim-hypr-nav.sh r"
"$mainMod, K, exec, ${scripts}/vim-hypr-nav.sh u"
"$mainMod, J, exec, ${scripts}/vim-hypr-nav.sh d"
"$mainMod CONTROL_L, H, swapwindow, l"
"$mainMod CONTROL_L, L, swapwindow, r"
"$mainMod CONTROL_L, K, swapwindow, u"
"$mainMod CONTROL_L, J, swapwindow, d"
"$mainMod SHIFT, H, movewindow, l"
"$mainMod SHIFT, L, movewindow, r"
"$mainMod SHIFT, K, movewindow, u"
"$mainMod SHIFT, J, movewindow, d"
"$mainMod ALT, L, resizeactive, 20 0"
"$mainMod ALT, H, resizeactive, -20 0"
"$mainMod ALT, K, resizeactive, 0 -20"
"$mainMod ALT, J, resizeactive, 0 20"
"$mainMod SHIFT, T, split-movetoworkspace, empty"
"$mainMod, T, split-workspace, empty"
"$mainMod, TAB, split-workspace, m+1"
"$mainMod SHIFT, TAB, split-workspace, m-1"
]
++ (
# workspaces
# binds $mod + [shift +] {1..10} to [move to] workspace {1..10}
builtins.concatLists (builtins.genList
(
x:
let
ws =
let
c = (x + 1) / 10;
in
builtins.toString (x + 1 - (c * 10));
in
[
"$mainMod, ${ws}, split-workspace, ${toString (x + 1)}"
"$mod SHIFT, ${ws}, split-movetoworkspace, ${toString (x + 1)}"
2024-05-31 23:44:20 +02:00
]
2024-06-01 16:56:07 +02:00
)
10)
);
2024-05-31 23:44:20 +02:00
};
2024-06-01 16:56:07 +02:00
};
2024-05-31 22:25:50 +02:00
}