Add initial config for river

This commit is contained in:
Erwin Boskma 2024-04-22 17:42:31 +02:00
parent 9f76b04fd7
commit 8e8678120b
Signed by: erwin
SSH key fingerprint: SHA256:/Wk1WZdLg+vQHs3in9qq7PsIp8SMzwGSk/RLZ5zPuZk
9 changed files with 570 additions and 216 deletions

View file

@ -0,0 +1,218 @@
{
pkgs,
config,
lib,
...
}:
with lib;
let
cfg = config.eboskma.programs.river;
mod = "Mod4";
lockcmd = "${pkgs.swaylock}/bin/swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image ${cfg.wallpaper} --scaling fill";
rofiPower = pkgs.writeShellScriptBin "rofi-power" (
builtins.replaceStrings [ "{WALLPAPER}" ] [ (builtins.toString cfg.wallpaper) ] (
builtins.readFile ./powermenu.sh
)
);
menu = "${config.programs.anyrun.package}/bin/anyrun";
directions = {
left = "n";
down = "e";
up = "i";
right = "o";
};
catppuccin = {
rosewater = "0xf5e0dc";
flamingo = "0xf2cdcd";
pink = "0xf5c2e7";
mauve = "0xcba6f7";
red = "0xf38ba8";
maroon = "0xeba0ac";
peach = "0xfab387";
yellow = "0xf9e2af";
green = "0xa6e3a1";
teal = "0x94e2d5";
sky = "0x89dceb";
sapphire = "0x74c7ec";
blue = "0x89b4fa";
lavender = "0xb4befe";
text = "0xcdd6f4";
subtext1 = "0xbac2de";
subtext0 = "0xa6adc8";
overlay2 = "0x9399b2";
overlay1 = "0x7f849c";
overlay0 = "0x6c7086";
surface2 = "0x585b70";
surface1 = "0x45475a";
surface0 = "0x313244";
base = "0x1e1e2e";
mantle = "0x181825";
crust = "0x11111b";
};
bit = b: (foldl (x: _: x * 2) 1 (builtins.genList (n: n + 1) b));
tags = map (num: {
value = bit num;
index = toString (num + 1);
}) (builtins.genList (n: n) 9);
in
{
options.eboskma.programs.river = {
enable = mkEnableOption "river";
package = mkPackageOption pkgs "river" { };
wallpaper = mkOption {
description = "Desired wallpaper";
type = types.path;
};
};
config = mkIf cfg.enable {
wayland.windowManager.river = {
enable = true;
settings = {
declare-mode = [
"normal"
"locked"
"passthrough"
];
input = {
pointer-1390-268-ELECOM_TrackBall_Mouse_HUGE_TrackBall = {
accel-profile = "adaptive";
natural-scroll = "enabled";
};
};
hide-cursor = "when-typing enabled";
set-cursor-warp = "on-output-change";
keyboard-layout-file = toString ./keyboard-layout;
map = {
normal =
{
"${mod} Return" = "spawn ${pkgs.foot}/bin/foot";
"${mod}+Shift q" = "close";
"${mod} s" = "spawn ${menu}";
"${mod} ${directions.left}" = "focus-view left";
"${mod} ${directions.right}" = "focus-view right";
"${mod} ${directions.up}" = "focus-view up";
"${mod} ${directions.down}" = "focus-view down";
"${mod}+Shift ${directions.left}" = "move left";
"${mod}+Shift ${directions.right}" = "move right";
"${mod}+Shift ${directions.up}" = "move up";
"${mod}+Shift ${directions.down}" = "move down";
"${mod}+Control ${directions.left}" = "snap left";
"${mod}+Control ${directions.right}" = "snap right";
"${mod}+Control ${directions.up}" = "snap up";
"${mod}+Control ${directions.down}" = "snap down";
"${mod}+Shift Space" = "toggle-float";
"${mod} t" = "toggle-fullscreen";
# Scratchpad
"${mod}+Shift minus" = "toggle-view-tags ${toString (bit 20)}";
"${mod} minus" = "toggle-focused-tags ${toString (bit 20)}";
"${mod} Print" = "spawn '${pkgs.grim}/bin/grim'";
"${mod} l" = "spawn '${lockcmd}'";
# Enable passthrough mode
"${mod} Pause" = "enter-mode passthrough";
"None XF86AudioRaiseVolume" = "spawn '${pkgs.pamedia}/bin/pamedia up'";
"None XF86AudioLowerVolume" = "spawn '${pkgs.pamedia}/bin/pamedia down'";
"None XF86AudioMute" = "spawn '${pkgs.pamedia}/bin/pamedia mute'";
"None XF86Calculator" = "spawn ${pkgs.gnome.gnome-calculator}/bin/gnome-calculator";
"${mod} c" = mkIf config.eboskma.programs.emacs.enable "spawn '${config.eboskma.programs.emacs.package}/bin/emacsclient -c'";
"${mod} d" = "spawn '${pkgs.swaynotificationcenter}/bin/swaync-client --toggle-panel --skip-wait'";
"${mod}+Shift d" = "spawn '${pkgs.swaynotificationcenter}/bin/swaync-client --toggle-dnd --skip-wait'";
"${mod}+Shift f" = "spawn ${rofiPower}";
"${mod}+Shift+Alt ${directions.left}" = "send-layout-cmd rivertile 'main-ratio -0.05'";
"${mod}+Shift+Alt ${directions.right}" = "send-layout-cmd rivertile 'main-ratio +0.05'";
"${mod}+Shift+Control ${directions.left}" = "send-layout-cmd rivertile 'main-location left'";
"${mod}+Shift+Control ${directions.right}" = "send-layout-cmd rivertile 'main-location right'";
"${mod}+Shift+Control ${directions.up}" = "send-layout-cmd rivertile 'main-location top'";
"${mod}+Shift+Control ${directions.down}" = "send-layout-cmd rivertile 'main-location bottom'";
}
// builtins.listToAttrs (
map (tag: {
name = "${mod} ${toString tag.index}";
value = "set-focused-tags ${toString tag.value}";
}) tags
)
// builtins.listToAttrs (
map (tag: {
name = "${mod}+Control ${toString tag.index}";
value = "toggle-view-tags ${toString tag.value}";
}) tags
)
// builtins.listToAttrs (
map (tag: {
name = "${mod}+Shift ${toString tag.index}";
value = "set-view-tags ${toString tag.value}";
}) tags
);
passthrough = {
"${mod} Pause" = "enter-mode normal";
};
};
map-pointer = {
normal = {
"${mod} BTN_LEFT" = "move-view";
"${mod} BTN_RIGHT" = "resize-view";
};
};
spawn-tagmask = toString (builtins.bitXor ((bit 32) - 1) (bit 20));
spawn = [
# "'${ewwDaemon} --restart open bar-home'"
"'${pkgs.swaybg}/bin/swaybg --image ${cfg.wallpaper} --mode fill'"
];
rule-add = {
"-app-id" = {
foot = "tags ${toString (bit 1)}";
firefox = "tags ${toString (bit 0)}";
emacs = "tags ${toString (bit 2)}";
gnome-calculator = "float";
};
};
default-layout = "rivertile";
border-width = 1;
border-color-focused = catppuccin.lavender;
border-color-unfocused = catppuccin.overlay0;
border-color-urgent = catppuccin.peach;
# target title bg text indicator border
# client.focused $lavender $base $text $rosewater $lavender
# client.focused_inactive $overlay0 $base $text $rosewater $overlay0
# client.unfocused $overlay0 $base $text $rosewater $overlay0
# client.urgent $peach $base $peach $overlay0 $peach
# client.placeholder $overlay0 $base $text $overlay0 $overlay0
# client.background $base
};
extraConfig = ''
${cfg.package}/bin/rivertile -view-padding 10 -outer-padding 5 &
'';
};
};
}

