Compare commits

..

6 commits

Author SHA1 Message Date
ItsDrike aa8cc54140
Add window rules 2024-06-10 15:30:37 +02:00
ItsDrike 5ac92f8d3d
Update keybinds 2024-06-10 15:24:13 +02:00
ItsDrike bb39670cd1
Use brightnessctl 2024-06-10 15:11:49 +02:00
ItsDrike 0f4d3f1e05
Add brightness script 2024-06-10 14:32:51 +02:00
ItsDrike 98f1ed0089
Add hyprland-move-window script 2024-06-10 14:23:59 +02:00
ItsDrike 14d5cf5261
Move hyprland-swap-workspace to dir 2024-06-10 14:20:24 +02:00
12 changed files with 417 additions and 150 deletions

View file

@ -1,5 +1,6 @@
_: { _: {
imports = [ imports = [
./shared.nix ./shared.nix
./desktop.nix
]; ];
} }

View file

@ -0,0 +1,18 @@
{
osConfig,
lib,
pkgs,
...
}: let
inherit (lib) mkIf;
devType = osConfig.myOptions.device.roles.type;
acceptedTypes = [ "laptop" "desktop" ];
in {
config = mkIf (builtins.elem devType acceptedTypes) {
home.packages = with pkgs; [
trash-cli
bitwarden-cli
];
};
}

View file

