Skip to content

Commit

Permalink
feat: refactor hyprland config
Browse files Browse the repository at this point in the history
  • Loading branch information
sioodmy committed Jan 16, 2024
1 parent 5c94064 commit 59ca448
Show file tree
Hide file tree
Showing 9 changed files with 275 additions and 312 deletions.
5 changes: 4 additions & 1 deletion home/misc/media.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
UP = "add volume +2";
DOWN = "add volume -2";
};
# https://wiki.archlinux.org/title/mpv#Hardware_video_acceleration
config = {
hwdec = "auto";
hwdec = "auto-safe";
gpu-context = "wayland";
profile = "gpu-hq";
osc = false;
border = false;
};
Expand Down
9 changes: 6 additions & 3 deletions home/rice/dunst.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{pkgs, theme, ...}:
let
{
pkgs,
theme,
...
}: let
inherit (theme) x;
in{
in {
services.dunst = {
enable = true;
package = pkgs.dunst.overrideAttrs (_: {
Expand Down
86 changes: 86 additions & 0 deletions home/rice/hyprland/binds.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
config,
lib,
...
}: let
mod = "SUPER";
modshift = "${mod}SHIFT";

# binds $mod + [shift +] {1..10} to [move to] workspace {1..10} (stolen from fufie)
workspaces = builtins.concatLists (builtins.genList (
x: let
ws = let
c = (x + 1) / 10;
in
builtins.toString (x + 1 - (c * 10));
in [
"${mod}, ${ws}, workspace, ${toString (x + 1)}"
"${mod} SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}"
]
)
10);
in {
wayland.windowManager.hyprland.settings = {
bind =
[
''${mod},RETURN,exec,run-as-service foot${lib.optionalString config.programs.foot.server.enable "client"}''

"${mod},SPACE,exec,run-as-service $(tofi-drun)"
"${mod},MINUS,killactive"
"${mod},P,pseudo"

"${mod},H,movefocus,l"
"${mod},L,movefocus,r"
"${mod},K,movefocus,u"
"${mod},J,movefocus,d"

",XF86Bluetooth, exec, bcn"
"${mod},M,exec,hyprctl keyword $kw $(($(hyprctl getoption $kw -j | jaq -r '.int') ^ 1))" # toggle no_gaps_when_only
"${mod},T,togglegroup," # group focused window
"${modshift},G,changegroupactive," # switch within the active group
"${mod},V,togglefloating," # toggle floating for the focused window
"${mod},F,fullscreen," # fullscreen focused window

# workspace controls
"${modshift},right,movetoworkspace,+1" # move focused window to the next ws
"${modshift},left,movetoworkspace,-1" # move focused window to the previous ws
"${mod},mouse_down,workspace,e+1" # move to the next ws
"${mod},mouse_up,workspace,e-1" # move to the previous ws

"${mod},Print,exec, pauseshot"
",Print,exec, grim - | wl-copy"
"${modshift},O,exec,wl-ocr"

"${mod},Period,exec, tofi-emoji"

"${modshift},L,exec,swaylock --grace 0" # lock screen
]
++ workspaces;

bindm = [
"${mod},mouse:272,movewindow"
"${mod},mouse:273,resizewindow"
];

binde = [
# volume controls
",XF86AudioRaiseVolume, exec, pamixer -i 5"
",XF86AudioLowerVolume, exec, pamixer -d 5"
",XF86AudioMute, exec, pamixer -t"
",XF86AudioMicMute, exec, micmute"

# brightness controls
",XF86MonBrightnessUp, exec, brightnessctl set +10%"
",XF86MonBrightnessDown, exec, brightnessctl set 10%-"
"SUPERALT, L, resizeactive, 80 0"
"SUPERALT, H, resizeactive, -80 0"
];
# binds that are locked, a.k.a will activate even while an input inhibitor is active
bindl = [
# media controls
",XF86AudioPlay,exec,playerctl play-pause"
",XF86AudioPrev,exec,playerctl previous"
",XF86AudioNext,exec,playerctl next"
];
};
}
188 changes: 5 additions & 183 deletions home/rice/hyprland/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@
}: let
pointer = config.home.pointerCursor;
in {
# mostly borrwed from https://github.com/fufexan/dotfiles/blob/main/home/wayland/hyprland/config.nix (and raf)
# thanks fufie <3
wayland.windowManager.hyprland = {
settings = {
# define the mod key
"$MOD" = "SUPER";
"$scratchpad" = "title:^.*scratchpad.*$";
"$spotify" = "title:^.*scratchpad-spotify.*$";
"$pavucontrol" = "class:^(pavucontrol)$";

exec-once = [
"dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
# set cursor for HL itself
Expand All @@ -25,9 +17,6 @@ in {

# foot terminal server
"${lib.optionalString config.programs.foot.server.enable ''run-as-service 'foot --server''}"

# dirty fix for spotifyd
"systemctl --user restart spotifyd.service"
];

gestures = {
Expand All @@ -43,11 +32,7 @@ in {
# keyboard layout
kb_layout = "pl";
kb_options = "caps:escape";
# self explanatory, I hope?
follow_mouse = 1;
# do not imitate natural scroll

# sensitivity of the mouse cursor
sensitivity = 0.0;
touchpad = {
clickfinger_behavior = true;
Expand All @@ -62,7 +47,7 @@ in {
gaps_out = 11;

# border thiccness
border_size = 2;
border_size = 3;

# active border color
"col.active_border" = "rgb(89b4fa) rgb(cba6f7) 270deg";
Expand Down Expand Up @@ -141,65 +126,6 @@ in {

"$kw" = "dwindle:no_gaps_when_only";

bind = [
''$MOD,RETURN,exec,run-as-service foot${lib.optionalString config.programs.foot.server.enable "client"}''

"$MOD,SPACE,exec,run-as-service $(tofi-drun)"
"$MOD,C,killactive"
"$MOD,P,pseudo"

"$MOD,H,movefocus,l"
"$MOD,L,movefocus,r"
"$MOD,K,movefocus,u"
"$MOD,J,movefocus,d"

",XF86Bluetooth, exec, bcn"
"$MOD,M,exec,hyprctl keyword $kw $(($(hyprctl getoption $kw -j | jaq -r '.int') ^ 1))" # toggle no_gaps_when_only
"$MOD,T,togglegroup," # group focused window
"$MODSHIFT,G,changegroupactive," # switch within the active group
"$MOD,V,togglefloating," # toggle floating for the focused window
"$MOD,F,fullscreen," # fullscreen focused window

# workspace controls
"$MODSHIFT,right,movetoworkspace,+1" # move focused window to the next ws
"$MODSHIFT,left,movetoworkspace,-1" # move focused window to the previous ws
"$MOD,mouse_down,workspace,e+1" # move to the next ws
"$MOD,mouse_up,workspace,e-1" # move to the previous ws

"$MOD,Print,exec, pauseshot"
",Print,exec, grim - | wl-copy"
"$MODSHIFT,O,exec,wl-ocr"

"$MOD,Period,exec, tofi-emoji"

"$MODSHIFT,L,exec,swaylock --grace 0" # lock screen
];

bindm = [
"$MOD,mouse:272,movewindow"
"$MOD,mouse:273,resizewindow"
];

binde = [
# volume controls
",XF86AudioRaiseVolume, exec, pamixer -i 5"
",XF86AudioLowerVolume, exec, pamixer -d 5"
",XF86AudioMute, exec, pamixer -t"
",XF86AudioMicMute, exec, micmute"

# brightness controls
",XF86MonBrightnessUp, exec, brightnessctl set +10%"
",XF86MonBrightnessDown, exec, brightnessctl set 10%-"
"SUPERALT, L, resizeactive, 80 0"
"SUPERALT, H, resizeactive, -80 0"
];
# binds that are locked, a.k.a will activate even while an input inhibitor is active
bindl = [
# media controls
",XF86AudioPlay,exec,playerctl play-pause"
",XF86AudioPrev,exec,playerctl previous"
",XF86AudioNext,exec,playerctl next"
];
workspace = [
"1, monitor:eDP-1"
"2, monitor:eDP-1"
Expand All @@ -211,115 +137,11 @@ in {
"8, monitor:DP-2"
"9, monitor:DP-2"
];
layerrule = [
"blur, ^(gtk-layer-shell)$"
"blur, ^(launcher)$"
"ignorezero, ^(gtk-layer-shell)$"
"ignorezero, ^(launcher)$"
"blur, notifications"
"ignorezero, notifications"
"blur, bar"
"ignorezero, bar"
"ignorezero, ^(gtk-layer-shell|anyrun)$"
"blur, ^(gtk-layer-shell|anyrun)$"
"noanim, launcher"
"noanim, bar"
];
windowrulev2 = [
# only allow shadows for floating windows
"noshadow, floating:0"
"tile, title:Spotify"
"fullscreen,class:wlogout"
"fullscreen,title:wlogout"

# scratchpad
"float,$scratchpad"
"size 80% 85%,$scratchpad"
"workspace special silent,$scratchpad"
"center,$scratchpad"

"bordercolor rgb(a6e3a1),$spotify"
"bordersize 4,$spotify"

# telegram media viewer
"float, title:^(Media viewer)$"

"idleinhibit focus, class:^(mpv)$"
"idleinhibit focus,class:foot"

"idleinhibit fullscreen, class:^(firefox)$"
"float, title:^(Picture-in-Picture)$"
"pin, title:^(Picture-in-Picture)$"

"float,class:udiskie"

"opacity 0.85 0.85,class:^(firefox)$"
"opacity 0.8 0.8,class:^(org.keepassxc.KeePassXC)$"

# pavucontrol
"float,$pavucontrol"
"size 86% 40%,$pavucontrol"
"move 50% 6%,$pavucontrol"
"workspace special silent,$pavucontrol"
"opacity 0.80,$pavucontrol"

"opacity 0.80,title:^(Spotify)$"

"opacity 0.9,class:^(org.keepassxc.KeePassXC)$"

"float, class:^(imv)$"

# throw sharing indicators away
"workspace special silent, title:^(Firefox — Sharing Indicator)$"
"workspace special silent, title:^(.*is sharing (your screen|a window)\.)$"

"workspace 4, title:^(.*(Disc|WebC)ord.*)$"
"tile, class:^(Spotify)$"
"workspace 3, title:^(Spotify)$"
"workspace 2, class:^(firefox)$"

"workspace 10 silent, class:^(Nextcloud)$"
monitor = [
",highrr,auto,1"
"eDP-1,1920x1080,0x0,1"
"DP-2,1920x1080@144,0x-1080,1"
];
};
extraConfig = ''
monitor=,highrr,auto,1
monitor=eDP-1,1920x1080,0x0,1
monitor=DP-2,1920x1080@144,0x-1080,1
# a submap for resizing windows
bind = $MOD, S, submap, resize # enter resize window to resize the active window
submap=resize
binde=,right,resizeactive,10 0
binde=,left,resizeactive,-10 0
binde=,up,resizeactive,0 -10
binde=,down,resizeactive,0 10
bind=,escape,submap,reset
submap=reset
# workspace binds
# binds * (asterisk) to special workspace
bind = $MOD, KP_Multiply, togglespecialworkspace
bind = $MODSHIFT, KP_Multiply, movetoworkspace, special
# and mod + [shift +] {1..10} to [move to] ws {1..10}
${
builtins.concatStringsSep
"\n"
(builtins.genList (
x: let
ws = let
c = (x + 1) / 10;
in
builtins.toString (x + 1 - (c * 10));
in ''
bind = $MOD, ${ws}, workspace, ${toString (x + 1)}
bind = $MOD SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}
''
)
10)
}
'';
};
}
19 changes: 8 additions & 11 deletions home/rice/hyprland/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ with lib; let
Install.WantedBy = ["graphical-session.target"];
};
in {
imports = [./config.nix];
imports = [./config.nix ./binds.nix ./rules.nix];
home.packages = with pkgs;
with inputs.hyprcontrib.packages.${pkgs.system}; [
libnotify
Expand Down Expand Up @@ -60,12 +60,16 @@ in {
wayland.windowManager.hyprland = {
enable = true;
package = inputs.hyprland.packages.${pkgs.system}.default;
systemd.enable = true;
systemd = {
variables = ["--all"];
extraCommands = [
"systemctl --user stop graphical-session.target"
"systemctl --user start hyprland-session.target"
];
};
};

services = {
# TODO
crabpulsar.enable = false;
wlsunset = {
# TODO: fix opaque red screen issue
enable = true;
Expand Down Expand Up @@ -95,12 +99,5 @@ in {
Restart = "always";
};
};
cliphist = mkService {
Unit.Description = "Clipboard history";
Service = {
ExecStart = "${pkgs.wl-clipboard}/bin/wl-paste --watch ${lib.getBin pkgs.cliphist}/cliphist store";
Restart = "always";
};
};
};
}
Loading

0 comments on commit 59ca448

Please sign in to comment.