View file

@ -0,0 +1,9 @@
// mode: c-ts-mode
default partial alphanumeric_keys;
xkb_symbols "basic" {
include "us(altgr-intl)";
include "eurosign(5)";
name[Group1] = "English (US, international with AltGr and Euro sign)";
};

View file

@ -0,0 +1,59 @@
# shellcheck disable=SC2148
confirm() {
rofi -dmenu \
-i \
-no-fixed-num-lines \
-p "Are you sure? [y/n]: " \
-theme power
}
# Options
shutdown="󰐥" # Icon: power
reboot="󰜉" # Icon: restart
lock="󰌾" # Icon: lock
hibernate="󰤄" # Icon: power_sleep
exit_wm="󰗼" # Icon: exit_to_app
#shutdown="S"
#reboot="R"
#lock="L"
#hibernate="S"
#exit_wm="E"
# Variable passed to rofi
options="${shutdown}\n${reboot}\n${lock}\n${hibernate}\n${exit_wm}"
uptime=$(uptime | awk '{print $1}' || true)
lockcmd="swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image {WALLPAPER} --scaling fill"
chosen="$(echo -e "${options}" | rofi -theme power -p "Uptime: ${uptime}" -dmenu -selected-row 2)"
if [[ ${chosen} == "" ]]; then
exit 0
fi
if [[ ${chosen} == "${lock}" ]]; then
${lockcmd}
exit 0
fi
answer=$(confirm)
if [[ ${answer} == "y" ]]; then
case "${chosen}" in
"${shutdown}")
systemctl poweroff
;;
"${reboot}")
systemctl reboot
;;
"${hibernate}")
${lockcmd}
systemctl hibernate
;;
"${exit_wm}")
riverctl exit
;;
*) ;;
esac
fi

