From 781d06f3de807449c8e37dc9bcca0c76bc7e290f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Tue, 20 Aug 2024 13:58:45 +0200 Subject: [PATCH] feat: switch back to river --- hosts/nixos-laptop/default.nix | 6 +- modules/programs/hyprland/default.nix | 15 +- modules/programs/river/default.nix | 81 +++--- modules/programs/river/style.css | 339 ++++++++++++++++++++++++++ 4 files changed, 384 insertions(+), 57 deletions(-) create mode 100644 modules/programs/river/style.css diff --git a/hosts/nixos-laptop/default.nix b/hosts/nixos-laptop/default.nix index a8c61f6..982415f 100644 --- a/hosts/nixos-laptop/default.nix +++ b/hosts/nixos-laptop/default.nix @@ -20,10 +20,8 @@ webis.enable = true; impermanence.enable = true; }; - programs.hyprland = { - enable = true; - monitors.DP-3.scale = "auto"; - }; + programs.river.enable = true; + programs.hyprland.enable = false; programs.exercism.enable = true; }; diff --git a/modules/programs/hyprland/default.nix b/modules/programs/hyprland/default.nix index b436b58..bc9ef3c 100644 --- a/modules/programs/hyprland/default.nix +++ b/modules/programs/hyprland/default.nix @@ -233,17 +233,16 @@ in alsa.support32Bit = true; pulse.enable = true; }; - xserver = { + displayManager = { enable = true; - displayManager = { - lightdm.enable = true; - autoLogin = { - enable = true; - user = "moritz"; - }; - defaultSession = "hyprland"; + autoLogin = { + enable = true; + user = "moritz"; }; + defaultSession = "hyprland"; }; + xserver.enable = true; + xserver.displayManager.lightdm.enable = true; }; security.rtkit.enable = true; diff --git a/modules/programs/river/default.nix b/modules/programs/river/default.nix index c0ae02d..11133ea 100644 --- a/modules/programs/river/default.nix +++ b/modules/programs/river/default.nix @@ -1,12 +1,13 @@ { config , lib , pkgs -, inputs , ... -} @ args: +}: + -with lib; let + inherit (lib) mkEnableOption mkIf mkOption types; + cfg = config.my.programs.river; in { @@ -15,7 +16,7 @@ in keyboardLayouts = mkOption { type = types.listOf types.str; description = "list of keyboard layouts"; - default = [ "de" "us" ]; + default = [ "us" ]; }; nvidiaSupport = mkEnableOption "nvidiaSupport"; }; @@ -25,7 +26,7 @@ in my = { programs = { wallpaper.enable = true; - foot.enable = true; + kitty.enable = true; tofi.enable = true; }; wallpapers.enable = true; @@ -49,22 +50,6 @@ in }; wayland.windowManager.river = { enable = true; - package = pkgs.river.overrideAttrs (old: { - src = inputs.river; - version = lib.my.mkVersionInput inputs.river; - # HACK: to change wlroots to 0.17.x - buildInputs = with pkgs; [ - libGL - libevdev - libinput - libxkbcommon - pixman - udev - wayland-protocols - wlroots_0_17 - xorg.libX11 - ]; - }); settings = { border-width = 2; declare-mode = [ @@ -75,8 +60,7 @@ in map = { normal = { "Super Q" = "close"; - "Super Return" = ''spawn "systemctl --user is-active --quiet foot && footclient --no-wait || foot"''; - "Super+Shift Return" = "spawn foot"; + "Super Return" = "spawn kitty"; "Super R" = ''spawn 'exec $(tofi-run --fuzzy-match=true)' ''; "Super W" = ''spawn "pkill -USR1 waybar"''; "Super+Shift R" = "spawn ~/.config/river/init"; @@ -100,11 +84,13 @@ in # bump in layout stack "Super Z" = "zoom"; + # lock screen + "Super+Alt L" = ''spawn "loginctl lock-session"''; } // # tags ( let - numbers = range 1 9; + numbers = lib.range 1 9; toTag = num: "$((1 << (${toString num} - 1)))"; mkMappings = num: @@ -114,14 +100,14 @@ in in [ # Super+Control+[1-9] to toggle focus of tag [0-8] - { name = "Super ${numStr}"; value = "toggle-focused-tags ${tag}"; } + { name = "Super ${numStr}"; value = "set-focused-tags ${tag}"; } # Super+Shift+Control+[1-9] to toggle tag [0-8] of focused view { name = "Super+Shift ${numStr}"; value = "toggle-view-tags ${tag}"; } ]; - mappings = flatten (map mkMappings numbers); + mappings = lib.flatten (map mkMappings numbers); in - listToAttrs mappings + lib.listToAttrs mappings ); }; map-pointer = { @@ -139,6 +125,7 @@ in when-typing = "enabled"; }; set-cursor-warp = "on-focus-change"; + keyboard-layout = "-options grp:win_space_toggle,caps:escape ${lib.concatStringsSep "," cfg.keyboardLayouts}"; }; extraConfig = /* bash */ '' rivercarro_pid="$(pidof rivercarro)" @@ -151,6 +138,14 @@ in # add waybar as a status bar programs.waybar = { enable = true; + package = pkgs.waybar.overrideAttrs (old: { + patches = old.patches or [ ] ++ [ + (pkgs.fetchpatch { + url = "https://gitlab.archlinux.org/archlinux/packaging/packages/waybar/-/raw/0306af03fcb6de6aee1e288f42b0bf1b223513bd/a544f4b2cdcf632f1a4424b89f6e3d85ef5aaa85.patch"; + sha256 = "sha256-S/1oUj9Aj6BElNTsDY8CTcKtS1j7Gl54JFgCywH05pg="; + }) + ]; + }); # start using systemd service systemd = { @@ -169,11 +164,7 @@ in modules-right = [ "network" "memory" "cpu" "battery" "clock" ]; }; }; - style = '' - #tags button.focused { - color: #ffffff - } - ''; + style = lib.readFile ./style.css; }; # lock screen after timeout @@ -188,11 +179,11 @@ in events = [ { event = "before-sleep"; - command = "${getExe pkgs.swaylock} -fF"; + command = "${lib.getExe pkgs.swaylock} -fF"; } { event = "lock"; - command = "${getExe pkgs.swaylock} -fF"; + command = "${lib.getExe pkgs.swaylock} -fF"; } ]; timeouts = @@ -239,7 +230,7 @@ in QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; QT_QPA_PLATFORMTHEME = "qt5ct"; _JAVA_AWT_WM_NONEREPARENTING = "1"; - } // (optionalAttrs cfg.nvidiaSupport + } // (lib.optionalAttrs cfg.nvidiaSupport { GBM_BACKEND = "nvidia-drm"; GDK_BACKEND = "wayland"; @@ -263,16 +254,16 @@ in alsa.support32Bit = true; pulse.enable = true; }; + displayManager = { + autoLogin = { + enable = true; + user = "moritz"; + }; + defaultSession = "river"; + }; xserver = { enable = true; - displayManager = { - lightdm.enable = true; - autoLogin = { - enable = true; - user = "moritz"; - }; - defaultSession = "river"; - }; + displayManager.lightdm.enable = true; }; }; security.rtkit.enable = true; @@ -287,7 +278,7 @@ in }; }; in - genAttrs units mkAfter; + lib.genAttrs units mkAfter; systemd.user.services = let @@ -297,6 +288,6 @@ in wants = [ "river-session.target" ]; }; in - genAttrs units mkAfter; + lib.genAttrs units mkAfter; }; } diff --git a/modules/programs/river/style.css b/modules/programs/river/style.css new file mode 100644 index 0000000..c2e8da7 --- /dev/null +++ b/modules/programs/river/style.css @@ -0,0 +1,339 @@ +* { + /* `otf-font-awesome` is required to be installed for icons */ + font-family: FontAwesome, Roboto, Helvetica, Arial, sans-serif; + font-size: 13px; +} + +window#waybar { + background-color: rgba(43, 48, 59, 0.5); + border-bottom: 3px solid rgba(100, 114, 125, 0.5); + color: #ffffff; + transition-property: background-color; + transition-duration: .5s; +} + +window#waybar.hidden { + opacity: 0.2; +} + +/* +window#waybar.empty { + background-color: transparent; +} +window#waybar.solo { + background-color: #FFFFFF; +} +*/ + +window#waybar.termite { + background-color: #3F3F3F; +} + +window#waybar.chromium { + background-color: #000000; + border: none; +} + +button { + /* Use box-shadow instead of border so the text isn't offset */ + box-shadow: inset 0 -3px transparent; + /* Avoid rounded borders under each button name */ + border: none; + border-radius: 0; +} + +/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ +button:hover { + background: inherit; + box-shadow: inset 0 -3px #ffffff; +} + +/* you can set a style on hover for any module like this */ +#pulseaudio:hover { + background-color: #a37800; +} + +#workspaces button { + padding: 0 5px; + background-color: transparent; + color: #ffffff; +} + +#workspaces button:hover { + background: rgba(0, 0, 0, 0.2); +} + +#workspaces button.focused { + background-color: #64727D; + box-shadow: inset 0 -3px #ffffff; +} + +#workspaces button.urgent { + background-color: #eb4d4b; +} + +#mode { + background-color: #64727D; + box-shadow: inset 0 -3px #ffffff; +} + +#clock, +#battery, +#cpu, +#memory, +#disk, +#temperature, +#backlight, +#network, +#pulseaudio, +#wireplumber, +#custom-media, +#tray, +#mode, +#idle_inhibitor, +#scratchpad, +#power-profiles-daemon, +#mpd { + padding: 0 10px; + color: #ffffff; +} + +#window, +#workspaces { + margin: 0 4px; +} + +/* If workspaces is the leftmost module, omit left margin */ +.modules-left > widget:first-child > #workspaces { + margin-left: 0; +} + +/* If workspaces is the rightmost module, omit right margin */ +.modules-right > widget:last-child > #workspaces { + margin-right: 0; +} + +#clock { + background-color: #64727D; +} + +#battery { + background-color: #ffffff; + color: #000000; +} + +#battery.charging, #battery.plugged { + color: #ffffff; + background-color: #26A65B; +} + +@keyframes blink { + to { + background-color: #ffffff; + color: #000000; + } +} + +/* Using steps() instead of linear as a timing function to limit cpu usage */ +#battery.critical:not(.charging) { + background-color: #f53c3c; + color: #ffffff; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: steps(12); + animation-iteration-count: infinite; + animation-direction: alternate; +} + +#power-profiles-daemon { + padding-right: 15px; +} + +#power-profiles-daemon.performance { + background-color: #f53c3c; + color: #ffffff; +} + +#power-profiles-daemon.balanced { + background-color: #2980b9; + color: #ffffff; +} + +#power-profiles-daemon.power-saver { + background-color: #2ecc71; + color: #000000; +} + +label:focus { + background-color: #000000; +} + +#cpu { + background-color: #2ecc71; + color: #000000; +} + +#memory { + background-color: #9b59b6; +} + +#disk { + background-color: #964B00; +} + +#backlight { + background-color: #90b1b1; +} + +#network { + background-color: #2980b9; +} + +#network.disconnected { + background-color: #f53c3c; +} + +#pulseaudio { + background-color: #f1c40f; + color: #000000; +} + +#pulseaudio.muted { + background-color: #90b1b1; + color: #2a5c45; +} + +#wireplumber { + background-color: #fff0f5; + color: #000000; +} + +#wireplumber.muted { + background-color: #f53c3c; +} + +#custom-media { + background-color: #66cc99; + color: #2a5c45; + min-width: 100px; +} + +#custom-media.custom-spotify { + background-color: #66cc99; +} + +#custom-media.custom-vlc { + background-color: #ffa000; +} + +#temperature { + background-color: #f0932b; +} + +#temperature.critical { + background-color: #eb4d4b; +} + +#tray { + background-color: #2980b9; +} + +#tray > .passive { + -gtk-icon-effect: dim; +} + +#tray > .needs-attention { + -gtk-icon-effect: highlight; + background-color: #eb4d4b; +} + +#idle_inhibitor { + background-color: #2d3436; +} + +#idle_inhibitor.activated { + background-color: #ecf0f1; + color: #2d3436; +} + +#mpd { + background-color: #66cc99; + color: #2a5c45; +} + +#mpd.disconnected { + background-color: #f53c3c; +} + +#mpd.stopped { + background-color: #90b1b1; +} + +#mpd.paused { + background-color: #51a37a; +} + +#language { + background: #00b093; + color: #740864; + padding: 0 5px; + margin: 0 5px; + min-width: 16px; +} + +#keyboard-state { + background: #97e1ad; + color: #000000; + padding: 0 0px; + margin: 0 5px; + min-width: 16px; +} + +#keyboard-state > label { + padding: 0 5px; +} + +#keyboard-state > label.locked { + background: rgba(0, 0, 0, 0.2); +} + +#scratchpad { + background: rgba(0, 0, 0, 0.2); +} + +#scratchpad.empty { +background-color: transparent; +} + +#privacy { + padding: 0; +} + +#privacy-item { + padding: 0 5px; + color: white; +} + +#privacy-item.screenshare { + background-color: #cf5700; +} + +#privacy-item.audio-in { + background-color: #1ca000; +} + +#privacy-item.audio-out { + background-color: #0069d4; +} + +#tags button { + color: black; +} + +#tags button.occupied { + color: white; +} + +#tags button.focused { + background-color: grey; +}