@ -1,174 +1,257 @@
{ {
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland = {
"$MOUSE_LMB" = "mouse:272"; settings = {
"$MOUSE_RMB" = "mouse:273"; "$MOUSE_LMB" = "mouse:272";
"$MOUSE_MMB" = "mouse:274"; "$MOUSE_RMB" = "mouse:273";
"$MOUSE_EX1" = "mouse:275"; "$MOUSE_MMB" = "mouse:274";
"$MOUSE_EX2" = "mouse:276"; "$MOUSE_EX1" = "mouse:275";
"$MOUSE_EX2" = "mouse:276";
"$XF86Favorites" = "164"; "$XF86Favorites" = "164";
bind = [ bind = [
# #
# Active window # Active window
# #
"SUPER, W, killactive," "SUPER, W, killactive,"
"SUPER, F, togglefloating," "SUPER, F, togglefloating,"
"SUPER, Space, fullscreen, 0" "SUPER, Space, fullscreen, 0"
"SUPER, Space, fullscreen, 1" # maximize "SUPER, Space, fullscreen, 1" # maximize
"SUPER_SHIFT, S, layoutmsg, togglesplit" "SUPER_SHIFT, S, layoutmsg, togglesplit"
# #
# Programs # Programs
# #
"SUPER, Return, exec, kitty" "SUPER, Return, exec, kitty"
# TODO: requires programs # TODO: requires programs
# #
# DE/WM Control programs # DE/WM Control programs
# #
# TODO: Requires programs # TODO: Requires programs
"SUPER_SHIFT, L, exec, wlogout -p layer-shell" "SUPER_SHIFT, L, exec, wlogout -p layer-shell"
"SUPER_CTRL, L, exec, loginctl lock-session"
# #
# Screenshots # Screenshots
# #
# TODO: requires script # TODO: requires script
# #
# Brightness control # Brightness control
# #
# TODO: requires script "SUPER, Right, exec, brightness 5%+"
"SUPER, Left, exec, brightness 5%-"
", XF86MonBrightnessUp, exec, brightness 5%+"
", XF86MonBrightnessDown, exec, brightness 5%-"
#
# Audio/Volume control
#
", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
", XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
# (rest in binde section)
#
# Notifications
#
# TODO: Requires notification daemon (dunst?)
# #
# Audio/Volume control # Window groups
# #
"SUPER, Down, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05-" "SUPER, G, togglegroup,"
"SUPER, Up, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05+" "ALT, tab, changegroupactive, f"
", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05-" "ALT, grave, changegroupactive, b"
", XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05+"
", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
", XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
# #
# Notifications # Special workspace (scratchpad)
# #
# TODO: Requires notification daemon (dunst?) "ALT, grave, movetoworkspace, special"
"SUPER, grave, togglespecialworkspace,"
#
# Move window focus
#
"SUPER, h, movefocus, l"
"SUPER, l, movefocus, r"
"SUPER, k, movefocus, u"
"SUPER, j, movefocus, d"
# #
# Window groups # Move active window in direction
# #
"SUPER, G, togglegroup," "SUPER_ALT, h, movewindow, l"
"ALT, tab, changegroupactive, f" "SUPER_ALT, l, movewindow, r"
"ALT, grave, changegroupactive, b" "SUPER_ALT, k, movewindow, u"
"SUPER_ALT, j, movewindow, d"
# #
# Special workspace (scratchpad) # Move floating windows
# #
"ALT, grave, movetoworkspace, special" "SUPER_ALT, left, exec, hyprland-move-window 100 l"
"SUPER, grave, togglespecialworkspace," "SUPER_ALT, right, exec, hyprland-move-window 100 r"
"SUPER_ALT, up, exec, hyprland-move-window 100 u"
"SUPER_ALT, down, exec, hyprland-move-window 100 d"
# #
# Move window focus # Override split direction for next window (manual tiling)
# #
"SUPER, h, movefocus, l" "SUPER_ALT, left, layoutmsg, preselect l"
"SUPER, l, movefocus, r" "SUPER_ALT, right, layoutmsg, preselect r"
"SUPER, k, movefocus, u" "SUPER_ALT, up, layoutmsg, preselect u"
"SUPER, j, movefocus, d" "SUPER_ALT, down, layoutmsg, preselect d"
# #
# Move active window in direction # Switch workspace (swapping to current monitor)
# #
"SUPER_ALT, h, movewindow, l" "SUPER, 1, exec, hyprland-swap-workspace 1"
"SUPER_ALT, l, movewindow, r" "SUPER, 2, exec, hyprland-swap-workspace 2"
"SUPER_ALT, k, movewindow, u" "SUPER, 3, exec, hyprland-swap-workspace 3"
"SUPER_ALT, j, movewindow, d" "SUPER, 4, exec, hyprland-swap-workspace 4"
"SUPER, 5, exec, hyprland-swap-workspace 5"
"SUPER, 6, exec, hyprland-swap-workspace 6"
"SUPER, 7, exec, hyprland-swap-workspace 7"
"SUPER, 8, exec, hyprland-swap-workspace 8"
"SUPER, 9, exec, hyprland-swap-workspace 9"
# #
# Move floating windows # Move window to workspace
# #
# TODO: requires script (move-window.sh) "SUPER_SHIFT, 1, movetoworkspacesilent, 1"
"SUPER_SHIFT, 2, movetoworkspacesilent, 2"
"SUPER_SHIFT, 3, movetoworkspacesilent, 3"
"SUPER_SHIFT, 4, movetoworkspacesilent, 4"
"SUPER_SHIFT, 5, movetoworkspacesilent, 5"
"SUPER_SHIFT, 6, movetoworkspacesilent, 6"
"SUPER_SHIFT, 7, movetoworkspacesilent, 7"
"SUPER_SHIFT, 8, movetoworkspacesilent, 8"
"SUPER_SHIFT, 9, movetoworkspacesilent, 9"
# #
# Override split direction for next window (manual tiling) # Move window to workspace + focus it
# #
"SUPER_ALT, left, layoutmsg, preselect l" "ALT, 1, movetoworkspace, 1"
"SUPER_ALT, right, layoutmsg, preselect r" "ALT, 2, movetoworkspace, 2"
"SUPER_ALT, up, layoutmsg, preselect u" "ALT, 3, movetoworkspace, 3"
"SUPER_ALT, down, layoutmsg, preselect d" "ALT, 4, movetoworkspace, 4"
"ALT, 5, movetoworkspace, 5"
"ALT, 6, movetoworkspace, 6"
"ALT, 7, movetoworkspace, 7"
"ALT, 8, movetoworkspace, 8"
"ALT, 9, movetoworkspace, 9"
# #
# Switch workspace (swapping to current monitor) # Cycle workspaces (relative movement)
# #
"SUPER, 1, exec, hyprland-swap-workspace 1" "SUPER, mouse_down, workspace, +1"
"SUPER, 2, exec, hyprland-swap-workspace 2" "SUPER, mouse_up, workspace, -1"
"SUPER, 3, exec, hyprland-swap-workspace 3" "SUPER, bracketright, workspace, +1"
"SUPER, 4, exec, hyprland-swap-workspace 4" "SUPER, bracketleft, workspace, -1"
"SUPER, 5, exec, hyprland-swap-workspace 5"
"SUPER, 6, exec, hyprland-swap-workspace 6"
"SUPER, 7, exec, hyprland-swap-workspace 7"
"SUPER, 8, exec, hyprland-swap-workspace 8"
"SUPER, 9, exec, hyprland-swap-workspace 9"
# #
# Move window to workspace # Cycle monitors (relative movement)
# #
"SUPER_SHIFT, 1, movetoworkspacesilent, 1" "SUPER_SHIFT, mouse_down, focusmonitor, +1"
"SUPER_SHIFT, 2, movetoworkspacesilent, 2" "SUPER_SHIFT, mouse_up, focusmonitor, -1"
"SUPER_SHIFT, 3, movetoworkspacesilent, 3" "SUPER_SHIFT, bracketright, focusmonitor, +1"
"SUPER_SHIFT, 4, movetoworkspacesilent, 4" "SUPER_SHIFT, bracketleft, focusmonitor, -1"
"SUPER_SHIFT, 5, movetoworkspacesilent, 5" ];
"SUPER_SHIFT, 6, movetoworkspacesilent, 6"
"SUPER_SHIFT, 7, movetoworkspacesilent, 7"
"SUPER_SHIFT, 8, movetoworkspacesilent, 8"
"SUPER_SHIFT, 9, movetoworkspacesilent, 9"
# # Mouse bindings
# Move window to workspace + focus it bindm = [
# #
"ALT, 1, movetoworkspace, 1" # Mouse window resizing
"ALT, 2, movetoworkspace, 2" #
"ALT, 3, movetoworkspace, 3" "SUPER, $MOUSE_LMB, movewindow"
"ALT, 4, movetoworkspace, 4" "SUPER, $MOUSE_RMB, resizewindow"
"ALT, 5, movetoworkspace, 5" ];
"ALT, 6, movetoworkspace, 6"
"ALT, 7, movetoworkspace, 7"
"ALT, 8, movetoworkspace, 8"
"ALT, 9, movetoworkspace, 9"
# # Repeat bindings
# Cycle workspaces (relative movement) binde = [
# #
"SUPER, mouse_down, workspace, +1" # Audio/Volume control
"SUPER, mouse_up, workspace, -1" #
"SUPER, bracketright, workspace, +1" "SUPER, Down, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05-"
"SUPER, bracketleft, workspace, -1" "SUPER, Up, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05+"
", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05-"
", XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05+"
# (rest in bind section)
# #
# Cycle monitors (relative movement) # Window resizing
# #
"SUPER_SHIFT, mouse_down, focusmonitor, +1" "ALT, right, resizeactive, 10 0"
"SUPER_SHIFT, mouse_up, focusmonitor, -1" "ALT, left, resizeactive, -10 0"
"SUPER_SHIFT, bracketright, focusmonitor, +1" "ALT, up, resizeactive, 0 -10"
"SUPER_SHIFT, bracketleft, focusmonitor, -1" "ALT, down, resizeactive, 0 10 "
"ALT, H, resizeactive, -10 0"
# "ALT, K, resizeactive, 0 -10"
# Window resizing "ALT, J, resizeactive, 0 10"
# "ALT, L, resizeactive, 10 0"
# TODO: Submaps + binde ];
};
# Used for submaps, which don't support `settings`
extraConfig = ''
# #
# Isolation group # Isolation group
# #
# TODO: Submaps
];
bindm = [ # Useful to prevent keybind capturing (for games, etc)
# Mouse window resizing # SUPER + Fn + F12 (Favorites)
"SUPER, $MOUSE_LMB, movewindow" bind = SUPER, XF86Favorites, exec, hyprctl dispatch submap isolate && notify-send "Keybind isolation" "Keybind isolation on"
"SUPER, $MOUSE_RMB, resizewindow" submap = isolate
]; bind = SUPER, XF86Favorites, exec, hyprctl dispatch submap reset && notify-send "Keybind isolation" "Keybind isolation off"
submap = reset
#
# Precise keyboard window resizing
#
bind = SUPER, slash, submap, resize
submap = resize
binde = , right, resizeactive, 10 0
binde = , left, resizeactive, -10 0
binde = , up, resizeactive, 0 -10
binde = , down, resizeactive, 0 10
binde = SUPER, right, resizeactive, 30 0
binde = SUPER, left, resizeactive, -30 0
binde = SUPER, up, resizeactive, 0 -30
binde = SUPER, down, resizeactive, 0 30
binde = SHIFT, right, resizeactive, 1 0
binde = SHIFT, left, resizeactive, -1 0
binde = SHIFT, up, resizeactive, 0 -1
binde = SHIFT, down, resizeactive, 0 1
binde = , H, resizeactive, -10 0
binde = , K, resizeactive, 0 -10
binde = , J, resizeactive, 0 10
binde = , L, resizeactive, 10 0
binde = , right, resizeactive, 10 0
binde = , left, resizeactive, -10 0
binde = , up, resizeactive, 0 -10
binde = , down, resizeactive, 0 10
binde = SUPER, H, resizeactive, -30 0
binde = SUPER, K, resizeactive, 0 -30
binde = SUPER, J, resizeactive, 0 30
binde = SUPER, L, resizeactive, 30 0
binde = SHIFT, H, resizeactive, -1 0
binde = SHIFT, K, resizeactive, 0 -1
binde = SHIFT, J, resizeactive, 0 1
binde = SHIFT, L, resizeactive, 1 0
bind = , escape, submap, reset
bind = , return, submap, reset
bind = SUPER, slash, submap, reset
submap = reset
'';
}; };
} }

