From 80bb3844e625f4230a38093393f9e39976e1efb8 Mon Sep 17 00:00:00 2001 From: Alexis Jhon Gaspar Date: Tue, 26 Sep 2023 22:47:00 +0800 Subject: [PATCH] Eww work + continued debugging for layoutmenu - Added eww config - Added a new statusbutton (non-working for now) --- README.md | 1 + config/eww/README | 8 ++ config/eww/eww.scss | 90 ++++++++++++++ config/eww/eww.yuck | 152 ++++++++++++++++++++++++ desktop/startdwm | 2 + dwm-flexipatch/config.def.h | 9 +- dwm-flexipatch/dwm.c | 1 + dwm-flexipatch/patch/bar_statusbutton.c | 17 +++ dwm-flexipatch/patch/bar_statusbutton.h | 3 + dwm-flexipatch/patches.def.h | 2 +- scripts/eww/eww-album | 30 +++++ scripts/eww/eww-artist | 30 +++++ scripts/eww/eww-music | 30 +++++ scripts/eww/messages.txt | 2 + scripts/eww/quoter | 14 +++ 15 files changed, 387 insertions(+), 4 deletions(-) create mode 100644 config/eww/README create mode 100644 config/eww/eww.scss create mode 100644 config/eww/eww.yuck create mode 100755 scripts/eww/eww-album create mode 100755 scripts/eww/eww-artist create mode 100755 scripts/eww/eww-music create mode 100644 scripts/eww/messages.txt create mode 100755 scripts/eww/quoter diff --git a/README.md b/README.md index 8601e6a..f77fcf3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config/eww/README b/config/eww/README new file mode 100644 index 0000000..357c8a0 --- /dev/null +++ b/config/eww/README @@ -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 diff --git a/config/eww/eww.scss b/config/eww/eww.scss new file mode 100644 index 0000000..63b85e3 --- /dev/null +++ b/config/eww/eww.scss @@ -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; +} diff --git a/config/eww/eww.yuck b/config/eww/eww.yuck new file mode 100644 index 0000000..c50982f --- /dev/null +++ b/config/eww/eww.yuck @@ -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)) diff --git a/desktop/startdwm b/desktop/startdwm index 979d336..e8208cc 100755 --- a/desktop/startdwm +++ b/desktop/startdwm @@ -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 diff --git a/dwm-flexipatch/config.def.h b/dwm-flexipatch/config.def.h index 3502538..56bdbda 100644 --- a/dwm-flexipatch/config.def.h +++ b/dwm-flexipatch/config.def.h @@ -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 diff --git a/dwm-flexipatch/dwm.c b/dwm-flexipatch/dwm.c index 92de8bb..646ca87 100644 --- a/dwm-flexipatch/dwm.c +++ b/dwm-flexipatch/dwm.c @@ -234,6 +234,7 @@ enum { ClkButton, ClkButton2, ClkButton3, + ClkButton4, #endif // BAR_STATUSBUTTON_PATCH #if TAB_PATCH ClkTabBar, diff --git a/dwm-flexipatch/patch/bar_statusbutton.c b/dwm-flexipatch/patch/bar_statusbutton.c index ca45905..b3e05f3 100644 --- a/dwm-flexipatch/patch/bar_statusbutton.c +++ b/dwm-flexipatch/patch/bar_statusbutton.c @@ -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; +} diff --git a/dwm-flexipatch/patch/bar_statusbutton.h b/dwm-flexipatch/patch/bar_statusbutton.h index 6b92917..6839227 100644 --- a/dwm-flexipatch/patch/bar_statusbutton.h +++ b/dwm-flexipatch/patch/bar_statusbutton.h @@ -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); diff --git a/dwm-flexipatch/patches.def.h b/dwm-flexipatch/patches.def.h index 8687659..13a7545 100644 --- a/dwm-flexipatch/patches.def.h +++ b/dwm-flexipatch/patches.def.h @@ -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 diff --git a/scripts/eww/eww-album b/scripts/eww/eww-album new file mode 100755 index 0000000..4d60b1d --- /dev/null +++ b/scripts/eww/eww-album @@ -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" diff --git a/scripts/eww/eww-artist b/scripts/eww/eww-artist new file mode 100755 index 0000000..8c315b7 --- /dev/null +++ b/scripts/eww/eww-artist @@ -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" diff --git a/scripts/eww/eww-music b/scripts/eww/eww-music new file mode 100755 index 0000000..d4ffe94 --- /dev/null +++ b/scripts/eww/eww-music @@ -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" diff --git a/scripts/eww/messages.txt b/scripts/eww/messages.txt new file mode 100644 index 0000000..61bc881 --- /dev/null +++ b/scripts/eww/messages.txt @@ -0,0 +1,2 @@ +change me! +put me in the homedir! diff --git a/scripts/eww/quoter b/scripts/eww/quoter new file mode 100755 index 0000000..837dac7 --- /dev/null +++ b/scripts/eww/quoter @@ -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"