View file

@ -347,8 +347,11 @@ in
timeouts =
let
resumeMessages = builtins.concatStringsSep ", " (
builtins.map (name: "output ${name} power on") (builtins.attrNames cfg.output)
poweroffOpts = builtins.concatStringsSep " " (
builtins.map (name: "--output ${name} --off") (builtins.attrNames cfg.output)
);
resumeOpts = builtins.concatStringsSep " " (
builtins.map (name: "--output ${name} --on") (builtins.attrNames cfg.output)
);
in
[
@ -358,8 +361,8 @@ in
}
{
timeout = 1200;
command = "${cfg.package}/bin/swaymsg 'output * power off'";
resumeCommand = "${cfg.package}/bin/swaymsg '${resumeMessages}'";
command = "${pkgs.wlr-randr}/bin/wlr-randr ${poweroffOpts}";
resumeCommand = "${pkgs.wlr-randr}/bin/wlr-randr '${resumeOpts}'";
}
];
};

View file

@ -23,25 +23,26 @@ in
height = 32;
modules-left = [
"sway/workspaces"
"wlr/workspaces"
"river/tags"
"river/mode"
"sway/workspaces"
"sway/mode"
"custom/now_playing"
];
modules-center = [
"sway/window"
"hyprland/window"
"river/window"
];
modules-right = [
"network"
"memory"
"cpu"
"temperature"
"custom/keyboard-layout"
"wireplumber"
"tray"
"clock#date"
"clock#time"
"tray"
"idle_inhibitor"
"custom/notifications"
];
@ -67,15 +68,6 @@ in
};
};
"custom/keyboard-layout" = {
exec = ''${pkgs.sway}/bin/swaymsg -t get_inputs | ${pkgs.jaq}/bin/jaq -r '.[] | select(.identifier == "36125:40349:splitkb_Kyria_rev1") | .xkb_active_layout_name' '';
interval = 30;
format = "󰌌 {}"; # Icon: keyboard
# Signal sent by Sway key binding (~/.config/sway/key-bindings)
signal = 1; # SIGHUP
tooltip = false;
};
"memory" = {
interval = 5;
format = "󰍛 {}%"; # Icon: memory
@ -93,12 +85,6 @@ in
tooltip-format = "{ifname}: {ipaddr}";
};
"sway/mode" = {
format = ''<span style="italic">󰁌 {}</span>''; # Icon: arrow_expand_all
tooltip = false;
};
# TODO: package as nix thingy
"custom/now_playing" = {
exec = "${pkgs.ha-now-playing}/bin/ha-now-playing --host home.datarift.nl --entity media_player.sonos_woonkamer --token-file /run/secrets/ha_now_playing_token";
exec-on-event = false;
@ -111,6 +97,11 @@ in
on-scroll-up = "${pkgs.ha-now-playing}/bin/ha-now-playing --host home.datarift.nl --entity media_player.sonos_woonkamer --token-file /run/secrets/ha_now_playing_token volume-down";
};
"sway/mode" = {
format = ''<span style="italic">󰁌 {}</span>''; # Icon: arrow_expand_all
tooltip = false;
};
"sway/window" = {
format = "{}";
max-length = 120;
@ -128,6 +119,16 @@ in
};
};
"river/mode" = {
format = ''<span style="italic">󰁌 {}</span>''; # Icon: arrow_expand_all
};
"river/tags" = { };
"river/window" = {
max-length = 120;
};
"wlr/workspaces" = {
all-outputs = false;
# disable-scroll = true;
@ -206,198 +207,7 @@ in
}
];
style = ''
@keyframes blink-warning {
70% {
color: white;
}
to {
color: white;
background-color: orange;
}
}
@keyframes blink-critical {
70% {
color: white;
}
to {
color: white;
background-color: red;
}
}
* {
border: none;
border-radius: 0;
min-height: 0;
margin: 0;
padding: 0;
}
#waybar {
background: rgba(0, 0, 0, 0.8);
color: white;
font-family: "Iosevka Nerd Font", sans-serif;
font-size: 13px;
}
#battery,
#clock,
#cpu,
#custom-keyboard-layout,
#memory,
#mode,
#network,
#pulseaudio,
#temperature,
#tray,
#custom-now_playing,
#idle_inhibitor {
padding-left: 10px;
padding-right: 10px;
}
#battery {
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#battery.warning {
color: orange;
}
#battery.critical {
color: red;
}
#battery.warning.discharging {
animation-name: blink-warning;
animation-duration: 3s;
}
#battery.critical.discharging {
animation-name: blink-critical;
animation-duration: 2s;
}
#clock {
font-weight: bold;
}
#cpu {
/* No styles */
}
#cpu.warning {
color: orange;
}
#cpu.critical {
color: red;
}
#memory {
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#memory.warning {
color: orange;
}
#memory.critical {
color: red;
animation-name: blink-critical;
animation-duration: 2s;
}
#mode {
background: #64727D;
border-top: 2px solid white;
/* To compensate for the top border and still have vertical centering */
padding-bottom: 2px;
}
#network {
/* No styles */
}
#network.disconnected {
color: orange;
}
#pulseaudio {
/* No styles */
}
#pulseaudio.muted {
/* No styles */
}
#custom-spotify {
color: rgb(102, 220, 105);
}
#temperature {
/* No styles */
}
#temperature.critical {
color: red;
}
#tray {
/* No styles */
}
#window {
font-weight: bold;
}
#workspaces button {
border-top: 2px solid transparent;
/* To compensate for the top border and still have vertical centering */
padding-bottom: 2px;
padding-left: 10px;
padding-right: 10px;
color: #888888;
}
#workspaces button.focused, #workspaces button.active {
border-color: #4c7899;
color: white;
background-color: #285577;
}
#workspaces button.urgent {
border-color: #c9545d;
color: #c9545d;
}
#idle_inhibitor {
background-color: transparent;
font-weight: bold;
padding-right: 10px;
}
#idle_inhibitor.activated {
background-color: #c9545d;
color: #ffffff;
}
#custom-now_playing {
font-weight: bold;
}
#custom-notifications {
padding: 0 10px;
}
'';
style = ./style.css;
};
};
}