View file

@ -1,7 +1,101 @@
{ {
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland.settings = {
windowrulev2 = [ windowrulev2 = [
# TODO: Add these #
# Assigned workspaces
#
"workspace, 2, class:^(firefox)$"
"workspace 4, class:^(discord)$"
"workspace 4, class:^(vesktop)$"
"workspace 4, class:^(WebCord)$"
"workspace 5, class:^(Spotify)$"
"workspace 6, class:^(Stremio)$"
"workspace 6, class:^(com.stremio.stremio)$"
#
# Idle inhibition
#
"idleinhibit focus, class:^(Stremio)$"
"idleinhibit focus, class:^(com.stremio.stremio)$"
"idleinhibit focus, class:^(mpv)$"
"idleinhibit focus, class:^(firefox)$,title:^(.+ - YouTube Mozilla Firefox)$"
"idleinhibit focus, class:^(firefox)$,title:^(Picture-in-Picture)$"
#
# Correct size / Auto tile
#
"size 800 550, class:^(qalculate-gtk)$"
"tile, class:^(Spotify)$"
#
# Auto float
#
"float, class:^(Lxappearance)$"
"float, class:^(Rofi)$"
"float, class:^(feh)$"
"float, class:^(pavucontrol-qt)$"
"float, class:^(pavucontrol)$"
"float, class:^(file-roller)$"
"float, class:^(qalculate-gtk)$"
"float, class:^(com.github.wwmm.easyeffects)"
"float, class:^(opensnitch_ui)$"
"float, class:^(Brave-browser)$,title:^(_crx_.+)$"
"float, class:^(hyprland-share-picker)$"
"float,class:^(floating)$"
"center, class:^(hyprland-share-picker)$"
"animation slide, class:^(hyprland-share-picker)$"
# Float firefox windows (like bookmark menus, or some extension windows)
"float, class:^(firefox)$,title:^(Revert Bookmarks)$"
"float, class:^(firefox)$,title:^(Library)$"
"float, class:^(firefox)$,title:^(Extension: \(uBlock Origin\))"
"float, class:^(firefox)$,title:^(Firefox Sharing Indicator)$"
"float, class:^(firefox)$,title:^(Opening .+)$"
"float, class:^(firefox)$,title:^$"
# Float some pcmanfm windows
"float, class:^(pcmanfm-qt)$,title:^(Mount)$"
"float, class:^(pcmanfm-qt)$,title:^(Preferences)$"
"float, class:^(pcmanfm-qt)$,title:^(Move files)$"
"float, class:^(pcmanfm-qt)$,title:^(Search Files)$"
"float, class:^(pcmanfm-qt)$,title:^(Copy Files)$"
"float, class:^(pcmanfm-qt)$,title:^(Confirm to replace files)$"
# Float some windows from other apps
"float, class:^(Spotify)$,title:^(Ozone X11)$"
"float, class:^(python3)$,title:^(Tor Browser Launcher Settings)$"
"float, class:^(python3)$,title:^(Tor Browser)$"
# General float rules
"float, class:^(file_progress)$"
"float, class:^(confirm)$"
"float, class:^(dialog)$"
"float, class:^(download)$"
"float, class:^(notification)$"
"float, class:^(error)$"
"float, class:^(splash)$"
"float, class:^(confirmreset)$"
#
# Fixes
#
# Jetbrains
"windowdance, class:^(jetbrains-.*)$,floating:1"
"center, class:^(jetbrains-.*)$,title:^(splash)$,floating:1"
"nofocus, class:^(jetbrains-.*)$,title:^(splash)$,floating:1"
"noborder, class:^(jetbrains-.*)$,title:^(splash)$,floating:1"
"center, class:^(jetbrains-.*)$,title:^( )$,floating:1"
"stayfocused, class:^(jetbrains-.*)$,title:^( )$,floating:1"
"noborder, class:^(jetbrains-.*)$,title:^( )$,floating:1"
"nofocus, class:^(jetbrains-.*)$,title:^(win.*)$,floating:1"
"noinitialfocus, class:^(jetbrains-.*)$,title:^(win.*)$"
];
layerrule = [
# Don't add borders to grim selections when taking screenshots
"noanim, ^(selection)$"
]; ];
}; };
} }

