diff --git a/modules/default.nix b/modules/default.nix index 255b9e2..ed774ca 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -42,6 +42,7 @@ in { ./user/bspwm.nix ./user/direnv.nix ./user/dunst.nix + ./user/eww.nix ./user/git.nix ./user/gpg.nix ./user/kitty.nix diff --git a/modules/user/bspwm.nix b/modules/user/bspwm.nix index 0768db6..dbeef3d 100644 --- a/modules/user/bspwm.nix +++ b/modules/user/bspwm.nix @@ -1,3 +1,4 @@ +# Depends on eww { config, pkgs, ... }: { xsession.windowManager.bspwm = { enable = true; @@ -6,11 +7,13 @@ window_gap = 10; border_width = 0; split_ratio = 0.5; - top_padding = 25; + top_padding = 35; }; extraConfig = '' ${pkgs.feh}/bin/feh --no-fehbg --bg-fill ~/Pictures/Wallpapers/current - systemctl --user restart polybar # home-manager loads this too early + + ${pkgs.procps}/bin/pkill -SIGINT eww + ${pkgs.eww}/bin/eww open mainbar ''; }; } diff --git a/modules/user/eww.nix b/modules/user/eww.nix new file mode 100644 index 0000000..b0a8099 --- /dev/null +++ b/modules/user/eww.nix @@ -0,0 +1,8 @@ +# Depends on bspwm +{ pkgs, ... }: { + home.packages = with pkgs; [ xtitle ]; + programs.eww = { + enable = true; + configDir = ../../res/eww; + }; +} diff --git a/overlays/default.nix b/overlays/default.nix index 51fe262..fe9b25e 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,5 +1,6 @@ builtins.map (path: import path) [ ./discord.nix + ./eww.nix ./material-icons.nix ./picom.nix ./polymc.nix diff --git a/overlays/eww.nix b/overlays/eww.nix new file mode 100644 index 0000000..466608c --- /dev/null +++ b/overlays/eww.nix @@ -0,0 +1,18 @@ +self: super: { + # Mainly for https://github.com/elkowar/eww/pull/280 + eww = super.eww.overrideAttrs (old: rec { + version = "unstable-fb0e57a"; + src = self.fetchFromGitHub { + owner = "elkowar"; + repo = "eww"; + rev = "fb0e57a0149904e76fb33807a2804d4af82350de"; + sha256 = "089rvcswr0wy05fac8xbfrws1qacqi3iialpv8sai7mzlpsw21m0"; + }; + cargoSha256 = "1s7rxilqis2nbvjqjp5zarvmr9g6ndcicyx1rilgjv34qwna3mz1"; + cargoDeps = self.rustPlatform.fetchCargoTarball { + inherit src; + name = "${old.pname}-${version}"; + sha256 = cargoSha256; + }; + }); +} diff --git a/res/eww/eww.scss b/res/eww/eww.scss new file mode 100644 index 0000000..885b761 --- /dev/null +++ b/res/eww/eww.scss @@ -0,0 +1,49 @@ +$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; + } +} + diff --git a/res/eww/eww.yuck b/res/eww/eww.yuck new file mode 100644 index 0000000..b3d0208 --- /dev/null +++ b/res/eww/eww.yuck @@ -0,0 +1,58 @@ +(defwindow mainbar :monitor 0 + :geometry (geometry :x "0%" + :y "0%" + :width "100%" + :height "30px" + :anchor "top center") + :stacking "fg" + :windowtype "dock" + :wm-ignore 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 lworkspaces "./scripts/workspaces.sh") +(deflisten ltitle "./scripts/title.sh") + +(defwidget bar [] + (eventbox :onscroll "./scripts/scroll.sh {}" + (centerbox :orientation "h" + :class "bar" + (workspaces) + (title) + (time)))) + +(defwidget workspaces [] + (literal :content lworkspaces)) + +(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/scripts/scroll.sh b/res/eww/scripts/scroll.sh new file mode 100755 index 0000000..f76b6b0 --- /dev/null +++ b/res/eww/scripts/scroll.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh +translated=$([ "$1" == "up" ] && echo "prev" || echo "next") +bspc desktop -f $translated diff --git a/res/eww/scripts/title.sh b/res/eww/scripts/title.sh new file mode 100755 index 0000000..26664ba --- /dev/null +++ b/res/eww/scripts/title.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +xtitle -s | while read -r line ; do + trunc=$(echo $line | cut -c-85) + if [ -z "$line" ]; then + echo "" + else + echo "(box :class \"widget title\" :halign \"center\" :valign \"center\" :vexpand true :hexpand true (label :text \"${trunc}\"))" + fi +done diff --git a/res/eww/scripts/workspaces.sh b/res/eww/scripts/workspaces.sh new file mode 100755 index 0000000..3eb9b52 --- /dev/null +++ b/res/eww/scripts/workspaces.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env sh + +# Checks if a list ($1) contains an element ($2) +contains() { + for e in $1; do + [ "$e" -eq "$2" ] && echo 1 && return + done + echo 0 +} + +print_workspaces() { + buf="" + desktops=$(bspc query -D --names) + focused_desktop=$(bspc query -D -d focused --names) + occupied_desktops=$(bspc query -D -d .occupied --names) + urgent_desktops=$(bspc query -D -d .urgent --names) + + for d in $desktops; do + if [ "$(contains "$focused_desktop" "$d")" -eq 1 ]; then + ws=$d + icon="" + class="focused" + elif [ "$(contains "$occupied_desktops" "$d")" -eq 1 ]; then + ws=$d + icon="" + class="occupied" + elif [ "$(contains "$urgent_desktops" "$d")" -eq 1 ]; then + ws=$d + icon="" + class="urgent" + else + ws=$d + icon="" + class="empty" + fi + + buf="$buf (eventbox :cursor \"hand\" (button :class \"$class\" :onclick \"bspc desktop -f $ws\" \"$icon\"))" + done + + echo "(box :class \"widget workspaces\" :halign \"start\" :valign \"center\" :vexpand true :hexpand true $buf)" +} + +# Listen to bspwm changes +print_workspaces +bspc subscribe desktop node_transfer | while read -r _ ; do + print_workspaces +done diff --git a/users/rin/default.nix b/users/rin/default.nix index e830032..e453d61 100644 --- a/users/rin/default.nix +++ b/users/rin/default.nix @@ -34,8 +34,8 @@ rofi dunst + eww picom - polybar xorg sxhkd diff --git a/users/rin/packages.nix b/users/rin/packages.nix index 91a7e61..5004694 100644 --- a/users/rin/packages.nix +++ b/users/rin/packages.nix @@ -56,6 +56,7 @@ in { ] ++ lib.optionals enableGUI [ discord element-desktop + eww feh gnome.file-roller gimp