user/eww: init

This commit is contained in:
LavaDesu 2022-03-22 23:50:53 +07:00
parent ed93b93c43
commit 5a4b56580b
Signed by: cilly
GPG key ID: 6500251E087653C9
12 changed files with 202 additions and 3 deletions

View file

@ -42,6 +42,7 @@ in {
./user/bspwm.nix ./user/bspwm.nix
./user/direnv.nix ./user/direnv.nix
./user/dunst.nix ./user/dunst.nix
./user/eww.nix
./user/git.nix ./user/git.nix
./user/gpg.nix ./user/gpg.nix
./user/kitty.nix ./user/kitty.nix

View file

@ -1,3 +1,4 @@
# Depends on eww
{ config, pkgs, ... }: { { config, pkgs, ... }: {
xsession.windowManager.bspwm = { xsession.windowManager.bspwm = {
enable = true; enable = true;
@ -6,11 +7,13 @@
window_gap = 10; window_gap = 10;
border_width = 0; border_width = 0;
split_ratio = 0.5; split_ratio = 0.5;
top_padding = 25; top_padding = 35;
}; };
extraConfig = '' extraConfig = ''
${pkgs.feh}/bin/feh --no-fehbg --bg-fill ~/Pictures/Wallpapers/current ${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
''; '';
}; };
} }

8
modules/user/eww.nix Normal file
View file

@ -0,0 +1,8 @@
# Depends on bspwm
{ pkgs, ... }: {
home.packages = with pkgs; [ xtitle ];
programs.eww = {
enable = true;
configDir = ../../res/eww;
};
}

View file

@ -1,5 +1,6 @@
builtins.map (path: import path) [ builtins.map (path: import path) [
./discord.nix ./discord.nix
./eww.nix
./material-icons.nix ./material-icons.nix
./picom.nix ./picom.nix
./polymc.nix ./polymc.nix

18
overlays/eww.nix Normal file
View file

@ -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;
};
});
}

49
res/eww/eww.scss Normal file
View file

@ -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;
}
}

58
res/eww/eww.yuck Normal file
View file

@ -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 : ""})
)))

3
res/eww/scripts/scroll.sh Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env sh
translated=$([ "$1" == "up" ] && echo "prev" || echo "next")
bspc desktop -f $translated

10
res/eww/scripts/title.sh Executable file
View file

@ -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

47
res/eww/scripts/workspaces.sh Executable file
View file

@ -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

View file

@ -34,8 +34,8 @@
rofi rofi
dunst dunst
eww
picom picom
polybar
xorg xorg
sxhkd sxhkd

View file

@ -56,6 +56,7 @@ in {
] ++ lib.optionals enableGUI [ ] ++ lib.optionals enableGUI [
discord discord
element-desktop element-desktop
eww
feh feh
gnome.file-roller gnome.file-roller
gimp gimp