View file

@ -6,7 +6,7 @@
}: let }: let
inherit (lib) mkIf; inherit (lib) mkIf;
inherit (import ./packages {inherit pkgs;}) hyprland-swap-workspace; hyprPkgs = (import ./packages {inherit pkgs;});
cfg = osConfig.myOptions.home-manager.wms.hyprland; cfg = osConfig.myOptions.home-manager.wms.hyprland;
in { in {
@ -15,8 +15,11 @@ in {
]; ];
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = with pkgs; [ home.packages = [
hyprland-swap-workspace hyprPkgs.hyprland-swap-workspace
hyprPkgs.hyprland-move-window
pkgs.brightnessctl
hyprPkgs.brightness
]; ];
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {

View file

@ -0,0 +1,22 @@
#!/bin/sh
# This is mainly a wrapper, acting as just: `brightnessctl s $1`
# However, in addition, this will also produce a notification with
# the brightness level shown as a progress bar.
# Send brightness level desktop notification, showing the given brightness level
# as progress bar, along with given message.
# $1 - brightness level (number 0-100)
send_brightness_notify() {
percent_brightness="$1"
notify-send \
--app-name="brightness" \
--urgency="normal" \
-h int:value:$percent_brightness \
-h string:synchronous:brightness \
"brightness" "Level: $percent_brightness"
}
out="$(brightnessctl s "$1")"
cur_percent="$(echo "$out" | grep "Current" | grep -oP '\(\d+%' | tr -d '()%')"
send_brightness_notify "$cur_percent"

View file

@ -0,0 +1,4 @@
{pkgs, ...}:
pkgs.writeShellScriptBin "brightness" ''
${builtins.readFile ./brightness.sh}
''

View file

@ -3,7 +3,9 @@
... ...
}: let }: let
packages = { packages = {
hyprland-swap-workspace = pkgs.callPackage ./hyprland-swap-workspace.nix {}; hyprland-swap-workspace = pkgs.callPackage ./hyprland-swap-workspace {};
hyprland-move-window = pkgs.callPackage ./hyprland-move-window {};
brightness = pkgs.callPackage ./brightness {};
}; };
in in
packages packages

View file

@ -0,0 +1,5 @@
{pkgs, ...}:
pkgs.writeShellScriptBin "hyprland-move-window" ''
${builtins.readFile ./hyprland-move-window.sh}
''

View file

@ -0,0 +1,35 @@
#!/bin/sh
RESIZE_SIZE=${1:?Missing resize size}
RESIZE_PARAMS_X=0
RESIZE_PARAMS_Y=0
DIRECTION=${2:?Missing move direction}
case $DIRECTION in
l)
RESIZE_PARAMS_X=-$RESIZE_SIZE
;;
r)
RESIZE_PARAMS_X=$RESIZE_SIZE
;;
u)
RESIZE_PARAMS_Y=-$RESIZE_SIZE
;;
d)
RESIZE_PARAMS_Y=$RESIZE_SIZE
;;
*)
echo "kbye"
return 1
;;
esac
ACTIVE_WINDOW=$(hyprctl activewindow -j)
IS_FLOATING=$(echo "$ACTIVE_WINDOW" | jq .floating)
if [ "$IS_FLOATING" = "true" ]; then
hyprctl dispatch moveactive "$RESIZE_PARAMS_X" "$RESIZE_PARAMS_Y"
else
hyprctl dispatch movewindow "$DIRECTION"
fi