feat(desktop): setup river window manager.

This commit is contained in:
CronyAkatsuki 2025-06-06 22:22:27 +02:00
parent f7fc5c13ba
commit 3db633e6ab
5 changed files with 174 additions and 14 deletions

View file

@ -104,6 +104,11 @@
# Enable light for image control # Enable light for image control
programs.light.enable = true; programs.light.enable = true;
programs.river = {
enable = true;
extraPackages = [];
};
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.crony = { users.users.crony = {
isNormalUser = true; isNormalUser = true;

View file

@ -30,6 +30,7 @@
crony.gaming.enable = true; crony.gaming.enable = true;
crony.flatpak.enable = true; crony.flatpak.enable = true;
crony.wayland.enable = true; crony.wayland.enable = true;
crony.river.enable = true;
# DO NOT CHANGE ALSO # DO NOT CHANGE ALSO
home.stateVersion = "24.11"; # Please read the comment before changing. home.stateVersion = "24.11"; # Please read the comment before changing.

View file

@ -16,8 +16,10 @@
./xdg-user-dirs.nix ./xdg-user-dirs.nix
./qutebrowser.nix ./qutebrowser.nix
./wayland.nix ./wayland.nix
./river.nix
]; ];
crony.river.enable = lib.mkDefault false;
crony.wayland.enable = lib.mkDefault false; crony.wayland.enable = lib.mkDefault false;
crony.qutebrowser.enable = lib.mkDefault true; crony.qutebrowser.enable = lib.mkDefault true;
crony.mangohud.enable = lib.mkDefault false; crony.mangohud.enable = lib.mkDefault false;

View file

