Eww work + continued debugging for layoutmenu

- Added eww config
- Added a new statusbutton (non-working for now)
This commit is contained in:
Alexis Jhon Gaspar 2023-09-26 22:47:00 +08:00
parent fd8c72b9cb
commit 80bb3844e6
15 changed files with 387 additions and 4 deletions

View file

@ -173,4 +173,5 @@ All programs are licensed under the MIT License, except for some submodules, whi
* [GitHub](https://github.com/Lucas-mother3/suckless-utils) - Main mirror
* [GitLab](https://gitlab.com/Lucas-mother3/suckless-utils) - Secondary (and backup)
* [BitBucket](https://bitbucket.org/Lucas-mother3/suckless-utils) - Secondary backup
* [Codeberg](https://codeberg.org/Lucas-mother3/suckless-utils) - Tritary backup
* [speedie.site](https://git.speedie.site/Lucas-mother3/suckless-utils) - Mirror of gitlab

8
config/eww/README Normal file
View file

@ -0,0 +1,8 @@
Please link your scss wal config here
use:
ln $HOME/.cache/wal/colors.scss $HOME/.config/eww/colors.scss
Also please install the scripts in ../scripts/eww to $PATH

90
config/eww/eww.scss Normal file
View file

@ -0,0 +1,90 @@
/** Colors *******************************************/
@import 'colors.scss'
* {
font-family: "Hack Nerd Font";
}
.main {
background-color: $color0;
padding: 1em;
margin: 0.5em;
}
.date-box {
background-color: $color6;
color: $color0;
padding: 0.9em;
}
.spacer {
padding: 0.5rem;
background-color: $color0;
}
.time {
font-size: 3rem;
}
.date {
font-size: 1.2rem;
}
.title, .album, .artist {
color: $color0;
font-size: 1rem;
}
.title, .album, .artist {
color: $color0;
font-size: 1rem;
}
.music-box{
background-color: $color6;
padding: 0.9em;
}
.weather-box{
background-color: $color0;
}
.weather-icon {
background-color: $color6;
padding: 1em;
}
.weather-forecast {
color: $color0;
background-color: $color6;
padding: 1rem;
padding-right: 7em;
}
.weather-icon-text {
color: $color0;
font-size: 2em;
margin: 1rem;
margin-right: 0rem;
}
.ram-box, .cpu-box {
background-color: $color6;
padding: 1em;
}
.ram-radial, .cpu-radial {
color: $color0;
background-color: $color5;
}
.ram-radial-label {
font-size: 2em;
padding: 3rem;
margin-left: 0.25rem;
margin-right: 0.75rem;
}
.cpu-radial-label {
font-size: 2em;
padding: 3rem;
margin-right: 0.75rem;
}
.weather-location {
font-size: 1.25rem;
}
.weather-temp {
font-size: 2rem;
font-weight: bold;
}
.notification {
font-weight: bold;
color: $color0;
}

152
config/eww/eww.yuck Normal file
View file

@ -0,0 +1,152 @@
(defpoll time :interval "1s" "date '+%I:%M:%S'")
(defpoll date :interval "1s" "date '+%B %d, %Y'")
(defpoll time2 :interval "1s" "TZ=UTC date '+%I:%M %B %d (%Z)'")
(defpoll title :interval "1s" "eww-music")
(defpoll artist :interval "1s" "eww-artist")
(defpoll album :interval "1s" "eww-album")
(defpoll distro :interval "1s" "printf '󱅿 : ' && cat /etc/os-release | grep 'NAME=' | head -n 1 | sed -e 's/NAME=//g' -e 's/\"//g'")
(defpoll kernel :interval "1s" "printf ' : ' && uname -r")
(defpoll cpu :interval "1s" "printf ' : ' && lscpu | grep 'Model name:' | sed 's/Model name: //g' | head -c 25")
(defpoll gpu :interval "1s" "printf '󰍹 : ' && glxinfo -B | grep 'OpenGL renderer string' | sed 's/OpenGL renderer string: //g' | head -c 25")
(defpoll wm :interval "1s" "printf ' : ' && wmctrl -m | grep 'Name: ' | sed 's/Name: //g'")
; (defpoll weather-icon :interval "1s" "curl -s wttr.in/Gapan?format='%c'")
; (defpoll weather-location :interval "1s" "curl -s wttr.in/Gapan?format='%l'")
; (defpoll weather-temp :interval "1s" "curl -s wttr.in/Gapan?format='%t'")
(defvar weather-temp "+34°C")
(defvar weather-location "Gapan, NE")
(defvar weather-icon "☁")
(defvar notification "Notifications")
(defpoll notification-history :interval "1s" "printf 'In history: ' && dunstctl count history")
(defpoll notification-display :interval "1s" "printf 'Currently Displayed: ' && dunstctl count displayed")
(defpoll notification-summary :interval "1s" "printf 'Last notification:\\n' && dunstctl history | jq '.data[] | .[] | .summary | .data' | head -n 1 | sed 's/\"//g' ")
(defpoll quoter-text :interval "10s" "quoter | fold -w 30")
(defwidget datetime []
(box :class "date-box" :space-evenly "false" :orientation "v"
(label :class "time" :text time)
(label :class "date" :text date)
(label :class "date" :text time2)
)
)
(defwidget music[]
(box :class "music-box" :space-evenly "false" :orientation "v"
(label :class "title" :text title)
(label :class "artist" :text artist)
(label :class "album" :text album)
)
)
(defwidget fetch[]
(box :class "music-box" :space-evenly "false" :orientation "v"
(label :class "title" :text distro :xalign 0)
(label :class "artist" :text kernel :xalign 0)
(label :class "album" :text cpu :xalign 0)
(label :class "album" :text gpu :xalign 0)
(label :class "album" :text wm :xalign 0)
)
)
(defwidget quoter[]
(box :class "music-box" :space-evenly "false" :orientation "v"
(label :class "title" :text quoter-text :xalign 0)
)
)
(defwidget notifications[]
(box :class "music-box" :space-evenly "false" :orientation "v"
(label :class "notification" :text notification)
(label :class "artist" :text notification-history :xalign 0)
(label :class "album" :text notification-display :xalign 0)
(label :class "album" :text notification-summary :xalign 0)
)
)
(defwidget weather[]
(box :class "weather-box" :space-evenly "false" :orientation "h"
(box :class "weather-icon" :space-evenly "false" :orientation "v"
(label :class "weather-icon-text" :text weather-icon)
)
(box :class "spacer" :space-evenly "false" :orientation "v")
(box :class "weather-forecast" :space-evenly "false" :orientation "v"
(label :class "weather-location" :text weather-location :xalign 0)
(label :class "weather-temp" :text weather-temp :xalign 0)
)
)
)
(defwidget ram []
(box :class "ram-box" :space-evenly "false" :orientation "v"
(circular-progress :class "ram-radial"
:value "${EWW_RAM.used_mem_perc}"
:thickness 10
:clockwise "true"
:tooltip "Used RAM: ${EWW_RAM.used_mem_perc}%"
(label
:class "ram-radial-label"
:text ""
:valign "center"
:halign "center"))))
(defwidget cpu []
(box :class "cpu-box" :space-evenly "false" :orientation "v"
(circular-progress :class "cpu-radial"
:value "${EWW_CPU.avg}"
:thickness 10
:clockwise "true"
:tooltip "CPU Usage: ${EWW_CPU.avg}%"
(label
:class "cpu-radial-label"
:text ""
:valign "center"
:halign "center"))))
(defwidget spacer[]
(box :class "spacer" :space-evenly "false" :orientation "v")
)
(defwidget main []
(box :class "main" :space-evenly "false" :orientation "v"
(box :class "top-row" :space-evenly "false" :orientation "v"
(datetime)
(spacer)
(music)
(spacer)
)
(box :class "middle-row" :space-evenly "false" :orientation "h" :halign "center"
(ram)
(spacer)
(cpu)
)
(box :class "bottom-row" :space-evenly "false" :orientation "v" :halign "center"
(spacer)
(fetch)
(spacer)
(weather)
(spacer)
(notifications)
(spacer)
(quoter)
)
)
)
(defwindow main
:monitor 0
:geometry (geometry
:x "-30px"
:y "0%"
:width "15%"
:height "94%"
:anchor "center right")
:stacking "fg"
:reserve (struts :distance "40px" :side "top")
:windowtype "desktop"
:wm-ignore false
(main))

View file

@ -6,5 +6,7 @@ picom -b # launches compositor
/usr/bin/dunst & # launches dunst daemon
paplay /usr/share/sounds/Oxygen-Sys-Special.ogg # autoplay sound, optional
nm-applet & # optional, launch network-manager applet
/usr/local/bin/eww daemon & # launch eww in start up, assumes eww is copied to $PATH
/usr/local/bin/eww open main & # make sure the config is copied
nemo-desktop & # launch nemo in desktop mode, to provide desktop icons, optional
exec /usr/local/bin/dwm # launch dwm

View file

@ -97,6 +97,7 @@ static const int vertpadbar = 0; /* vertical padding for statusba
static const char buttonbar[] = "󰕰 Start";
static const char buttonbar2[] = " st";
static const char buttonbar3[] = " Firefox";
static const char buttonbar4[] = "Layouts";
#endif // BAR_STATUSBUTTON_PATCH
#if BAR_SYSTRAY_PATCH
static const unsigned int systrayspacing = 2; /* systray spacing */
@ -502,8 +503,7 @@ static const Rule rules[] = {
RULE(.wintype = WTYPE "TOOLBAR", .isfloating = 1)
RULE(.wintype = WTYPE "SPLASH", .isfloating = 1)
RULE(.class = "Gimp", .tags = 1 << 4)
RULE(.class = "Firefox", .tags = 1 << 7)
RULE(.class = "Eww", .unmanaged = 0)
RULE(.class = "Firefox", .tags = 1 << 7)
#if RENAMED_SCRATCHPADS_PATCH
RULE(.instance = "spterm", .scratchkey = 's', .isfloating = 1)
#elif SCRATCHPADS_PATCH
@ -573,6 +573,9 @@ static const BarRule barrules[] = {
#if BAR_LTSYMBOL_PATCH
{ -1, 0, BAR_ALIGN_LEFT, width_ltsymbol, draw_ltsymbol, click_ltsymbol, NULL, "layout" },
#endif // BAR_LTSYMBOL_PATCH
#if BAR_STATUSBUTTON_PATCH
{ -1, 0, BAR_ALIGN_LEFT, width_stbutton4, draw_stbutton4, click_stbutton4, NULL, "statusbutton4" },
#endif // BAR_STATUSBUTTON_PATCH
#if BAR_STATUSCOLORS_PATCH && BAR_STATUSCMD_PATCH
{ statusmon, 0, BAR_ALIGN_RIGHT, width_statuscolors, draw_statuscolors, click_statuscmd, NULL, "statuscolors" },
#elif BAR_STATUSCOLORS_PATCH
@ -1372,7 +1375,7 @@ static const Button buttons[] = {
#endif // BAR_STATUSBUTTON_PATCH
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
#if BAR_LAYOUTMENU_PATCH
{ ClkLtSymbol, 0, Button3, layoutmenu, {0} },
{ ClkButton4, 0, Button1, layoutmenu, {0} },
#else
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
#endif // BAR_LAYOUTMENU_PATCH

View file

@ -234,6 +234,7 @@ enum {
ClkButton,
ClkButton2,
ClkButton3,
ClkButton4,
#endif // BAR_STATUSBUTTON_PATCH
#if TAB_PATCH
ClkTabBar,

View file

@ -50,3 +50,20 @@ click_stbutton3(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton3;
}
int
width_stbutton4(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar4);
}
int
draw_stbutton4(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar4, 0, False);
}
int
click_stbutton4(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton4;
}

View file

@ -7,3 +7,6 @@ static int click_stbutton2(Bar *bar, Arg *arg, BarArg *a);
static int width_stbutton3(Bar *bar, BarArg *a);
static int draw_stbutton3(Bar *bar, BarArg *a);
static int click_stbutton3(Bar *bar, Arg *arg, BarArg *a);
static int width_stbutton4(Bar *bar, BarArg *a);
static int draw_stbutton4(Bar *bar, BarArg *a);
static int click_stbutton4(Bar *bar, Arg *arg, BarArg *a);

View file

@ -74,7 +74,7 @@
* - The text of the menu items is for display only. Name them however you want.
* https://dwm.suckless.org/patches/layoutmenu/
*/
#define BAR_LAYOUTMENU_PATCH 1
#define BAR_LAYOUTMENU_PATCH 1
/* Show layout symbol in bar */
#define BAR_LTSYMBOL_PATCH 1

30
scripts/eww/eww-album Executable file
View file

@ -0,0 +1,30 @@
#!/bin/sh
# Display currently playing music metadata.
if status="$(playerctl "$@" status 2>&1)" && [ "$status" != "Stopped" ]; then
[ "$status" = "Paused" ] && icon="$pausedIcon"
playerctl="$(playerctl "$@" metadata --format "{{album}}" | sed 's/\(.\{25\}\).*/\1.../')"
else
[ "$(mpc status "%state%")" = "paused" ] && icon="$pausedIcon"
mpd="$(mpc current -f "%album%" | sed 's/\(.\{25\}\).*/\1.../')"
fi
if [ -z "$(mpc current -f "%album%")" ]; then
currentSong="Let's go party!"
else
currentSong="$mpd"
fi
if [ "$status" = "No players found" ]; then
if [ -z "$mpd" ]; then
currentSong="Let's go party!"
else
currentSong="$mpd"
fi
else
currentSong="$playerctl"
fi
[ -z "currentSong" ] && exit
echo "$currentSong"

30
scripts/eww/eww-artist Executable file
View file

@ -0,0 +1,30 @@
#!/bin/sh
# Display currently playing music metadata.
if status="$(playerctl "$@" status 2>&1)" && [ "$status" != "Stopped" ]; then
[ "$status" = "Paused" ] && icon="$pausedIcon"
playerctl="$(playerctl "$@" metadata --format "{{artist}}" | sed 's/\(.\{25\}\).*/\1.../')"
else
[ "$(mpc status "%state%")" = "paused" ] && icon="$pausedIcon"
mpd="$(mpc current -f "%artist%" | sed 's/\(.\{25\}\).*/\1.../')"
fi
if [ -z "$(mpc current -f "%artist%")" ]; then
currentSong="Try playing something"
else
currentSong="$mpd"
fi
if [ "$status" = "No players found" ]; then
if [ -z "$mpd" ]; then
currentSong="Try playing something"
else
currentSong="$mpd"
fi
else
currentSong="$playerctl"
fi
[ -z "currentSong" ] && exit
echo "$currentSong"

30
scripts/eww/eww-music Executable file
View file

@ -0,0 +1,30 @@
#!/bin/sh
# Display currently playing music metadata.
if status="$(playerctl "$@" status 2>&1)" && [ "$status" != "Stopped" ]; then
[ "$status" = "Paused" ] && icon="$pausedIcon"
playerctl="$(playerctl "$@" metadata --format "{{title}}" | sed 's/\(.\{25\}\).*/\1.../')"
else
[ "$(mpc status "%state%")" = "paused" ] && icon="$pausedIcon"
mpd="$(mpc current -f "%title%" | sed 's/\(.\{25\}\).*/\1.../')"
fi
if [ -z "$(mpc current -f "%title%")" ]; then
currentSong="Nothing is playing :/"
else
currentSong="$mpd"
fi
if [ "$status" = "No players found" ]; then
if [ -z "$mpd" ]; then
currentSong="Nothing is playing :/"
else
currentSong="$mpd"
fi
else
currentSong="$playerctl"
fi
[ -z "currentSong" ] && exit
echo "$currentSong"

2
scripts/eww/messages.txt Normal file
View file

@ -0,0 +1,2 @@
change me!
put me in the homedir!

14
scripts/eww/quoter Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
# Quoter, the randomly generated quotes maker
# It reads messages off a file called "messages.txt"
# If it doesn't exists on the same dir as the script, it'll fail.
# Setting vars
file=$HOME/messages.txt
count=$(wc -l $file | awk '{print $1}')
number=$((1 + $RANDOM % $count))
quote=$(sed -n $number\p $file)
echo "Random quote: $quote"