dotfiles/home/hyprland/default.nix

254 lines
9.2 KiB
Nix
Raw Normal View History

2024-06-03 16:02:50 +02:00
{ inputs, pkgs, ... }:
2024-06-01 16:56:07 +02:00
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";
2024-06-03 01:00:53 +02:00
firefox = "${pkgs.firefox}/bin/firefox";
2024-06-03 02:00:07 +02:00
nautilus = "${pkgs.gnome.nautilus}/bin/nautilus";
2024-06-03 16:01:31 +02:00
gnome-calendar = "${pkgs.gnome.gnome-calendar}/bin/gnome-calendar";
2024-06-01 18:10:39 +02:00
waybar = "${inputs.waybar.packages.${pkgs.system}.waybar}/bin/waybar";
2024-06-01 16:56:07 +02:00
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";
2024-06-03 01:00:53 +02:00
rofi-ykman = pkgs.writeShellScriptBin "rofi-ykman" ''
2024-06-03 16:02:50 +02:00
accounts=$(${pkgs.yubikey-manager}/bin/ykman oath accounts list)
2024-06-03 01:00:53 +02:00
prompt="YubiKey OATH"
2024-06-03 16:02:50 +02:00
account=$(echo "''${accounts/, TOTP/\n}" | awk '{ print $0 "\0icon\x1fyubioath"; }' | ${rofi} -dmenu -i -p "$prompt" ''${shortcuts[@]})
code=$(${pkgs.yubikey-manager}/bin/ykman oath accounts code "$account")
IFS=', ' read -r -a code <<< "$code"
2024-06-03 01:00:53 +02:00
echo -n "''${code[-1]}" | ${pkgs.wl-clipboard}/bin/wl-copy;
'';
2024-06-01 16:56:07 +02:00
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
'';
2024-06-03 16:02:50 +02:00
in {
2024-06-01 16:56:07 +02:00
services.kdeconnect = {
enable = true;
package = pkgs.kdePackages.kdeconnect-kde;
indicator = true;
};
2024-05-31 23:44:20 +02:00
2024-06-03 16:02:50 +02:00
home.packages = with pkgs; [ wl-clipboard ];
2024-06-03 01:00:53 +02:00
2024-06-04 16:16:30 +02:00
services.cliphist = { enable = true; };
2024-06-03 17:18:13 +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;
2024-06-03 16:02:50 +02:00
preload = [ "${./files/wallpaper.png}" ];
2024-06-01 17:19:39 +02:00
wallpaper = [
2024-06-02 14:50:05 +02:00
# Fill in by host-specific config!
# "Display,${./files/wallpaper.png}"
2024-06-01 17:19:39 +02:00
];
2024-06-01 17:10:24 +02:00
};
};
2024-06-01 17:49:46 +02:00
services.dunst = {
enable = true;
settings = {
2024-06-02 14:02:14 +02:00
global = {
frame_color = "#00000000";
separator_color = "frame";
background = "#24273A";
foreground = "#ffffff";
font = "Ubuntu 10.5";
width = "(0, 600)";
padding = 15;
origin = "top-right";
offset = "10x10";
horizontal_padding = 20;
gap_size = 15;
};
2024-06-01 17:49:46 +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"
2024-06-01 18:10:39 +02:00
"${waybar}"
2024-06-01 16:56:07 +02:00
"${wl-paste} --type text --watch cliphist store"
"${wl-paste} --type image --watch cliphist store"
];
env = [
"WLR_NO_HARDWARE_CURSORS,1"
"TERMINAL,${alacritty}"
"WLR_RENDERER_ALLOW_SOFTWARE,1"
];
2024-06-03 16:02:50 +02:00
debug = { disable_logs = false; };
2024-06-01 16:56:07 +02:00
windowrulev2 = [
"float, title:^(rofi)(.*)$"
"center, title:^(rofi)(.*)$"
"noborder, title:^(rofi)(.*)$"
"stayfocused, title:^()$,class:^(steam)$"
"minsize 1 1, title:^()$,class:^(steam)$"
"stayfocused, title:^()$,class:^(steam)$"
];
2024-06-03 16:02:50 +02:00
windowrule = [ "noanim,waybar" ];
2024-06-01 16:56:07 +02:00
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;
2024-06-04 22:27:38 +02:00
kb_options = "compose:rctrl";
2024-06-01 16:56:07 +02:00
numlock_by_default = true;
};
2024-06-03 16:02:50 +02:00
binds = { scroll_event_delay = 1; };
xwayland = { force_zero_scaling = true; };
misc = { disable_hyprland_logo = 1; };
2024-06-01 16:56:07 +02:00
decoration = {
rounding = 1;
2024-06-03 16:02:50 +02:00
blur = { enabled = false; };
2024-06-01 16:56:07 +02:00
};
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,"
2024-06-03 02:00:07 +02:00
"$mainMod, A, exec, ${nautilus}"
2024-06-03 16:01:31 +02:00
"$mainMod, S, exec, ${gnome-calendar}"
2024-06-03 01:00:53 +02:00
"$mainMod, B, exec, MOZ_ENABLE_WAYLAND=1 ${firefox}"
2024-06-01 16:56:07 +02:00
"$mainMod, M, fullscreen, 1"
"$mainMod, F11, fullscreen"
"$mainMod, F, togglefloating,"
"$mainMod, SPACE, togglesplit, # dwindle"
"CONTROL_L ALT_L, L, exec, ${swaylock}"
2024-06-03 16:02:50 +02:00
''
2024-06-04 16:16:30 +02:00
$mainMod, C, exec, cliphist list | awk '{print $0, "\0icon\x1fcom.github.davidmhewitt.clipped"; }' | ${rofi} -dmenu -display-columns 2 | cliphist decode | wl-copy''
2024-06-03 01:00:53 +02:00
"$mainMod, Y, exec, ${rofi-ykman}/bin/rofi-ykman"
2024-06-01 17:57:53 +02:00
"$mainMod, N, exec, ${./files/rofi-ssh.sh}"
2024-05-31 23:44:20 +02:00
2024-06-03 16:02:50 +02:00
"$mainMod, Escape, exec, ${rofi} -show power-menu -modi power-menu:${
./files/rofi-power-menu.sh
}"
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"
2024-06-03 16:02:50 +02:00
'', Print, exec, grim -g "$(slurp -d)" - | wl-copy''
2024-05-31 23:44:20 +02:00
2024-06-01 17:55:08 +02:00
"$mainMod, H, exec, ${./files/vim-hypr-nav.sh} l"
"$mainMod, L, exec, ${./files/vim-hypr-nav.sh} r"
"$mainMod, K, exec, ${./files/vim-hypr-nav.sh} u"
"$mainMod, J, exec, ${./files/vim-hypr-nav.sh} d"
2024-06-01 16:56:07 +02:00
"$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"
2024-06-03 16:02:50 +02:00
] ++ (
2024-06-01 16:56:07 +02:00
# workspaces
# binds $mod + [shift +] {1..10} to [move to] workspace {1..10}
2024-06-03 16:02:50 +02:00
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)}"
"$mainMod SHIFT, ${ws}, split-movetoworkspace, ${toString (x + 1)}"
]) 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
}