View file

@ -0,0 +1,247 @@
@define-color rosewater #f5e0dc;
@define-color flamingo #f2cdcd;
@define-color pink #f5c2e7;
@define-color mauve #cba6f7;
@define-color red #f38ba8;
@define-color maroon #eba0ac;
@define-color peach #fab387;
@define-color yellow #f9e2af;
@define-color green #a6e3a1;
@define-color teal #94e2d5;
@define-color sky #89dceb;
@define-color sapphire #74c7ec;
@define-color blue #89b4fa;
@define-color lavender #b4befe;
@define-color text #cdd6f4;
@define-color subtext1 #bac2de;
@define-color subtext0 #a6adc8;
@define-color overlay2 #9399b2;
@define-color overlay1 #7f849c;
@define-color overlay0 #6c7086;
@define-color surface2 #585b70;
@define-color surface1 #45475a;
@define-color surface0 #313244;
@define-color base #1e1e2e;
@define-color mantle #181825;
@define-color crust #11111b;
@keyframes blink-warning {
70% {
color: @text;
}
to {
color: @text;
background-color: orange;
}
}
@keyframes blink-critical {
70% {
color: @text;
}
to {
color: @text;
background-color: red;
}
}
* {
border: none;
border-radius: 0;
color: @text;
min-height: 0;
margin: 0;
padding: 0;
}
#waybar {
background: @base;
color: @text;
font-family: "Iosevka Nerd Font", sans-serif;
font-size: 14px;
}
#battery,
#clock,
#cpu,
#custom-keyboard-layout,
#memory,
#mode,
#network,
#pulseaudio,
#temperature,
#tray,
#custom-now_playing,
#idle_inhibitor {
padding-left: 10px;
padding-right: 10px;
}
#battery {
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#battery.warning {
color: @peach;
}
#battery.critical {
color: @red;
}
#battery.warning.discharging {
animation-name: blink-warning;
animation-duration: 3s;
}
#battery.critical.discharging {
animation-name: blink-critical;
animation-duration: 2s;
}
#clock {
font-weight: bold;
}
#cpu {
/* No styles */
}
#cpu.warning {
color: @peach;
}
#cpu.critical {
color: @red;
}
#memory {
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#memory.warning {
color: @peach;
}
#memory.critical {
color: @red;
animation-name: blink-critical;
animation-duration: 2s;
}
#mode {
background: @surface0;
border-top: 2px solid @text;
/* To compensate for the top border and still have vertical centering */
padding-bottom: 2px;
}
#mode.normal {
font-size: 0;
min-width: 0;
min-height: 0;
margin: -17px;
padding: 0;
border: 0;
opacity: 0;
box-shadow: none;
background-color: transparent;
}
#network {
/* No styles */
}
#network.disconnected {
color: @peach;
}
#pulseaudio {
/* No styles */
}
#pulseaudio.muted {
/* No styles */
}
#custom-spotify {
color: rgb(102, 220, 105);
}
#temperature {
/* No styles */
}
#temperature.critical {
color: @red;
}
#tray {
/* No styles */
}
#window {
font-weight: bold;
}
#tags button,
#workspaces button {
border-top: 2px solid transparent;
/* To compensate for the top border and still have vertical centering */
padding-bottom: 2px;
padding-left: 10px;
padding-right: 10px;
color: @overlay1;
}
#tags button.focused,
#tags button.active,
#workspaces button.focused,
#workspaces button.active {
border-color: @surface2;
color: @text;
background-color: @surface0;
}
#tags button.urgent,
#workspaces button.urgent {
border-color: @red;
color: @text;
}
#tags button:not(.occupied):not(.focused) {
font-size: 0;
min-width: 0;
min-height: 0;
margin: -17px;
padding: 0;
border: 0;
opacity: 0;
box-shadow: none;
background-color: transparent;
}
#idle_inhibitor {
background-color: transparent;
font-weight: bold;
padding-right: 10px;
}
#idle_inhibitor.activated {
background-color: @red;
color: @text;
}
#custom-now_playing {
font-weight: bold;
}
#custom-notifications {
padding: 0 10px;
}

