From 21b52a31e1eff5c8142f26e091fde083c21db55f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 14 Jan 2025 11:30:32 +0100 Subject: niri --- accounts/gkleen@sif/default.nix | 309 +------------------------ accounts/gkleen@sif/hyprland.nix | 425 ----------------------------------- accounts/gkleen@sif/niri/default.nix | 139 ++++++++++++ accounts/gkleen@sif/niri/waybar.nix | 288 ++++++++++++++++++++++++ 4 files changed, 433 insertions(+), 728 deletions(-) delete mode 100644 accounts/gkleen@sif/hyprland.nix create mode 100644 accounts/gkleen@sif/niri/default.nix create mode 100644 accounts/gkleen@sif/niri/waybar.nix (limited to 'accounts') diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index 83dcf989..bcfd1224 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -92,6 +92,7 @@ in { home-manager.users.${userName} = { imports = [ ./libvirt + ./niri flakeInputs.nix-index-database.hmModules.nix-index flakeInputs.impermanence.nixosModules.home-manager.impermanence ]; @@ -250,287 +251,6 @@ in { "kitty_mod+m" = "detach_window ask"; }; }; - waybar = { - enable = true; - systemd = { - enable = true; - target = "hyprland-session.target"; - }; - settings = let - windowRewrites = { - "(.*) — Mozilla Firefox" = "$1"; - "(.*) - Mozilla Thunderbird" = "$1"; - "(.*) - mpv" = "$1"; - }; - iconSize = 11; - in [ - { - layer = "top"; - position = "top"; - height = 14; - output = [ "eDP-1" "DP-2" "DP-3" ]; - modules-left = [ "hyprland/workspaces" ]; - modules-center = [ "hyprland/window" ]; - modules-right = [ # "custom/worktime" "custom/worktime-today" - "custom/weather" "custom/keymap" "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "clock" ]; - - "custom/weather" = { - format = "{}"; - tooltip = true; - interval = 3600; - exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --nerd --custom-indicator \"{ICON} {FeelsLikeC}°\""; - return-type = "json"; - }; - "custom/keymap" = { - format = "{}"; - tooltip = true; - return-type = "json"; - exec = pkgs.writers.writePython3 "keymap" {} '' - import os - import socket - import re - import subprocess - import json - - - def output(keymap): - short = keymap - if keymap == "English (programmer Dvorak)": - short = "dvp" - elif keymap == "English (US)": - short = "us" - print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501 - - - r = subprocess.run(["hyprctl", "devices", "-j"], check=True, stdout=subprocess.PIPE, text=True) # noqa: E501 - for keyboard in json.loads(r.stdout)['keyboards']: - if keyboard['name'] != "at-translated-set-2-keyboard": - continue - output(keyboard['active_keymap']) - - sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - sock.connect(os.environ["XDG_RUNTIME_DIR"] + "/hypr/" + os.environ["HYPRLAND_INSTANCE_SIGNATURE"] + "/.socket2.sock") # noqa: E501 - expected = re.compile(r'^activelayout>>at-translated-set-2-keyboard,(?P.+)$') # noqa: E501 - for line in sock.makefile(buffering=1, encoding='utf-8'): - if match := expected.match(line): - output(match.group("keymap")) - ''; - on-click = "hyprctl switchxkblayout at-translated-set-2-keyboard next"; - }; - "custom/worktime" = { - interval = 60; - exec = getExe pkgs.worktime; - tooltip = false; - }; - "custom/worktime-today" = { - interval = 60; - exec = "${getExe pkgs.worktime} today"; - tooltip = false; - }; - "hyprland/workspaces" = { - all-outputs = true; - }; - "hyprland/window" = { - separate-outputs = true; - icon = true; - icon-size = 14; - rewrite = windowRewrites; - }; - clock = { - interval = 1; - # timezone = "Europe/Berlin"; - format = "W{:%V-%u %F %H:%M:%S%Ez}"; - tooltip-format = "{calendar}"; - calendar = { - mode = "year"; - mode-mon-col = 3; - weeks-pos = "left"; - on-scroll = 1; - format = { - months = "{}"; - days = "{}"; - weeks = "{}"; - weekdays = "{}"; - today = "{}"; - }; - }; - }; - battery = { - format = "{icon}"; - icon-size = iconSize - 2; - states = { warning = 30; critical = 15; }; - format-icons = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ]; - format-charging = "󰂄"; - format-plugged = "󰚥"; - tooltip-format = "{capacity}% {timeTo}"; - interval = 20; - }; - tray = { - icon-size = 16; - # show-passive-items = true; - spacing = 1; - }; - privacy = { - icon-spacing = 7; - icon-size = iconSize; - modules = [ - { type = "screenshare"; } - { type = "audio-in"; } - ]; - }; - idle_inhibitor = { - format = "{icon}"; - icon-size = iconSize; - format-icons = { activated = "󰈈"; deactivated = "󰈉"; }; - timeout = 120; - }; - backlight = { - format = "{icon}"; - icon-size = iconSize; - tooltip-format = "{percent}%"; - format-icons = ["󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠"]; - on-scroll-up = "lightctl -d -e4 -n1 up"; - on-scroll-down = "lightctl -d -e4 -n1 down"; - }; - wireplumber = { - format = "{icon}"; - icon-size = iconSize; - tooltip-format = "{volume}% {node_name}"; - format-icons = ["󰕿" "󰖀" "󰕾"]; - format-muted = "󰝟"; - # ignored-sinks = ["Easy Effects Sink"]; - on-scroll-up = "volumectl -d -u up"; - on-scroll-down = "volumectl -d -u down"; - on-click = "volumectl -d toggle-mute"; - }; - } - { - layer = "top"; - position = "top"; - height = 14; - output = [ "!eDP-1" "!DP-2" "!DP-3" ]; - modules-left = [ "hyprland/workspaces" ]; - modules-center = [ "hyprland/window" ]; - modules-right = [ "clock" ]; - - "hyprland/workspaces" = { - all-outputs = false; - }; - "hyprland/window" = { - separate-outputs = true; - icon = true; - icon-size = 14; - rewrite = windowRewrites; - }; - clock = { - interval = 1; - # timezone = "Europe/Berlin"; - format = "{:%H:%M}"; - tooltip-format = "W{:%V-%u %F %H:%M:%S%Ez}"; - }; - } - ]; - style = '' - @define-color white #ffffff; - @define-color grey #555555; - @define-color blue #1a8fff; - @define-color green #23fd00; - @define-color orange #f28a21; - @define-color red #f2201f; - - * { - border: none; - font-family: "Fira Sans Nerd Font"; - font-size: 10pt; - min-height: 0; - } - - window#waybar { - background-color: rgba(0, 0, 0, 0.66); - color: @white; - } - - .modules-left { - margin-left: 9px; - } - .modules-right { - margin-right: 9px; - } - - .module { - margin: 0 5px; - } - - #workspaces button { - color: @grey; - } - #workspaces button.hosting-monitor { - color: @white; - } - #workspaces button.visible { - color: @blue; - } - #workspaces button.active { - color: @green; - } - #workspaces button.urgent { - color: @red; - } - - #custom-weather, #custom-keymap, #custom-worktime, #custom-worktime-today { - color: @grey; - margin: 0 5px; - } - #custom-weather, #custom-worktime-today { - margin-right: 3px; - } - #custom-keymap, #custom-weather { - margin-left: 3px; - } - - #tray { - margin: 0; - } - #battery, #idle_inhibitor, #backlight, #wireplumber { - color: @grey; - margin: 0 5px 0 2px; - } - #idle_inhibitor { - margin-right: 2px; - margin-left: 3px; - } - #battery { - margin-right: 3px; - } - #battery.discharging { - color: @white; - } - #battery.warning { - color: @orange; - } - #battery.critical { - color: @red; - } - #battery.charging { - color: @white; - } - #idle_inhibitor.activated { - color: @white; - } - - #idle_inhibitor { - padding-top: 1px; - } - - #privacy { - color: @red; - margin: -1px 2px 0px 5px; - } - #clock { - /* margin-right: 5px; */ - } - ''; - }; wpaperd = { enable = true; settings.default = { @@ -543,7 +263,7 @@ in { enable = true; settings = { main = { - terminal = lib.getExe pkgs.kitty; + terminal = lib.getExe cfg.programs.kitty.package; layer = "overlay"; icon-theme = "Paper"; font = "Fira Sans"; @@ -639,13 +359,13 @@ in { enable = true; events = [ { event = "before-sleep"; command = lockCommand; } - { event = "after-resume"; command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on"; } + # { event = "after-resume"; command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on"; } { event = "lock"; command = lockCommand; } ]; timeouts = [ - { timeout = 300; - command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off"; - } + # { timeout = 300; + # command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off"; + # } { timeout = 330; command = lockCommand; } ]; extraArgs = [ @@ -927,23 +647,6 @@ in { color-scheme = "prefer-dark"; }; }; - - wayland.windowManager.hyprland = { - enable = true; - settings = import ./hyprland.nix inputs; - }; - - xdg.portal = { - enable = true; - xdgOpenUsePortal = true; - config = { - common.default = [ "gtk" ]; - hyprland.default = [ "gtk" "kde" "hyprland" ]; - }; - extraPortals = with pkgs; [ - xdg-desktop-portal-kde xdg-desktop-portal-gtk xdg-desktop-portal-wlr xdg-desktop-portal-hyprland - ]; - }; }; }; } diff --git a/accounts/gkleen@sif/hyprland.nix b/accounts/gkleen@sif/hyprland.nix deleted file mode 100644 index 90ae689a..00000000 --- a/accounts/gkleen@sif/hyprland.nix +++ /dev/null @@ -1,425 +0,0 @@ -{ pkgs, lib, config, userName, ... }: -let - cfg = config.home-manager.users.${userName}; -in { - monitor = [ - ",preferred,auto,auto,bitdepth,8" - "eDP-1,3840x2160@60,auto,1.5,bitdepth,8" - ]; - - "$terminal" = "kitty"; - "$menu" = "fuzzel"; - - env = [ - "NIXOS_OZONE_WL,1" - "QT_QPA_PLATFORM,wayland" - "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" - "GDK_BACKEND,wayland" - "GDK_SCALE,0.66" - "QT_AUTO_SCREEN_SCALE_FACTOR,1" - "SDL_VIDEODRIVER,wayland" - # "AQ_DRM_DEVICES,/dev/dri/by-path/pci-0000:01:00.0-card" - "__NV_PRIME_RENDER_OFFLOAD,1" - "__NV_PRIME_RENDER_OFFLOAD_PROVIDER,NVIDIA-G0" - "__GLX_VENDOR_LIBRARY_NAME,nvidia" - "__VK_LAYER_NV_optimus,NVIDIA_only" - ]; - - xwayland.force_zero_scaling = true; - - general = { - gaps_in = 3; - gaps_out = 9; - "col.active_border" = "rgba(33ccffee) rgba(00ff95ee) 45deg"; - "col.inactive_border" = "rgba(595959aa)"; - - resize_on_border = false; - - allow_tearing = false; - - layout = "dwindle"; - }; - - decoration = { - rounding = 5; - dim_special = 0.0; - }; - - animations = { - enabled = true; - bezier = "myBezier, 0.05, 0.9, 0.1, 1.05"; - animation = [ - "windows, 1, 1, default, popin 80%" - "windowsMove, 0" - # "windows, 1, 7, myBezier" - # "windowsOut, 1, 7, myBezier, popin 80%" - "border, 1, 10, default" - "borderangle, 1, 8, default" - "fade, 1, 1, default" - "workspaces, 1, 1, default, fade" - # "workspaces, 1, 6, default" - ]; - }; - - dwindle = { - pseudotile = false; - preserve_split = true; - }; - - master = { - new_status = "master"; - }; - - misc = { - disable_hyprland_logo = true; - disable_splash_rendering = true; - # focus_on_activate = true; - mouse_move_enables_dpms = true; - key_press_enables_dpms = true; - new_window_takes_over_fullscreen = 1; - exit_window_retains_fullscreen = true; - }; - - cursor = { - use_cpu_buffer = true; - hide_on_key_press = true; - # no_hardware_cursors = 0; - }; - - input = { - kb_layout = "us,us"; - kb_variant = "dvp,"; - kb_model = ""; - kb_options = "compose:caps,grp:win_space_toggle"; - kb_rules = ""; - - follow_mouse = 1; - - sensitivity = 0; - - touchpad = { - natural_scroll = false; - }; - }; - - device = [ - { name = "synaptics-tm3512-010"; - sensitivity = 0.4; - } - { name = "tpps/2-elan-trackpoint"; - sensitivity = 0.2; - } - { name = "logitech-ergo-m575"; - sensitivity = 1.333; - } - ]; - - gestures = { - workspace_swipe = false; - }; - - dwindle = { - # no_gaps_when_only = 1; - }; - - "$mainMod" = "SUPER"; - - bind = [ - "$mainMod, return, exec, $terminal" - "$mainMod, Q, killactive" - "$mainMod SHIFT, Q, exec, hyprctl kill" - "$mainMod, V, togglefloating" - "$mainMod, D, exec, $menu" - "$mainMod SHIFT, D, exec, $menu --list-executables-in-path" - # "$mainMod, J, togglesplit," - - "$mainMod SHIFT, L, exec, loginctl lock-session" - "$mainMod SHIFT, E, exit" - - "$mainMod, left, movefocus, l" - "$mainMod, right, movefocus, r" - "$mainMod, up, movefocus, u" - "$mainMod, down, movefocus, d" - "$mainMod SHIFT, left, swapwindow, l" - "$mainMod SHIFT, right, swapwindow, r" - "$mainMod SHIFT, up, swapwindow, u" - "$mainMod SHIFT, down, swapwindow, d" - - "$mainMod, N, cyclenext, tiled" - "$mainMod, T, cyclenext, prev tiled" - "$mainMod SHIFT, N, swapnext" - "$mainMod SHIFT, T, swapnext, prev" - - "$mainMod, G, focusmonitor, 0" - "$mainMod, C, focusmonitor, 1" - "$mainMod, R, focusmonitor, 2" - "$mainMod, L, focusmonitor, 3" - - "$mainMod CTRL, G, movecurrentworkspacetomonitor, 0" - "$mainMod CTRL, C, movecurrentworkspacetomonitor, 1" - "$mainMod CTRL, R, movecurrentworkspacetomonitor, 2" - "$mainMod CTRL, L, movecurrentworkspacetomonitor, 3" - - "$mainMod, F, fullscreen, 1" - "$mainMod SHIFT, F, fullscreen, 0" - "$mainMod CTRL SHIFT, F, fullscreenstate, 1, 2" - - "$mainMod, code:14, workspace, 1" - "$mainMod, code:17, workspace, 2" - "$mainMod, code:13, workspace, 3" - "$mainMod, code:18, workspace, 4" - "$mainMod, code:12, workspace, 5" - "$mainMod, code:19, workspace, 6" - "$mainMod, code:11, workspace, 7" - "$mainMod, code:20, workspace, 8" - "$mainMod, code:15, workspace, 9" - "$mainMod, code:16, workspace, 10" - - "$mainMod SHIFT, code:14, movetoworkspacesilent, 1" - "$mainMod SHIFT, code:17, movetoworkspacesilent, 2" - "$mainMod SHIFT, code:13, movetoworkspacesilent, 3" - "$mainMod SHIFT, code:18, movetoworkspacesilent, 4" - "$mainMod SHIFT, code:12, movetoworkspacesilent, 5" - "$mainMod SHIFT, code:19, movetoworkspacesilent, 6" - "$mainMod SHIFT, code:11, movetoworkspacesilent, 7" - "$mainMod SHIFT, code:20, movetoworkspacesilent, 8" - "$mainMod SHIFT, code:15, movetoworkspacesilent, 9" - "$mainMod SHIFT, code:16, movetoworkspacesilent, 10" - - "$mainMod, semicolon, exec, dunstctl close" - "$mainMod SHIFT, semicolon, exec, dunstctl close-all" - "$mainMod, period, exec, dunstctl context" - "$mainMod, comma, exec, dunstctl history-pop" - - "$mainMod ALT, E, exec, emacsclient -c" - "$mainMod ALT, Y, exec, ${pkgs.writeShellScript "yt-dlp" '' - export PATH="${lib.makeBinPath (with pkgs; [ wl-clipboard-rs socat ])}:$PATH" - socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/yt-dlp.sock <<<$'{ "urls": ["'"$(wl-paste)"$'"] }' - ''}" - "$mainMod ALT, L, exec, ${pkgs.writeShellScript "mpv" '' - export PATH="${lib.makeBinPath (with pkgs; [ wl-clipboard-rs ])}:$PATH" - exec mpv "$(wl-paste)" - ''}" - - ", Print, exec, ${pkgs.writeShellScript "screenshot" '' - export PATH="${lib.makeBinPath (with pkgs; [ grim slurp wl-clipboard-rs coreutils ])}:$PATH" - - outFile="$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" - grim -g "$(slurp -b 00000080 -c FFFFFFFF -s 00000000 -w 1)" "$outFile" - wl-copy --type image/png <"$outFile" - ''}" - "SHIFT, Print, exec, ${pkgs.writeShellScript "screenshot" '' - export PATH="${lib.makeBinPath (with pkgs; [ grim jq wl-clipboard-rs coreutils ])}:$PATH" - - outFile="$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" - grim -o "$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .name')" "$outFile" - wl-copy --type image/png <"$outFile" - ''}" - "CTRL SHIFT, Print, exec, ${pkgs.runCommand "picker" { - buildInputs = [ pkgs.makeWrapper ]; - } '' - makeWrapper ${lib.getExe pkgs.hyprpicker} $out \ - --prefix PATH : ${lib.makeBinPath [pkgs.wl-clipboard-rs]} - ''} -a" - "$mainMod, M, exec, ${pkgs.writeShellScript "qalc-fuzzel" '' - export PATH="${lib.makeBinPath (with pkgs; [ wl-clipboard-rs libqalculate cfg.programs.fuzzel.package coreutils findutils libnotify gnugrep ])}:$PATH" - - RESULTS_DIR="$HOME/.cache/qalc-fuzzel" - prev() { - FOUND=false - while IFS= read -r line; do - [[ -n "$line" ]] || continue - FOUND=true - echo $line - done < <(export LC_ALL=C.UTF-8; echo; find "$RESULTS_DIR" -type f -printf $'%T@ %p\n' | sort -n | cut -d' ' -f2- | xargs -r cat) - $FOUND || echo - } - FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> ") || exit $? - if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then - QALC_RES="$FUZZEL_RES" - QALC_RET=0 - else - QALC_RES=$(qalc "$FUZZEL_RES" 2>&1) - QALC_RET=$? - fi - [[ -n "$QALC_RES" ]] || exit 1 - EXISTING=false - fgrep -xrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch - [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true - if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then - RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' "$RES_FILE" <<<"$QALC_RES" - fi - [[ "$QALC_RES" =~ .*\ =\ (.*) ]] && QALC_RES="''${BASH_REMATCH[1]}" - [[ $QALC_RET -eq 0 ]] && wl-copy "$QALC_RES" - notify-send "$QALC_RES" - ''}" - "$mainMod, E, exec, ${pkgs.writeShellScript "emoji-fuzzel" '' - export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package wtype wl-clipboard-rs ])}:$PATH" - - FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " <$HOME/.local/share/emoji-data/list.txt) || exit $? - [[ -n "$FUZZEL_RES" ]] || exit 1 - wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste - ''}" - "$mainMod, B, exec, ${pkgs.writeShellScript "bring" '' - export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package gawk gojq cfg.wayland.windowManager.hyprland.package ])}:$PATH" - - state="$(hyprctl -j clients)" - active_window="$(hyprctl -j activewindow)" - active_workspace="$(hyprctl -j activeworkspace | gojq -r '.id')" - - current_addr="$(echo "$active_window" | gojq -r '.address')" - - window="$(echo "$state" | - gojq -r '.[] | select(.workspace.id == '"$active_workspace"') | select(.monitor != -1 ) | "\(.title)\t\(.address)"' | - fuzzel --log-level=warning --dmenu)" - - addr="$(echo "$window" | awk -F $'\t' '{print $2}')" - - if [[ "$addr" = "$current_addr" ]]; then - exit 0 - fi - - fullscreen_on_same_ws="$(echo "$state" | gojq -r '.[] | select(.fullscreen == true) | select(.workspace.id == '"$active_workspace"') | .address')" - - if [[ "$window" != "" ]]; then - if [[ "$fullscreen_on_same_ws" == "" ]]; then - hyprctl dispatch focuswindow address:"''${addr}" - else - # If we want to focus app_A and app_B is fullscreen on the same workspace, - # app_A will get focus, but app_B will remain on top. - # This monstrosity is to make sure app_A will end up on top instead. - # XXX: doesn't handle fullscreen 0, but I don't care. - hyprctl --batch "dispatch focuswindow address:''${fullscreen_on_same_ws}; dispatch fullscreen 1; dispatch focuswindow address:''${addr}; dispatch fullscreen 1" - fi - fi - ''}" - "$mainMod SHIFT, B, exec, ${pkgs.writeShellScript "bring" '' - export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package gawk gojq cfg.wayland.windowManager.hyprland.package ])}:$PATH" - - state="$(hyprctl -j clients)" - active_window="$(hyprctl -j activewindow)" - - current_addr="$(echo "$active_window" | gojq -r '.address')" - - window="$(echo "$state" | - gojq -r '.[] | select(.monitor != -1 ) | "\(.title)\t\(.workspace.name)\t\(.address)"' | - fuzzel --log-level=warning --dmenu)" - - addr="$(echo "$window" | awk -F $'\t' '{print $3}')" - ws="$(echo "$window" | awk -F $'\t' '{print $2}')" - - if [[ "$addr" = "$current_addr" ]]; then - exit 0 - fi - - fullscreen_on_same_ws="$(echo "$state" | gojq -r ".[] | select(.fullscreen == true) | select(.workspace.name == \"$ws\") | .address")" - - if [[ "$window" != "" ]]; then - if [[ "$fullscreen_on_same_ws" == "" ]]; then - hyprctl dispatch focuswindow address:"''${addr}" - else - # If we want to focus app_A and app_B is fullscreen on the same workspace, - # app_A will get focus, but app_B will remain on top. - # This monstrosity is to make sure app_A will end up on top instead. - # XXX: doesn't handle fullscreen 0, but I don't care. - hyprctl --batch "dispatch focuswindow address:''${fullscreen_on_same_ws}; dispatch fullscreen 1; dispatch focuswindow address:''${addr}; dispatch fullscreen 1" - fi - fi - ''}" - - "$mainMod CTRL, return, togglespecialworkspace, term" - "$mainMod CTRL, e, togglespecialworkspace, edit" - "$mainMod CTRL, a, togglespecialworkspace, pwvucontrol" - "$mainMod CTRL, o, togglespecialworkspace, easyeffects" - "$mainMod CTRL, b, togglespecialworkspace, blueman" - "$mainMod CTRL, p, togglespecialworkspace, keepass" - ]; - bindm = [ - "$mainMod, mouse:272, movewindow" - "$mainMod, mouse:273, resizewindow" - ]; - bindel = [ - ", XF86MonBrightnessUp, exec, lightctl -d -e4 -n1 up" - ", XF86MonBrightnessDown, exec, lightctl -d -e4 -n1 down" - ", XF86AudioRaiseVolume, exec, volumectl -d -u up" - ", XF86AudioLowerVolume, exec, volumectl -d -u down" - ]; - bindl = [ - ", XF86AudioMute, exec, volumectl -d toggle-mute" - ", XF86AudioMicMute, exec, volumectl -d -m toggle-mute" - "$mainMod SHIFT, S, exec, systemctl suspend" - - ", switch:off:Lid Switch,exec,hyprctl dispatch dpms on eDP-1" - ", switch:on:Lid Switch,exec,hyprctl dispatch dpms off eDP-1" - - ", switch:off:Lid Switch,exec,${pkgs.writeShellScript "clamshell-off" '' - export PATH="${lib.makeBinPath (with pkgs; [ jq ])}:$PATH" - [[ $(hyprctl monitors -j | jq '.[] | select(.name == "eDP-1") | .disabled') = "true" ]] || exit 0 - - hyprctl keyword monitor "eDP-1,3840x2160@60,auto,1.5" - ''}" - ", switch:on:Lid Switch,exec,${pkgs.writeShellScript "clamshell-on" '' - export PATH="${lib.makeBinPath (with pkgs; [ jq ])}:$PATH" - - [[ $(hyprctl monitors -j | jq 'reduce (.[] | select(.disabled == false)) as $_ (0; .+1)') -gt 1 ]] || exit 0 - - hyprctl keyword monitor "eDP-1,disable" - ''}" - ]; - - windowrulev2 = [ - "suppressevent maximize fullscreen, class:.*" - - # "maximize, class:^(Element|thunderbird)$" - "workspace special:pwvucontrol, class:^com\.saivert\.pwvucontrol$" - "workspace special:easyeffects, class:^com\.github\.wwmm\.easyeffects$" - "workspace special:blueman, class:^\.blueman-manager-wrapped$" - "workspace special:keepass silent, class:^org\.keepassxc\.KeePassXC$, title:^(?!Unlock Database.*)(?!.*(Access Request|Passkey credentials)).*$" - # "group set always lock invade, class:^Element$" - "workspace 2, class:^firefox$" - "workspace 4, class:^evince$" - "workspace 4, class:^imv$" - "workspace 4, class:^org\.pwmt\.zathura$" - "workspace 10, class:^mpv$" - "workspace 1, class:^Element$" - "workspace 1, class:^thunderbird$" - "workspace 5, class:^virt-manager$" - "workspace 5, class:^qemu$" - "float, class:^org\.keepassxc\.KeePassXC$, title:^.*Access Request$" - "center, class:^org\.keepassxc\.KeePassXC$, title:^.*Access Request$" - "float, class:^org\.keepassxc\.KeePassXC$, title:^.*Passkey credentials$" - "center, class:^org\.keepassxc\.KeePassXC$, title:^.*Passkey credentials$" - "float, class:^org\.keepassxc\.KeePassXC$, title:^Unlock Database.*$" - "center, class:^org\.keepassxc\.KeePassXC$, title:^Unlock Database.*$" - "float, class:^xdg-desktop-portal-gtk$" - "center, class:^xdg-desktop-portal-gtk$" - - "bordercolor rgba(ffaa33ee) rgba(bfff00ee) 45deg, fullscreen:1" - "bordercolor rgba(3366ffee) rgba(6a00ffee) 45deg, xwayland:1" - "bordercolor rgba(6633ffee) rgba(ea00ffee) 45deg, xwayland:1, fullscreen:1" - ]; - - workspace = [ - "s[true], gapsout:100" - - "special:term, on-created-empty:kitty" - "special:edit, on-created-empty:emacsclient -c" - "special:pwvucontrol, on-created-empty:pwvucontrol" - "special:easyeffects, on-created-empty:easyeffects" - "special:blueman, on-created-empty:blueman-manager" - "special:keepass, on-created-empty:keepassxc" - - "1, defaultName:comm" - "2, defaultName:web" - "3, defaultName:work" - "4, defaultName:read" - ]; - - layerrule = [ - "blur, waybar" - "blur, launcher" - "noanim, notifications" - "blur, notifications" - ]; -} diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix new file mode 100644 index 00000000..6a8d10a0 --- /dev/null +++ b/accounts/gkleen@sif/niri/default.nix @@ -0,0 +1,139 @@ +{ config, pkgs, lib, ... }: +let + niri = config.programs.niri.package; + terminal = lib.getExe config.programs.kitty.package; + lightctl = lib.getExe' config.services.avizo.package "lightctl"; + volumectl = lib.getExe' config.services.avizo.package "volumectl"; + dunstctl = lib.getExe' config.services.dunst.package "dunstctl"; +in { + imports = [ + ./waybar.nix + ]; + + config = { + systemd.user.services.xwayland-satellite = { + Unit = { + BindsTo = [ "graphical-session.target" ]; + PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session.target" ]; + Requisite = [ "graphical-session.target" ]; + }; + Service = { + Type = "notify"; + NotifyAccess = "all"; + ExecStart = lib.getExe pkgs.xwayland-satellite-unstable; + StandardOutput = "journal"; + }; + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + + programs.niri.settings = { + prefer-no-csd = true; + screenshot-path = "${config.home.homeDirectory}/screenshots"; + + input = { + keyboard.xkb = { + layout = "us,"; + variant = "dvp,"; + options = "compose:caps,grp:win_space_toggle"; + }; + }; + + environment = { + NIXOS_OZONE_WL = "1"; + QT_QPA_PLATFORM = "wayland"; + GDK_BACKEND = "wayland"; + SDL_VIDEODRIVER = "wayland"; + }; + + cursor.hide-when-typing = true; + + binds = with config.lib.niri.actions; { + "Mod+Return".action = spawn terminal; + "Mod+Q".action = close-window; + "Mod+D".action = spawn (lib.getExe config.programs.fuzzel.package); + "Mod+Shift+D".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; + + "Mod+H".action = focus-column-left; + "Mod+T".action = focus-window-down; + "Mod+N".action = focus-window-up; + "Mod+S".action = focus-column-right; + + "Mod+Shift+H".action = move-column-left; + "Mod+Shift+T".action = move-window-down; + "Mod+Shift+N".action = move-window-up; + "Mod+Shift+S".action = move-column-right; + + "Mod+Control+H".action = focus-monitor-left; + "Mod+Control+T".action = focus-monitor-down; + "Mod+Control+N".action = focus-monitor-up; + "Mod+Control+S".action = focus-monitor-right; + + "Mod+Shift+Control+H".action = move-workspace-to-monitor-left; + "Mod+Shift+Control+T".action = move-workspace-to-monitor-down; + "Mod+Shift+Control+N".action = move-workspace-to-monitor-up; + "Mod+Shift+Control+S".action = move-workspace-to-monitor-right; + + "Mod+G".action = focus-workspace-down; + "Mod+C".action = focus-workspace-up; + + "Mod+Control+G".action = move-column-to-workspace-down; + "Mod+Control+C".action = move-column-to-workspace-up; + + "Mod+Shift+G".action = move-workspace-down; + "Mod+Shift+C".action = move-workspace-up; + + "Mod+M".action = consume-window-into-column; + "Mod+W".action = expel-window-from-column; + + "Mod+F".action = maximize-column; + "Mod+Shift+F".action = fullscreen-window; + + "Mod+Space".action = switch-focus-between-floating-and-tiling; + "Mod+Shift+Space".action = toggle-window-floating; + + "Mod+Left".action = set-column-width "-10%"; + "Mod+Down".action = set-window-height "-10%"; + "Mod+Up".action = set-window-height "+10%"; + "Mod+Right".action = set-column-width "+10%"; + + "Mod+Shift+Z" = { + action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors"; + allow-when-locked = true; + }; + + "XF86MonBrightnessUp" = { + action = spawn lightctl "-d" "-e4" "-n1" "up"; + allow-when-locked = true; + }; + "XF86MonBrightnessDown" = { + action = spawn lightctl "-d" "-e4" "-n1" "down"; + allow-when-locked = true; + }; + "XF86AudioRaiseVolume" = { + action = spawn volumectl "-d" "-u" "up"; + allow-when-locked = true; + }; + "XF86AudioLowerVolume" = { + action = spawn volumectl "-d" "-u" "down"; + allow-when-locked = true; + }; + "XF86AudioMute" = { + action = spawn volumectl "-d" "toggle-mute"; + allow-when-locked = true; + }; + "XF86AudioMicMute" = { + action = spawn volumectl "-d" "-m" "toggle-mute"; + allow-when-locked = true; + }; + + "Mod+Semicolon".action = spawn dunstctl "close"; + "Mod+Shift+Semicolon".action = spawn dunstctl "close-all"; + "Mod+Period".action = spawn dunstctl "context"; + "Mod+Comma".action = spawn dunstctl "history-pop"; + }; + }; + }; +} diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix new file mode 100644 index 00000000..1a25b581 --- /dev/null +++ b/accounts/gkleen@sif/niri/waybar.nix @@ -0,0 +1,288 @@ +{ lib, pkgs, ... }: +{ + config = { + programs.waybar = { + enable = true; + systemd = { + enable = true; + target = "graphical-session.target"; + }; + settings = let + windowRewrites = { + "(.*) — Mozilla Firefox" = "$1"; + "(.*) - Mozilla Thunderbird" = "$1"; + "(.*) - mpv" = "$1"; + }; + iconSize = 11; + in [ + { + layer = "top"; + position = "top"; + height = 14; + output = [ "eDP-1" "DP-2" "DP-3" ]; + modules-left = [ "niri/workspaces" ]; + modules-center = [ "niri/window" ]; + modules-right = [ # "custom/worktime" "custom/worktime-today" + "custom/weather" + # "custom/keymap" + "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "clock" ]; + + "custom/weather" = { + format = "{}"; + tooltip = true; + interval = 3600; + exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --nerd --custom-indicator \"{ICON} {FeelsLikeC}°\""; + return-type = "json"; + }; + "custom/keymap" = { + format = "{}"; + tooltip = true; + return-type = "json"; + exec = pkgs.writers.writePython3 "keymap" {} '' + import os + import socket + import re + import subprocess + import json + + + def output(keymap): + short = keymap + if keymap == "English (programmer Dvorak)": + short = "dvp" + elif keymap == "English (US)": + short = "us" + print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501 + + + r = subprocess.run(["hyprctl", "devices", "-j"], check=True, stdout=subprocess.PIPE, text=True) # noqa: E501 + for keyboard in json.loads(r.stdout)['keyboards']: + if keyboard['name'] != "at-translated-set-2-keyboard": + continue + output(keyboard['active_keymap']) + + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + sock.connect(os.environ["XDG_RUNTIME_DIR"] + "/hypr/" + os.environ["HYPRLAND_INSTANCE_SIGNATURE"] + "/.socket2.sock") # noqa: E501 + expected = re.compile(r'^activelayout>>at-translated-set-2-keyboard,(?P.+)$') # noqa: E501 + for line in sock.makefile(buffering=1, encoding='utf-8'): + if match := expected.match(line): + output(match.group("keymap")) + ''; + on-click = "hyprctl switchxkblayout at-translated-set-2-keyboard next"; + }; + "custom/worktime" = { + interval = 60; + exec = lib.getExe pkgs.worktime; + tooltip = false; + }; + "custom/worktime-today" = { + interval = 60; + exec = "${lib.getExe pkgs.worktime} today"; + tooltip = false; + }; + "niri/workspaces" = { + all-outputs = true; + }; + "niri/window" = { + separate-outputs = true; + icon = true; + icon-size = 14; + rewrite = windowRewrites; + }; + clock = { + interval = 1; + # timezone = "Europe/Berlin"; + format = "W{:%V-%u %F %H:%M:%S%Ez}"; + tooltip-format = "{calendar}"; + calendar = { + mode = "year"; + mode-mon-col = 3; + weeks-pos = "left"; + on-scroll = 1; + format = { + months = "{}"; + days = "{}"; + weeks = "{}"; + weekdays = "{}"; + today = "{}"; + }; + }; + }; + battery = { + format = "{icon}"; + icon-size = iconSize - 2; + states = { warning = 30; critical = 15; }; + format-icons = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ]; + format-charging = "󰂄"; + format-plugged = "󰚥"; + tooltip-format = "{capacity}% {timeTo}"; + interval = 20; + }; + tray = { + icon-size = 16; + # show-passive-items = true; + spacing = 1; + }; + privacy = { + icon-spacing = 7; + icon-size = iconSize; + modules = [ + { type = "screenshare"; } + { type = "audio-in"; } + ]; + }; + idle_inhibitor = { + format = "{icon}"; + icon-size = iconSize; + format-icons = { activated = "󰈈"; deactivated = "󰈉"; }; + timeout = 120; + }; + backlight = { + format = "{icon}"; + icon-size = iconSize; + tooltip-format = "{percent}%"; + format-icons = ["󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠"]; + on-scroll-up = "lightctl -d -e4 -n1 up"; + on-scroll-down = "lightctl -d -e4 -n1 down"; + }; + wireplumber = { + format = "{icon}"; + icon-size = iconSize; + tooltip-format = "{volume}% {node_name}"; + format-icons = ["󰕿" "󰖀" "󰕾"]; + format-muted = "󰝟"; + # ignored-sinks = ["Easy Effects Sink"]; + on-scroll-up = "volumectl -d -u up"; + on-scroll-down = "volumectl -d -u down"; + on-click = "volumectl -d toggle-mute"; + }; + } + { + layer = "top"; + position = "top"; + height = 14; + output = [ "!eDP-1" "!DP-2" "!DP-3" ]; + modules-left = [ "niri/workspaces" ]; + modules-center = [ "niri/window" ]; + modules-right = [ "clock" ]; + + "niri/workspaces" = { + all-outputs = false; + }; + "niri/window" = { + separate-outputs = true; + icon = true; + icon-size = 14; + rewrite = windowRewrites; + }; + clock = { + interval = 1; + # timezone = "Europe/Berlin"; + format = "{:%H:%M}"; + tooltip-format = "W{:%V-%u %F %H:%M:%S%Ez}"; + }; + } + ]; + style = '' + @define-color white #ffffff; + @define-color grey #555555; + @define-color blue #1a8fff; + @define-color green #23fd00; + @define-color orange #f28a21; + @define-color red #f2201f; + + * { + border: none; + font-family: "Fira Sans Nerd Font"; + font-size: 10pt; + min-height: 0; + } + + window#waybar { + background-color: rgba(0, 0, 0, 0.66); + color: @white; + } + + .modules-left { + margin-left: 9px; + } + .modules-right { + margin-right: 9px; + } + + .module { + margin: 0 5px; + } + + #workspaces button { + color: @grey; + } + #workspaces button.hosting-monitor { + color: @white; + } + #workspaces button.visible { + color: @blue; + } + #workspaces button.active { + color: @green; + } + #workspaces button.urgent { + color: @red; + } + + #custom-weather, #custom-keymap, #custom-worktime, #custom-worktime-today { + color: @grey; + margin: 0 5px; + } + #custom-weather, #custom-worktime-today { + margin-right: 3px; + } + #custom-keymap, #custom-weather { + margin-left: 3px; + } + + #tray { + margin: 0; + } + #battery, #idle_inhibitor, #backlight, #wireplumber { + color: @grey; + margin: 0 5px 0 2px; + } + #idle_inhibitor { + margin-right: 2px; + margin-left: 3px; + } + #battery { + margin-right: 3px; + } + #battery.discharging { + color: @white; + } + #battery.warning { + color: @orange; + } + #battery.critical { + color: @red; + } + #battery.charging { + color: @white; + } + #idle_inhibitor.activated { + color: @white; + } + + #idle_inhibitor { + padding-top: 1px; + } + + #privacy { + color: @red; + margin: -1px 2px 0px 5px; + } + #clock { + /* margin-right: 5px; */ + } + ''; + }; + }; +} -- cgit v1.2.3