diff --git a/modules/default.nix b/modules/default.nix index 4c4da77..bc442dc 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -50,6 +50,7 @@ in { ./user/direnv.nix ./user/dunst.nix ./user/eww.nix + ./user/eww-wayland.nix ./user/git.nix ./user/gpg.nix ./user/kitty.nix @@ -63,6 +64,7 @@ in { ./user/picom.nix ./user/polybar.nix ./user/rofi.nix + ./user/rofi-wayland.nix ./user/sessionVariables.nix ./user/spicetify.nix ./user/sxhkd.nix diff --git a/modules/system/greetd.nix b/modules/system/greetd.nix index 2958926..4e2a41f 100644 --- a/modules/system/greetd.nix +++ b/modules/system/greetd.nix @@ -3,7 +3,7 @@ enable = true; settings = { default_session = { - command = "${pkgs.greetd.tuigreet}/bin/tuigreet --remember --asterisks --time --cmd 'zsh -c \"source $HOME/.config/zsh/.zshrc && startx\"'"; + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --remember --asterisks --time --cmd 'zsh -c \"source $HOME/.config/zsh/.zshrc && Hyprland > $XDG_RUNTIME_DIR/Hyprland.out\"'"; user = "greeter"; }; }; diff --git a/modules/user/eww-wayland.nix b/modules/user/eww-wayland.nix new file mode 100644 index 0000000..e939a1f --- /dev/null +++ b/modules/user/eww-wayland.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: { + home.packages = with pkgs; [ socat ]; + programs.eww = { + enable = true; + configDir = ../../res/eww-wayland; + }; +} diff --git a/modules/user/rofi-wayland.nix b/modules/user/rofi-wayland.nix new file mode 100644 index 0000000..6bb85a0 --- /dev/null +++ b/modules/user/rofi-wayland.nix @@ -0,0 +1,8 @@ +{ config, pkgs, ... }: { + programs.rofi = { + enable = true; + package = pkgs.rofi-wayland; + theme = "theme"; + }; + xdg.configFile."rofi/theme.rasi".source = ../../res/theme.rasi; +} diff --git a/overlays/eww.nix b/overlays/eww.nix index 8d89aa1..bea0aec 100644 --- a/overlays/eww.nix +++ b/overlays/eww.nix @@ -1,5 +1,5 @@ self: super: { - eww = super.eww.overrideAttrs (old: rec { + eww = (super.eww.override { withWayland = true; }).overrideAttrs (old: rec { patches = old.patches ++ [ # Use normal scroll events instead of smooth scroll ( due to https://bugzilla.gnome.org/show_bug.cgi?id=675959 ) ./patches/eww.patch diff --git a/res/eww-wayland/eww.scss b/res/eww-wayland/eww.scss new file mode 100644 index 0000000..08b2270 --- /dev/null +++ b/res/eww-wayland/eww.scss @@ -0,0 +1,72 @@ +$background: #1a1b26; +$accent: #9d7cd8; +$foreground: #c0caf5; + +* { + all: unset; +} + +window { + background: transparent; +} + +.bar { + margin: 5px 20px 0px 20px; +} + +.widget { + background: $background; + color: $foreground; + font-family: "Noto Sans"; + font-weight: 600; + font-size: 15px; + padding: 5px 15px; + border-radius: 50px; +} + +.time { + .base { + font-weight: 700; + } + .extension { + font-weight: 500; + color: rgba($foreground, .7); + } +} + +.workspaces { + padding: 5px 10px; + font-size: 22px; + + button { + padding: 0px 2px; + } + + .empty, .occupied { + color: $accent; + } +} + +.widget.line-workspaces { + color: transparent; + padding: 0; + border-radius: 0; + font-size: 0; + + button { + padding: 0 13px; + } + + .empty { + background-color: $background; + } + + .occupied { + background-color: $accent; + } + + .focused { + background-color: $foreground; + } +} + diff --git a/res/eww-wayland/eww.yuck b/res/eww-wayland/eww.yuck new file mode 100644 index 0000000..6a89d2b --- /dev/null +++ b/res/eww-wayland/eww.yuck @@ -0,0 +1,67 @@ +(defwindow mainbar :monitor 0 + :geometry (geometry :x "0%" + :y "0%" + :width "100%" + :height "30px" + :anchor "top center") + :stacking "fg" + :exclusive false + :focusable false + (bar)) + +(defvar time-extended false) ; for :run-while property of below variable + ; when this turns true, the polling starts and + ; var gets updated with given interval + +(defpoll ptime :interval "1s" + :run-while !time-extended + `date +%H:%M`) +(defpoll petimea :interval "1s" + :run-while time-extended + `date "+%A, %d %B %Y "`) +(defpoll petimeb :interval "1s" + :run-while time-extended + `date "+:%S"`) + +(deflisten ltitle "./scripts/title.sh") +(deflisten lworkspaces :initial "[]" "./scripts/workspaces.sh") +(deflisten lcurrent_workspace :initial "1" "./scripts/active-workspace.sh") + +(defwidget bar [] + (eventbox :onscroll "./scripts/scroll.sh {}" + (centerbox :orientation "h" + :class "bar" + (workspaces) + (title) + (time)))) + +(defwidget workspaces [] + (box :class "widget workspaces" + :halign "start" + :valign "center" + :vexpand true + :hexpand true + (for workspace in lworkspaces + (eventbox :cursor "hand" + (button :class "${workspace.id == lcurrent_workspace ? "focused" : (workspace.windows > 0 ? "occupied" : "empty")}" + :onclick "hyprctl dispatch workspace ${workspace.id}" + "${workspace.id == lcurrent_workspace ? "" : (workspace.windows > 0 ? "" : "")}"))))) + +(defwidget title [] + (literal :content ltitle)) + +(defwidget time_extension [text] + (label :text text + :class "extension")) + +(defwidget time [] + (button :onclick `eww update time-extended=${time-extended ? "false" : "true"}` + (box :orientation "horizontal" + :space-evenly false + :halign "end" + :class "widget time" + (time_extension :text {time-extended ? petimea : ""}) + (label :text ptime + :class "base") + (time_extension :text {time-extended ? petimeb : ""})))) + diff --git a/res/eww-wayland/scripts/active-workspace.sh b/res/eww-wayland/scripts/active-workspace.sh new file mode 100755 index 0000000..cbdf971 --- /dev/null +++ b/res/eww-wayland/scripts/active-workspace.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id' + +socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | + stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}' diff --git a/res/eww-wayland/scripts/title.sh b/res/eww-wayland/scripts/title.sh new file mode 100755 index 0000000..baaffdf --- /dev/null +++ b/res/eww-wayland/scripts/title.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +out () { + if [ -z "$1" ]; then + echo "" + else + echo "(box :class \"widget title\" :halign \"center\" :valign \"center\" :vexpand true :hexpand true (label :text \"$1\"))" + fi +} + +init=$(hyprctl activewindow -j | jq --raw-output .title) +out "$init" + +socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}' | while read -r line ; do + trunc=$(echo $line | cut -c-85) + out "$trunc" +done diff --git a/res/eww-wayland/scripts/workspaces.sh b/res/eww-wayland/scripts/workspaces.sh new file mode 100755 index 0000000..a496f8f --- /dev/null +++ b/res/eww-wayland/scripts/workspaces.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +spaces (){ + WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries') + seq 1 10 | jq --argjson windows "${WORKSPACE_WINDOWS}" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})' +} + +spaces +socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do + spaces +done diff --git a/users/rin/default.nix b/users/rin/default.nix index 3734f52..78bdd09 100644 --- a/users/rin/default.nix +++ b/users/rin/default.nix @@ -2,7 +2,7 @@ programs.zsh.enable = true; users.users.rin = { isNormalUser = true; - extraGroups = [ "adbusers" "audio" "corectrl" "libvirtd" "video" "wheel" ]; + extraGroups = [ "adbusers" "audio" "corectrl" "libvirtd" "networkmanager" "video" "wheel" ]; shell = pkgs.zsh; uid = 1001; passwordFile = config.age.secrets.passwd.path; @@ -33,18 +33,14 @@ kitty mpv obs - rofi - spicetify + rofi-wayland dunst - eww - picom - - xorg - sxhkd - bspwm + eww-wayland ]; + services.mpris-proxy.enable = true; + home.file.".local/bin/ipc-bridge.exe".source = builtins.fetchurl { url = "https://github.com/0e4ef622/wine-discord-ipc-bridge/releases/download/v0.0.1/winediscordipcbridge.exe"; sha256 = "1swn9spxpq6blm74kjmfz4ipq6a8qjzccvb2msb25pf5b1z7jnns";