View file

@ -46,6 +46,7 @@
greetd = {
enable = true;
sway = true;
river = true;
wallpaper = ../../wallpapers/river-2560.png;
};
libvirtd.enable = false;

View file

@ -41,6 +41,7 @@ in
options.eboskma.greetd = {
enable = mkEnableOption "enable greetd";
sway = mkEnableOption "sway";
river = mkEnableOption "river";
steam = mkEnableOption "steam";
wayvnc = mkEnableOption "wayvnc";
output = mkOption {
@ -131,6 +132,7 @@ in
"greetd/environments" = {
text = concatStringsSep "\n" (
(optional cfg.sway "${swaySession}")
++ (optional cfg.river "${pkgs.river}/bin/river")
++ (optional cfg.steam "${steam-gamescope}")
++ [ "${pkgs.bash}/bin/bash" ]
);

View file

@ -107,6 +107,10 @@ in
}
];
};
river = {
enable = true;
wallpaper = "${homeCfg.home.homeDirectory}/.wallpapers/river-2560.png";
};
rofi = {
enable = true;
package = pkgs.rofi-wayland;
@ -131,6 +135,7 @@ in
input = {
"36125:40349:splitkb.com_Kyria_rev1" = {
xkb_layout = "us";
xkb_variant = "altgr-intl";
xkb_options = "lv3:ralt_switch_multikey,eurosign:5";
};
"1133:49291:Logitech_G502_HERO_SE" = {
@ -161,7 +166,7 @@ in
};
};
tmux.enable = true;
waybar.enable = false;
waybar.enable = true;
zathura.enable = true;
zellij = {
enable = true;