@ -0,0 +1,158 @@
{
config,
pkgs,
lib,
...
}: let
volume-notify = pkgs.writeShellScriptBin "volume-notify" ''
#!/usr/bin/env sh
volumep="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
case "$volumep" in
*0.0*) volumep="''${volumep##* 0.0}%" ;;
*0.*) volumep="''${volumep##* 0.}%" ;;
*MUTED*) volumep='MUTED' ;;
*) volumep="100%" ;;
esac
notify-send -h string:x-canonical-private-synchronous:sys-notify "🔊 Volume: ''${volumep}"
'';
toggle-sound-output = pkgs.writeShellScriptBin "toggle-sound-output" ''
#!/usr/bin/env sh
speakers="alsa_output.pci-0000_05_00.1.hdmi-stereo"
headphones="alsa_output.usb-Xtrfy_SC1_Xtrfy_SC1-00.analog-stereo"
current="$(wpctl status -n | grep Audio/Sink | grep -oE '[^ ]+$')"
if [ "''${current}" = "''${headphones}" ]; then
wpctl set-default "$(pw-cli info $speakers | head -n 1 | awk '{print $2}')"
else
wpctl set-default "$(pw-cli info $headphones | head -n 1 | awk '{print $2}')"
fi
'';
power-menu = pkgs.writeShellScriptBin "power-menu" ''
#!/usr/bin/env sh
case "$(printf "shutdown\\nreboot" | tofi --prompt "Choose your poison")" in
"shutdown") poweroff ;;
"reboot") reboot ;;
esac
'';
in {
options = {
crony.river.enable = lib.mkEnableOption "Enable and setup river window manager";
};
config = lib.mkIf config.crony.river.enable {
home.packages = with pkgs; [
playerctl
grim
];
wayland.windowManager.river = {
enable = true;
settings = {
set-repeat = "50 300";
default-layout = "rivertile";
keyboard-layout = {
"-options" = {
"'caps:escape,grp:alt_space_toggle'" = "'us,hr'";
};
};
rule-add = {
"-app-id" = {
"'bar'" = "csd";
"'float*'" = {
"-title" = {
"foo" = "float";
};
};
};
};
map = {
normal = {
"Super Return" = "spawn foot";
"Super Q" = "close";
"Super+Ctrl E" = "exit";
"J" = "focus-view next";
"K" = "focus-view previous";
"Super+Shift J" = "swap next";
"Super+Shift K" = "swap previous";
"Super+Shift Return" = "zoom";
"Super H" = "send-layout-cmd rivertile 'main-ratio -0.05'";
"Super L" = "send-layout-cmd rivertile 'main-ratio +0.05'";
"Super+Shift ." = "send-layout-cmd rivertile 'main-count +1'";
"Super+Shift ," = "send-layout-cmd rivertile 'main-count -1'";
"Super+Shift Space" = "toggle-float";
"Super F" = "toggle-fullscreen";
"Super D" = "spawn 'tofi-run | xargs riverctl dispatch exec --'";
"Super+Shift D" = "spawn 'tofi-drun | xargs riverctl dispatch exec --'";
"Super+Shift L" = "spawn 'hyprlock --immediate'";
"Super B" = "spawn qutebrowser";
"Super+Shift B" = "spawn librewolf";
"Super F1" = "spawn '${toggle-sound-output}/bin/toggle-sound-output'";
"Super E" = "spawn '${power-menu}/bin/power-menu'";
"Super F12" = "spawn 'grim ${config.xdg.userDirs.pictures}/screenshots/$(date +%s_grim.png)'";
"Super V" = "spawn 'cliphist list | tofi --horizontal false --height 380 | cliphist decode | wl-copy'";
};
};
map-pointer = {
normal = {
"Super BTN_LEFT" = "move-view";
"Super BTN_RIGHT" = "resize-view";
"Super BTN_MIDDLE" = "toggle-float";
};
};
spawn = [
"wl-paste --type text --watch cliphist store" # Stores only text data
"wl-paste --type image --watch cliphist store" # Stores only image data
"keepassxc" # Startup my password manager
"waybar" # Start waybar on start
];
};
systemd = {
enable = true;
};
xwayland.enable = true;
extraConfig = ''
for i in $(seq 1 9)
do
tags=$((1 << ($i - 1)))
# Super+[1-9] to focus tag [0-8]
riverctl map normal Super $i set-focused-tags $tags
# Super+Shift+[1-9] to tag focused view with tag [0-8]
riverctl map normal Super+Shift $i set-view-tags $tags
# Super+Control+[1-9] to toggle focus of tag [0-8]
riverctl map normal Super+Control $i toggle-focused-tags $tags
# Super+Shift+Control+[1-9] to toggle tag [0-8] of focused view
riverctl map normal Super+Shift+Control $i toggle-view-tags $tags
done
for mode in normal locked
do
riverctl map $mode None XF86AudioRaiseVolume spawn 'pctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ --limit 1 && ${volume-notify}/bin/volume-notify'
riverctl map $mode None XF86AudioLowerVolume spawn 'wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- --limit 1 && ${volume-notify}/bin/volume-notify'
riverctl map $mode None XF86AudioMute spawn 'wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && ${volume-notify}/bin/volume-notify'
riverctl map $mode None XF86AudioMedia spawn 'playerctl play-pause'
riverctl map $mode None XF86AudioPlay spawn 'playerctl play-pause'
riverctl map $mode None XF86AudioPrev spawn 'playerctl previous'
riverctl map $mode None XF86AudioNext spawn 'playerctl next'
riverctl map $mode None XF86MonBrightnessUp spawn 'light -A 10'
riverctl map $mode None XF86MonBrightnessDown spawn 'light -D 10'
done
rivertile -view-padding 6 -outer-padding 6 &
'';
};
};
}

View file

@ -137,25 +137,21 @@
padding-left: 10px; padding-left: 10px;
} }
#workspaces { #tags {
background-color: @base01; background-color: @base01;
margin: 0.25em; margin: 0.25em;
border-radius: 1em; border-radius: 1em;
} }
#workspaces button { #tags button {
padding: 0 0.5em; padding: 0 0.5em;
color: @base06;
}
#workspaces button.empty {
color: @base03; color: @base03;
} }
#workspaces button.visible { #tags button.occupied {
color: @base06; color: @base06;
} }
#workspaces button.active { #tags button.focused {
color: @base0D; color: @base0D;
} }
@ -189,8 +185,8 @@
mainBar = { mainBar = {
height = 34; height = 34;
modules-left = [ modules-left = [
"hyprland/workspaces" "river/tags"
"hyprland/window" "river/window"
]; ];
modules-center = [ modules-center = [
]; ];
@ -203,10 +199,8 @@
"clock" "clock"
"tray" "tray"
]; ];
"hyprland/workspaces" = { "river/window" = {
persistent-workspaces = { max-length = 50;
"*" = [1 2 3 4 5 6 7 8 9];
};
}; };
disk = { disk = {
path = "/"; path = "/";