better structure
This commit is contained in:
174
config/eww/Lyrics/eww.scss
Normal file
174
config/eww/Lyrics/eww.scss
Normal file
@@ -0,0 +1,174 @@
|
||||
* {
|
||||
all: unset;
|
||||
transition: 200ms ease-out;
|
||||
}
|
||||
|
||||
.lyrics-window {
|
||||
background-color: $bg;
|
||||
border-radius: 14px;
|
||||
border: 2px solid $border;
|
||||
}
|
||||
|
||||
.lyrics-window-single {
|
||||
background-color: rgba(30, 30, 46);
|
||||
border-radius: 14px;
|
||||
border: 2px solid $border;
|
||||
}
|
||||
|
||||
.lyrics-box {
|
||||
margin: 20px 10px 0 20px;
|
||||
min-width: 500px;
|
||||
min-height: 70px;
|
||||
background-color: $gray-alt;
|
||||
border-radius: 15px;
|
||||
padding: 10px;
|
||||
box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.lyrics-box-single {
|
||||
margin: 5px 0px 5px 10px;
|
||||
min-width: 735px;
|
||||
}
|
||||
|
||||
.lyrics-text {
|
||||
color: $fg;
|
||||
font-size: 15px;
|
||||
font-family: 'Maple Mono NF CN', 'Maple Mono CN', monospace;
|
||||
}
|
||||
|
||||
.lyrics-text-single {
|
||||
color: $fg;
|
||||
font-size: 15px;
|
||||
font-family: 'Maple Mono NF CN', 'Maple Mono CN', monospace;
|
||||
min-height: 28px;
|
||||
}
|
||||
|
||||
.control-box {
|
||||
margin: 20px 10px 0 0;
|
||||
padding: 6px;
|
||||
min-height: 90px;
|
||||
}
|
||||
|
||||
.offset-minus,
|
||||
.offset-reset,
|
||||
.offset-plus,
|
||||
.offset-clear {
|
||||
padding: 0px 6px;
|
||||
margin: 0px 4px 0px 4px;
|
||||
font-family: 'MesloLGM Nerd Font Mono';
|
||||
font-size: 25px;
|
||||
min-width: 16px;
|
||||
}
|
||||
|
||||
.offset-minus-single,
|
||||
.offset-plus-single,
|
||||
.offset-reset-single,
|
||||
.info-single {
|
||||
padding: 0px 6px;
|
||||
margin: 0;
|
||||
font-family: 'MesloLGM Nerd Font Mono';
|
||||
font-size: 20px;
|
||||
min-width: 16px;
|
||||
}
|
||||
|
||||
.offset-minus,
|
||||
.offset-minus-single {
|
||||
color: $blue;
|
||||
}
|
||||
|
||||
.offset-plus,
|
||||
.offset-plus-single {
|
||||
color: $yellow;
|
||||
}
|
||||
|
||||
.offset-reset,
|
||||
.offset-reset-single {
|
||||
color: $green;
|
||||
}
|
||||
|
||||
.offset-clear {
|
||||
color: $red;
|
||||
}
|
||||
|
||||
.info-single {
|
||||
color: $cyan;
|
||||
}
|
||||
|
||||
.offset-minus:hover,
|
||||
.offset-reset:hover,
|
||||
.offset-plus:hover,
|
||||
.offset-clear:hover,
|
||||
.offset-minus-single:hover,
|
||||
.offset-plus-single:hover,
|
||||
.offset-reset-single:hover,
|
||||
.lyrics-info:hover,
|
||||
.info-single:hover,
|
||||
.player-prev:hover,
|
||||
.player-next:hover,
|
||||
.player-pp:hover {
|
||||
color: $fg;
|
||||
}
|
||||
|
||||
.player-music-slider-box {
|
||||
padding: 12px;
|
||||
margin: 10px 0 20px 20px;
|
||||
border-radius: 15px;
|
||||
background-color: $gray-alt;
|
||||
box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
min-height: 16px;
|
||||
}
|
||||
|
||||
.player-music-slider trough {
|
||||
background-color: $gray;
|
||||
}
|
||||
|
||||
.player-music-slider highlight {
|
||||
background-color: $border;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.player-music-slider {
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.player-controls-box {
|
||||
margin: 10px 0 20px 20px;
|
||||
}
|
||||
|
||||
.player-pp,
|
||||
.player-next,
|
||||
.player-prev,
|
||||
.lyrics-info {
|
||||
padding: 0px 6px;
|
||||
margin: 0px 4px 0px 4px;
|
||||
font-family: 'MesloLGM Nerd Font Mono';
|
||||
font-size: 25px;
|
||||
min-width: 16px;
|
||||
color: $fg-alt;
|
||||
}
|
||||
|
||||
.lyrics-info {
|
||||
color: $cyan;
|
||||
}
|
||||
|
||||
.offset-box {
|
||||
padding: 11px;
|
||||
margin: 10px 20px 20px 10px;
|
||||
border-radius: 15px;
|
||||
// background-color: $gray-alt;
|
||||
// box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.offset-label {
|
||||
color: $fg-alt;
|
||||
font-size: 15px;
|
||||
font-family: 'Maple Mono NF CN', 'Maple Mono CN', monospace;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.offset-value {
|
||||
color: $fg;
|
||||
font-size: 15px;
|
||||
font-family: 'Maple Mono NF CN', 'Maple Mono CN', monospace;
|
||||
margin-right: 10px;
|
||||
}
|
||||
95
config/eww/Lyrics/eww.yuck
Normal file
95
config/eww/Lyrics/eww.yuck
Normal file
@@ -0,0 +1,95 @@
|
||||
(defpoll lyriclines :interval "500ms" "spotify-lyrics print -l 3 -a 1 -f \"$HOME/.local/state/eww/lyrics/offset\" | Lyrics/scripts/colorize.sh 2")
|
||||
(deflisten lyricline "spotify-lyrics listen -l 1 -f \"$HOME/.local/state/eww/lyrics/offset\"")
|
||||
(defpoll position :interval "1s" "spotify-lyrics position")
|
||||
(defpoll length :interval "1s" "spotify-lyrics length")
|
||||
(defpoll offset :interval "1s" "cat $HOME/.local/state/eww/lyrics/offset")
|
||||
(defpoll play-button :interval "1s" "if spotify-lyrics status; then echo \"\"; else echo \"\"; fi")
|
||||
(defvar hover false)
|
||||
|
||||
(defwidget lyrics []
|
||||
(box :class "lyrics-window" :space-evenly "false" :orientation "v"
|
||||
(box :class "lyrics-container" :space-evenly "false" :orientation "h"
|
||||
(box :class "lyrics-box" :vexpand "false" :hexpand "false" :valign "center" :space-evenly "true" :orientation "v"
|
||||
(label :class "lyrics-text"
|
||||
:vexpand "false" :hexpand "false" :space-evenly "false"
|
||||
:halign "start"
|
||||
:unindent "false" :truncate "false" :truncate-left "false"
|
||||
:markup lyriclines
|
||||
)
|
||||
)
|
||||
(box :class "control-box" :vexpand "false" :hexpand "false" :space-evenly "true" :orientation "v"
|
||||
(box :class "control-row-1" :space-evenly "false" :orientation "h"
|
||||
(button :class "offset-plus" :onclick "Lyrics/scripts/lyric-offset.py +500" "")
|
||||
(button :class "offset-minus" :onclick "Lyrics/scripts/lyric-offset.py -500" "")
|
||||
)
|
||||
(box :class "control-row-1" :space-evenly "false" :orientation "h"
|
||||
(button :class "offset-reset" :onclick "Lyrics/scripts/lyric-offset.py" "")
|
||||
(button :class "offset-clear" :onclick "Lyrics/scripts/lyric-clear.sh $(spotify-lyrics trackid)" "")
|
||||
)
|
||||
)
|
||||
)
|
||||
(box :class "player-controls" :space-evenly "false" :orientation "h"
|
||||
(box :class "player-music-slider-box"
|
||||
:vexpand "false" :hexpand "false" :valign "center" :space-evenly "false" :orientation "h"
|
||||
(eventbox :onhover "eww update hover=true"
|
||||
:onhoverlost "eww update hover=false"
|
||||
:cursor "pointer"
|
||||
:space-evenly "false"
|
||||
(scale :orientation "h" :class "player-music-slider"
|
||||
:min 0 :max length :value position
|
||||
:onchange { hover ? "spotify-lyrics set-position {}" : "" })
|
||||
)
|
||||
)
|
||||
(box :class "player-controls-box"
|
||||
:vexpand "false" :hexpand "false" :valign "center" :space-evenly "false" :orientation "h"
|
||||
(button :class "player-prev" :onclick "playerctl previous --player=spotify" "")
|
||||
(button :class "player-pp" :onclick "playerctl play-pause --player=spotify" "${play-button}")
|
||||
(button :class "player-next" :onclick "playerctl next --player=spotify" "")
|
||||
(button :class "lyrics-info" :onclick "ghostty -e sh -c 'spotify-lyrics fetch | less' &" "")
|
||||
)
|
||||
(box :class "offset-box"
|
||||
:vexpand "false" :hexpand "true" :valign "center" :halign "center" :space-evenly "false" :orientation "h"
|
||||
(label :class "offset-label" :text "Offset (ms): ")
|
||||
(label :class "offset-value" :text offset)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defwidget lyrics-single []
|
||||
(box :class "lyrics-window-single" :space-evenly "false" :orientation "h"
|
||||
(box :class "lyrics-box-single"
|
||||
:vexpand "false" :hexpand "false"
|
||||
:valign "center" :space-evenly "false" :orientation "v"
|
||||
(label :class "lyrics-text-single"
|
||||
:vexpand "false" :hexpand "false" :space-evenly "false"
|
||||
:halign "start"
|
||||
:text lyricline
|
||||
)
|
||||
)
|
||||
(box :class "control-box-single" :vexpand "false" :hexpand "false" :space-evenly "true" :orientation "v"
|
||||
(box :class "control-row-1-single" :space-evenly "false" :orientation "h"
|
||||
(button :class "info-single" :onclick "ghostty -e sh -c 'spotify-lyrics fetch | less' &" "")
|
||||
(button :class "offset-plus-single" :onclick "Lyrics/scripts/lyric-offset.py +500" "")
|
||||
(button :class "offset-reset-single" :onclick "Lyrics/scripts/lyric-offset.py" "")
|
||||
(button :class "offset-minus-single" :onclick "Lyrics/scripts/lyric-offset.py -500" "")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defwindow lyrics
|
||||
:windowtype "normal"
|
||||
:wm-ignore true
|
||||
:monitor 0
|
||||
:geometry (geometry :anchor "top center")
|
||||
(lyrics)
|
||||
)
|
||||
|
||||
(defwindow lyrics-single
|
||||
:windowtype "normal"
|
||||
:wm-ignore true
|
||||
:monitor 0
|
||||
:geometry (geometry :x 1108 :y -45)
|
||||
(lyrics-single)
|
||||
)
|
||||
24
config/eww/Lyrics/scripts/colorize.sh
Executable file
24
config/eww/Lyrics/scripts/colorize.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
HIGHLIGHT_COLOR="#cdd6f4" # text
|
||||
NORMAL_COLOR="#7f849c" # overlay1
|
||||
TARGET_LINE=1
|
||||
[ -n "$1" ] && TARGET_LINE="$1"
|
||||
|
||||
mapfile -t lines
|
||||
|
||||
output=""
|
||||
for i in "${!lines[@]}"; do
|
||||
line_num=$((i + 1))
|
||||
escaped_line=$(echo "${lines[$i]}" | sed 's/&/\&/g; s/</\</g; s/>/\>/g')
|
||||
|
||||
[[ $i -gt 0 ]] && output+=$'\n' # +="\n" is not properly displayed in eww
|
||||
|
||||
if [[ $line_num -eq $TARGET_LINE ]]; then
|
||||
output+="<span color=\"$HIGHLIGHT_COLOR\">$escaped_line</span>"
|
||||
else
|
||||
output+="<span color=\"$NORMAL_COLOR\">$escaped_line</span>"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$output"
|
||||
9
config/eww/Lyrics/scripts/lyric-clear.sh
Executable file
9
config/eww/Lyrics/scripts/lyric-clear.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
"spotify-lyrics" clear
|
||||
notify-send -a "spotify-lyrics" "Cache Cleared" "Lyrics cache have been cleared."
|
||||
else
|
||||
"spotify-lyrics" clear "$1"
|
||||
notify-send -a "spotify-lyrics" "Cache Cleared" "Lyrics cache for track $1 have been cleared."
|
||||
fi
|
||||
45
config/eww/Lyrics/scripts/lyric-offset.py
Executable file
45
config/eww/Lyrics/scripts/lyric-offset.py
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
APP_NAME = "spotify-lyrics"
|
||||
STATE_DIR_NAME = "~/.local/state/eww/lyrics"
|
||||
STATE_FILE_NAME = "offset"
|
||||
|
||||
|
||||
def notify_send(title, message):
|
||||
import subprocess
|
||||
subprocess.run(["notify-send", "-t", "1000", "-a", APP_NAME, title, message], check=True)
|
||||
|
||||
|
||||
def main():
|
||||
import sys
|
||||
import os
|
||||
|
||||
state_dir = os.path.expanduser(STATE_DIR_NAME)
|
||||
if not os.path.exists(state_dir):
|
||||
os.makedirs(state_dir)
|
||||
|
||||
offset_file = os.path.join(state_dir, STATE_FILE_NAME)
|
||||
if not os.path.exists(offset_file):
|
||||
with open(offset_file, "w") as f:
|
||||
f.write("0")
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
new_offset = 0
|
||||
else:
|
||||
try:
|
||||
increment = int(sys.argv[1])
|
||||
with open(offset_file, "r") as f:
|
||||
current_offset = int(f.read().strip())
|
||||
new_offset = current_offset + increment
|
||||
except ValueError:
|
||||
print("Invalid input. Please provide an integer value.")
|
||||
return
|
||||
|
||||
with open(offset_file, "w") as f:
|
||||
f.write(str(new_offset))
|
||||
|
||||
notify_send("Lyrics Speed Changed", f"The offset has been changed to {new_offset} ms.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
2
config/eww/Lyrics/scripts/lyric-show.sh
Executable file
2
config/eww/Lyrics/scripts/lyric-show.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
|
||||
270
config/eww/Main/eww.scss
Normal file
270
config/eww/Main/eww.scss
Normal file
@@ -0,0 +1,270 @@
|
||||
* {
|
||||
all: unset;
|
||||
transition: 200ms ease-out;
|
||||
}
|
||||
|
||||
.main-window {
|
||||
background-color: $bg;
|
||||
font-family: 'Sour Gummy', 'MesloLGM Nerd Font Mono', 'Noto Sans';
|
||||
border-radius: 14px;
|
||||
border: 2px solid $border;
|
||||
}
|
||||
|
||||
.date-box {
|
||||
// background-color: $bg;
|
||||
margin: 20px 20px 0px 20px;
|
||||
min-width: 290px;
|
||||
padding: 20px 10px 20px 10px;
|
||||
border-radius: 15px;
|
||||
color: $fg;
|
||||
// box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.time {
|
||||
font-family: 'Sour Gummy ExtraLight';
|
||||
font-weight: bold;
|
||||
font-size: 100px;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.date {
|
||||
font-size: 24px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.weather-box {
|
||||
background-color: $gray-alt;
|
||||
margin: 20px 20px 0px 0px;
|
||||
padding: 20px 10px 10px 20px;
|
||||
border-radius: 15px;
|
||||
box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.weather-desc {
|
||||
color: $fg-alt;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.weather-temp {
|
||||
font-size: 36px;
|
||||
color: $fg;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.weather-icon {
|
||||
font-family: 'MesloLGM Nerd Font';
|
||||
font-size: 60px;
|
||||
margin-top: 5px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.weather-updatetime {
|
||||
color: $fg-alt;
|
||||
font-size: 16px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.stats-box {
|
||||
background-color: $gray-alt;
|
||||
margin: 20px 20px 0px 20px;
|
||||
padding: 20px 35px 20px 25px;
|
||||
border-radius: 15px;
|
||||
box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.stats-header {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: $gray;
|
||||
}
|
||||
|
||||
.volume-icon,
|
||||
.brightness-icon,
|
||||
.cpu-icon,
|
||||
.memory-icon {
|
||||
font-size: 20px;
|
||||
color: $fg;
|
||||
}
|
||||
|
||||
.volume-scale trough,
|
||||
.brightness-scale trough,
|
||||
.cpu-scale trough,
|
||||
.memory-scale trough {
|
||||
all: unset;
|
||||
background-color: $gray;
|
||||
min-height: 10px;
|
||||
border-radius: 15px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.volume-scale highlight {
|
||||
background-color: $sapphire;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.brightness-scale highlight {
|
||||
background-color: $teal;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.cpu-scale highlight {
|
||||
background-color: $yellow;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.memory-scale highlight {
|
||||
background-color: $peach;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.fortune-box {
|
||||
// background-color: $gray-alt;
|
||||
margin: 20px 20px 0px 0px;
|
||||
padding: 20px 35px 20px 25px;
|
||||
border-radius: 15px;
|
||||
// box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.fortune-header {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: $gray;
|
||||
}
|
||||
|
||||
.fortune-text {
|
||||
font-family: 'Noto Sans';
|
||||
font-size: 14px;
|
||||
color: $fg;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.music-art-box {
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
min-width: 455px;
|
||||
min-height: 240px;
|
||||
border-radius: 17px;
|
||||
background-position: center;
|
||||
margin: 20px 0px 0px 20px;
|
||||
box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.music-title {
|
||||
margin: 20px 0px 0px 20px;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
color: $fg;
|
||||
}
|
||||
|
||||
.music-artist {
|
||||
margin: 10px 0px 0px 20px;
|
||||
font-size: 20px;
|
||||
color: $fg-alt;
|
||||
}
|
||||
|
||||
.music-length {
|
||||
margin: 90px 0px 0px 20px;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: $fg-alt;
|
||||
}
|
||||
|
||||
.music-stuff-box {
|
||||
border-radius: 15px;
|
||||
background: linear-gradient(to right, $bg-alt, transparent);
|
||||
min-height: 240px;
|
||||
}
|
||||
|
||||
.player-cover-box {
|
||||
background-size: 140px;
|
||||
min-height: 140px;
|
||||
min-width: 140px;
|
||||
border-radius: 20px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.player-box {
|
||||
margin: 40px 30px 30px 50px;
|
||||
}
|
||||
|
||||
.player-info-box {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.player-info-title,
|
||||
.player-info-artist {
|
||||
color: $border;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.player-info-album,
|
||||
.player-info-length {
|
||||
color: $fg-alt;
|
||||
}
|
||||
|
||||
.player-info-button {
|
||||
background-color: $gray-alt;
|
||||
padding: 15px;
|
||||
border-radius: 20px;
|
||||
font-weight: bold;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.cavabar {
|
||||
font-family: 'Noto Sans';
|
||||
font-size: 14px;
|
||||
color: $border;
|
||||
}
|
||||
|
||||
.music-controls-box {
|
||||
margin: 20px 20px 0px 20px;
|
||||
// background-color: $gray-alt;
|
||||
padding: 0px 23px 0px 23px;
|
||||
border-radius: 15px;
|
||||
text-shadow: 0px 0px 10px rgba(0, 0, 0, 1);
|
||||
// box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.music-next,
|
||||
.music-previous {
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.music-pp {
|
||||
font-size: 44px;
|
||||
color: $fg;
|
||||
}
|
||||
|
||||
.music-next:hover,
|
||||
.music-previous:hover,
|
||||
.music-pp:hover {
|
||||
color: $orange;
|
||||
}
|
||||
|
||||
.profile-stuff-box {
|
||||
margin: 20px 20px 20px 20px;
|
||||
// background-color: $gray-alt;
|
||||
border-radius: 15px;
|
||||
padding: 15px 20px 15px 20px;
|
||||
// box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.profile-img {
|
||||
border-radius: 10px;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
min-width: 90px;
|
||||
box-shadow: 5px 5px 8px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.profile-stuff {
|
||||
padding: 7px 0px 0px 30px;
|
||||
font-size: 20px;
|
||||
color: $fg;
|
||||
}
|
||||
|
||||
.profile-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
116
config/eww/Main/eww.yuck
Normal file
116
config/eww/Main/eww.yuck
Normal file
@@ -0,0 +1,116 @@
|
||||
;; variables
|
||||
(defvar window false)
|
||||
(defpoll time :interval "1s" "date '+%H:%M'")
|
||||
(defpoll date :interval "1s" "date '+%A, %B %d'")
|
||||
(deflisten notifications-cards "Main/scripts/logger.zsh subscribe")
|
||||
(defpoll notifications-crits :interval "1s" "Main/scripts/logger.zsh crits")
|
||||
(defpoll weather-icon :interval "5m" "Main/scripts/weather --icon")
|
||||
(defpoll weather-temp :interval "5m" "Main/scripts/weather --temp")
|
||||
(defpoll weather-desc :interval "5m" "Main/scripts/weather --stat")
|
||||
(defpoll weather-updatetime :interval "5m" "Main/scripts/weather --updatetime")
|
||||
(deflisten weather-color :initial "#7aa2f7" "Main/scripts/weather --hex")
|
||||
(defpoll calendar-day :interval "20h" "+%d")
|
||||
(defpoll calendar-year :interval "20h" "+%Y")
|
||||
(defpoll calendar-month :interval "20h" "%+B")
|
||||
(defpoll cpu :interval "1s" "Main/scripts/system --cpu")
|
||||
(defpoll memory :interval "1s" "Main/scripts/system --mem")
|
||||
(defpoll profile-image :interval "10h" "Main/scripts/details --image")
|
||||
(defpoll profile-username :interval "1h" "whoami")
|
||||
(defpoll profile-name :interval "1h" "Main/scripts/details --name")
|
||||
(defpoll profile-kernel :interval "1h" "Main/scripts/details --kernel")
|
||||
(defpoll profile-os :interval "1h" "Main/scripts/details --os")
|
||||
(defpoll music-length :interval "1s" "Main/scripts/music-length")
|
||||
(defpoll music-title :interval "1s" "Main/scripts/music-title --status")
|
||||
(defpoll music-pp :interval "1s" "Main/scripts/music-title --icon")
|
||||
(defpoll music-artist :interval "1s" "Main/scripts/music-artist")
|
||||
(defpoll music-art :interval "1s" "Main/scripts/music-art")
|
||||
(defpoll music-art-blur :interval "1s" "Main/scripts/music-art-blur")
|
||||
(defpoll volume :interval "1s" "Main/scripts/system --vol")
|
||||
(defpoll brightness :interval "1s" "Main/scripts/system --bri")
|
||||
(defpoll fortune :interval "1h" "Main/scripts/fortune-split 32 6")
|
||||
(deflisten cava "Main/scripts/cava")
|
||||
(defpoll title :interval "1s" "Main/scripts/music-title --status")
|
||||
(defpoll artist :interval "1s" "Main/scripts/player --artist")
|
||||
(defpoll album :interval "1s" "Main/scripts/player --album")
|
||||
(defpoll length-info :interval "1s" "Main/scripts/player --length-info")
|
||||
(defvar volume-hover false)
|
||||
(defvar brightness-hover false)
|
||||
|
||||
;; widgets
|
||||
(defwidget main []
|
||||
(box :class "main-window" :space-evenly "false" :orientation "v"
|
||||
(box :class "top-row" :orientation "h" :space-evenly "false"
|
||||
(box :class "date-box" :space-evenly "false" :orientation "v" :hexpand "false" :vexpand "false"
|
||||
(label :class "time" :text time)
|
||||
(label :class "date" :text date))
|
||||
(box :class "weather-box" :space-evenly "false" :hexpand "true" :orientation "v"
|
||||
(label :class "weather-desc" :halign "start" :text weather-desc)
|
||||
(label :class "weather-temp" :halign "start" :text weather-temp)
|
||||
(label :class "weather-updatetime" :halign "start" :text weather-updatetime)
|
||||
(label :class "weather-icon" :halign "end" :valign "start" :text weather-icon :style "color: ${weather-color}")))
|
||||
(box :class "second-row" :orientation "h" :space-evenly "false"
|
||||
(box :class "stats-box" :space-evenly "false" :orientation "v" :spacing 8
|
||||
(label :class "stats-header" :halign "start" :text "Stats")
|
||||
(box :class "volume-stats" :hexpand "false" :vexpand "false" :space-evenly "false"
|
||||
(label :tooltip "${volume}%" :class "volume-icon" :text "")
|
||||
(eventbox :class "volume-eventbox"
|
||||
:onhover "eww update volume-hover=true"
|
||||
:onhoverlost "eww update volume-hover=false"
|
||||
:cursor "pointer"
|
||||
:space-evenly "false"
|
||||
(scale :min 0 :max 101 :class "volume-scale" :width 150
|
||||
:value {volume == "" ? 0 : volume}
|
||||
:round-digits 0
|
||||
:onchange { volume-hover ? "wpctl set-volume -l 1.0 @DEFAULT_AUDIO_SINK@ {}%" : "" }
|
||||
)))
|
||||
(box :class "brightness-stats" :hexpand "false" :vexpand "false" :space-evenly "false"
|
||||
(label :tooltip "${brightness}%" :class "brightness-icon" :text "")
|
||||
(eventbox :class "brightness-eventbox"
|
||||
:onhover "eww update brightness-hover=true"
|
||||
:onhoverlost "eww update brightness-hover=false"
|
||||
:cursor "pointer"
|
||||
:space-evenly "false"
|
||||
(scale :min 0 :max 101 :class "brightness-scale" :width 150
|
||||
:value {brightness == "" ? 0 : brightness}
|
||||
:round-digits 0
|
||||
:onchange { brightness-hover ? "brightnessctl set {}\% --class=backlight" : "" })))
|
||||
(box :class "cpu-stats" :hexpand "false" :vexpand "false" :space-evenly "false"
|
||||
(label :tooltip "${cpu}%" :class "cpu-icon" :text "")
|
||||
(scale :min 0 :max 101 :active false :value {cpu == "" ? 0 : cpu} :class "cpu-scale" :width 150))
|
||||
(box :class "memory-stats" :hexpand "false" :vexpand "false" :space-evenly "false"
|
||||
(label :tooltip "${memory}%" :class "memory-icon" :text "")
|
||||
(scale :min 0 :max 101 :active false :value {memory == "" ? 0 : memory} :class "memory-scale" :width 150)))
|
||||
(box :class "fortune-box" :space-evenly "false" :hexpand "true" :orientation "v"
|
||||
(label :class "fortune-header" :halign "start" :text "Fortune")
|
||||
(label :class "fortune-text" :halign "start" :text fortune :show-truncated true :wrap true)))
|
||||
(box :class "third-row" :orientation "h" :space-evenly "false"
|
||||
(box :class "music-art-box" :space-evenly "false" :orientation "v" :hexpand "false" :vexpand "false" :style "background-image: url(\"${music-art-blur}\");"
|
||||
(box :class "music-stuff-box" :space-evenly "false" :hexpand "false" :vexpand "false" :orientation "v"
|
||||
(box :class "player-box" :hexpand "false" :vexpand "false" :space-evenly "true"
|
||||
(box :class "player-info-box" :hexpand "false" :vexpand "false" :space-evenly "false" :orientation "v" :spacing 15
|
||||
(label :class "player-info-title" :text " Title: ${title}" :halign "start" :limit-width 30 :tooltip "${title}")
|
||||
(label :class "player-info-artist" :text " Artist: ${artist}" :halign "start" :limit-width 30 :tooltip "${artist}")
|
||||
(label :class "player-info-album" :text " Album: ${album}" :halign "start" :limit-width 30 :tooltip "${album}")
|
||||
(label :class "player-info-length" :text " Length: ${length-info}" :halign "start" :tooltip "${length-info}"))
|
||||
(box :class "player-cover-box" :hexpand "false" :halign "end" :vexpand "false" :space-evenly "false" :style "background-image: url(\"${music-art}\");"))
|
||||
(label :vexpand "true" :hexpand "false" :space-evenly "false" :valign "end"
|
||||
:class "cavabar"
|
||||
:text cava)))
|
||||
(box :class "music-controls-box" :space-evenly "true" :hexpand "true" :vexpand "false" :orientation "v"
|
||||
(button :class "music-previous" :halign "center" :onclick "playerctl previous" "")
|
||||
(button :class "music-pp" :halign "center" :onclick "playerctl play-pause" "${music-pp}")
|
||||
(button :class "music-next" :halign "center" :onclick "playerctl next" "")))
|
||||
(box :class "profile-stuff-box" :space-evenly "false" :hexpand "false" :vexpand "false" :orientation "h" :height 140
|
||||
(box :class "profile-img" :space-evenly "false" :hexpand "false" :vexpand "false" :orientation "v" :style "background-image: url(\"${profile-image}\");")
|
||||
(box :class "profile-stuff" :orientation "v" :space-evenly "false" :hexpand "false" :vexpand "false" :spacing 8
|
||||
(label :class "profile-name" :text profile-name :halign "start")
|
||||
(label :class "profile-os" :text profile-os :halign "start")
|
||||
(label :class "profile-kernel" :text profile-kernel :halign "start")))))
|
||||
|
||||
;; windows
|
||||
(defwindow main
|
||||
:windowtype "normal"
|
||||
:wm-ignore true
|
||||
:monitor 0
|
||||
:geometry (geometry :x 0 :y 0)
|
||||
(main))
|
||||
BIN
config/eww/Main/images/default-music-blur.png
Normal file
BIN
config/eww/Main/images/default-music-blur.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 919 KiB |
1
config/eww/Main/images/default-music.svg
Normal file
1
config/eww/Main/images/default-music.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 148 KiB |
BIN
config/eww/Main/images/profile.png
Normal file
BIN
config/eww/Main/images/profile.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 182 KiB |
40
config/eww/Main/scripts/cava
Executable file
40
config/eww/Main/scripts/cava
Executable file
@@ -0,0 +1,40 @@
|
||||
#! /bin/bash
|
||||
|
||||
|
||||
bar="▁▂▃▄▅▆▇█"
|
||||
dict="s/;//g;"
|
||||
|
||||
# creating "dictionary" to replace char with bar
|
||||
i=0
|
||||
while [ $i -lt ${#bar} ]
|
||||
do
|
||||
dict="${dict}s/$i/${bar:$i:1}/g;"
|
||||
i=$((i=i+1))
|
||||
done
|
||||
|
||||
# make sure to clean pipe
|
||||
pipe="/tmp/cava.fifo"
|
||||
if [ -p $pipe ]; then
|
||||
unlink $pipe
|
||||
fi
|
||||
mkfifo $pipe
|
||||
|
||||
# write cava config
|
||||
config_file="/tmp/waybar_cava_config"
|
||||
echo "
|
||||
[general]
|
||||
bars = 30
|
||||
[output]
|
||||
method = raw
|
||||
raw_target = $pipe
|
||||
data_format = ascii
|
||||
ascii_max_range = 7
|
||||
" > $config_file
|
||||
|
||||
# run cava in the background
|
||||
cava -p $config_file &
|
||||
|
||||
# reading data from fifo
|
||||
while read -r cmd; do
|
||||
echo $cmd | sed $dict
|
||||
done < $pipe
|
||||
28
config/eww/Main/scripts/details
Executable file
28
config/eww/Main/scripts/details
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $1 == "--image" ]]; then
|
||||
FILE=$HOME/.face
|
||||
if [[ -f "$FILE" ]]; then
|
||||
echo "../../.face"
|
||||
else
|
||||
echo "Main/images/profile.png"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [[ $1 == "--name" ]]; then
|
||||
fullname=$(getent passwd "$(whoami)" | cut -d ':' -f 5 | cut -d ',' -f 1 | tr -d "\n")
|
||||
if [ -z "$fullname" ]; then
|
||||
echo "$(whoami)@$(hostnamectl | awk 'FNR==1 {print $3}')"
|
||||
else
|
||||
echo "$fullname"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $1 == "--kernel" ]]; then
|
||||
echo "$(uname -r)"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--os" ]]; then
|
||||
echo "$(cat /etc/os-release | awk 'NR==1'| awk -F '"' '{print $2}')"
|
||||
fi
|
||||
92
config/eww/Main/scripts/fortune-split
Executable file
92
config/eww/Main/scripts/fortune-split
Executable file
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
def wrap(text, width, height):
|
||||
lines = []
|
||||
|
||||
paragraphs = text.split('\n')
|
||||
|
||||
for paragraph in paragraphs:
|
||||
if len(lines) >= height:
|
||||
return []
|
||||
|
||||
# Skip empty paragraphs
|
||||
if not paragraph.strip():
|
||||
lines.append('')
|
||||
continue
|
||||
|
||||
current_line = ''
|
||||
words = paragraph.split()
|
||||
|
||||
for word in words:
|
||||
if current_line:
|
||||
test_line = current_line + ' ' + word
|
||||
else:
|
||||
test_line = word
|
||||
|
||||
if len(test_line) <= width:
|
||||
current_line = test_line
|
||||
else:
|
||||
if current_line:
|
||||
lines.append(current_line)
|
||||
current_line = word
|
||||
else:
|
||||
while len(word) > width:
|
||||
lines.append(word[:width])
|
||||
word = word[width:]
|
||||
current_line = word
|
||||
|
||||
if current_line:
|
||||
lines.append(current_line)
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
RETRY_LIMIT = 10
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: fortune.py <width> <height>")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
width = int(sys.argv[1])
|
||||
if width <= 0:
|
||||
raise ValueError()
|
||||
height = int(sys.argv[2])
|
||||
if height <= 0:
|
||||
raise ValueError()
|
||||
except ValueError:
|
||||
print("Invalid argument.")
|
||||
sys.exit(1)
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
if i >= RETRY_LIMIT:
|
||||
print("Failed to get fortune after multiple attempts.")
|
||||
sys.exit(1)
|
||||
i += 1
|
||||
|
||||
try:
|
||||
buffer = subprocess.check_output(['fortune', '-s'], text=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error running fortune: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
lines = wrap(buffer, width, height)
|
||||
|
||||
if lines:
|
||||
break
|
||||
else:
|
||||
print("retrying...")
|
||||
|
||||
for line in lines:
|
||||
print(line)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
32
config/eww/Main/scripts/music-album
Executable file
32
config/eww/Main/scripts/music-album
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ album }}"
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="No Album"
|
||||
fi
|
||||
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "No Album"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "No Alnum" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
45
config/eww/Main/scripts/music-art
Executable file
45
config/eww/Main/scripts/music-art
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
tmp_dir="$HOME/.cache/eww/music-art"
|
||||
art_path=$tmp_dir/temp.png
|
||||
art_blur_path="$tmp_dir/temp-blur.png"
|
||||
cache_path="$tmp_dir/cache.conf"
|
||||
cache_blur_path="$tmp_dir/cache-blur.conf"
|
||||
log_path="$tmp_dir/log.txt"
|
||||
default_path="$HOME/.config/eww/Main/images/default-music.svg"
|
||||
default_blur_path="$HOME/.config/eww/Main/images/default-music-blur.png"
|
||||
|
||||
mkdir -p "$tmp_dir"
|
||||
|
||||
artlink="$(playerctl metadata mpris:artUrl)"
|
||||
[ -f "$cache_path" ] && . "$cache_path"
|
||||
|
||||
# avoid unnecessary downloads
|
||||
if [ -z "$artlink" ]; then
|
||||
art_path="$default_path"
|
||||
art_blur_path="$default_blur_path"
|
||||
elif [[ "$cachedlink" != "$artlink" ]]; then
|
||||
echo "cachedlink=\"$artlink\"" > "$cache_path"
|
||||
echo "Updating music art: $artlink" >> "$log_path"
|
||||
|
||||
if [[ "$artlink" == "file://"* ]]; then
|
||||
# Handle local file URLs
|
||||
local_file_path="${artlink#file://}"
|
||||
if [[ -f "$local_file_path" ]]; then
|
||||
magick "$local_file_path" "$art_path" || exit 1
|
||||
fi
|
||||
magick "$art_path" -blur 0x8 "$art_blur_path"
|
||||
elif [[ "$artlink" =~ ^https?:// ]]; then
|
||||
# Handle HTTP/HTTPS URLs
|
||||
curl -s "$artlink" --output "$art_path"_orig || exit 1
|
||||
magick "$art_path"_orig "$art_path" || exit 1
|
||||
magick "$art_path" -blur 0x8 "$art_blur_path"
|
||||
else
|
||||
echo "Unknown art link format: $artlink" >> "$log_path"
|
||||
art_path="$default_path"
|
||||
art_blur_path="$default_blur_path"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "path=\"$art_blur_path\"" > "$cache_blur_path"
|
||||
echo "$art_path"
|
||||
8
config/eww/Main/scripts/music-art-blur
Executable file
8
config/eww/Main/scripts/music-art-blur
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
tmp_dir="$HOME/.cache/eww/music-art"
|
||||
cache_blur_path="$tmp_dir/cache-blur.conf"
|
||||
|
||||
. "$cache_blur_path"
|
||||
|
||||
echo "$path"
|
||||
32
config/eww/Main/scripts/music-artist
Executable file
32
config/eww/Main/scripts/music-artist
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ artist }}"
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="No Artist"
|
||||
fi
|
||||
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "No Artist"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "No Artist" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
32
config/eww/Main/scripts/music-length
Executable file
32
config/eww/Main/scripts/music-length
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ duration(position) }} / {{ duration(mpris:length) }}"
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="--:-- / --:--"
|
||||
fi
|
||||
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "--:-- / --:--"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "--:-- / --:--" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
32
config/eww/Main/scripts/music-length-info
Executable file
32
config/eww/Main/scripts/music-length-info
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ duration(mpris:length) }}"
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="--:--"
|
||||
fi
|
||||
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "--:--"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "--:--" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
4
config/eww/Main/scripts/music-position
Executable file
4
config/eww/Main/scripts/music-position
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
POS=$(playerctl -p spotify position)
|
||||
python -c "print(float($POS*1000000))"
|
||||
43
config/eww/Main/scripts/music-title
Executable file
43
config/eww/Main/scripts/music-title
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ title }}"
|
||||
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="Nothing is playing"
|
||||
fi
|
||||
|
||||
if [ "$1" == "--status" ]; then
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "Nothing is playing"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "Nothing is playing" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" == "--icon" ]; then
|
||||
if [[ $STATUS == "Playing" ]]; then
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
57
config/eww/Main/scripts/player
Executable file
57
config/eww/Main/scripts/player
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $1 == "--length" ]]; then
|
||||
playerctl -p spotify metadata mpris:length
|
||||
fi
|
||||
|
||||
if [[ $1 == "--open" ]]; then
|
||||
URL=$(playerctl -p spotify metadata xesam:url)
|
||||
echo "$URL?go=1&utm_medium=desktop"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--artist" ]]; then
|
||||
"$HOME/.config/eww/Main/scripts/music-artist"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--length-time" ]]; then
|
||||
"$HOME/.config/eww/Main/scripts/music-length"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--length-info" ]]; then
|
||||
"$HOME/.config/eww/Main/scripts/music-length-info"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--cover" ]]; then
|
||||
"$HOME/.config/eww/Main/scripts/music-art"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--album" ]]; then
|
||||
"$HOME/.config/eww/Main/scripts/music-album"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--current-volume" ]]; then
|
||||
VOLUME=$(playerctl -p spotify volume)
|
||||
echo $(python -c "print(float("$VOLUME")*100)")
|
||||
fi
|
||||
|
||||
if [[ $1 == "--volume" ]]; then
|
||||
CURRENT_VOLUME=$2
|
||||
NOW_VOLUME=$(python -c "print(float($CURRENT_VOLUME)/100)")
|
||||
playerctl -p spotify volume "$NOW_VOLUME"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--shuffle" ]]; then
|
||||
if [[ $(playerctl -p spotify shuffle) == "On" ]]; then
|
||||
playerctl -p spotify shuffle off
|
||||
else
|
||||
playerctl -p spotify shuffle On
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $1 == "--current-pos" ]]; then
|
||||
playerctl -p spotify position --format '{{ duration(position) }}'
|
||||
fi
|
||||
|
||||
if [[ $1 == "--launch-lyrics" ]]; then
|
||||
eww open --toggle lyrics
|
||||
fi
|
||||
70
config/eww/Main/scripts/system
Executable file
70
config/eww/Main/scripts/system
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
## Files and Data
|
||||
PREV_TOTAL=0
|
||||
PREV_IDLE=0
|
||||
cpuFile="/tmp/.cpu_usage"
|
||||
|
||||
## Get CPU usage
|
||||
get_cpu() {
|
||||
if [[ -f "${cpuFile}" ]]; then
|
||||
fileCont=$(cat "${cpuFile}")
|
||||
PREV_TOTAL=$(echo "${fileCont}" | head -n 1)
|
||||
PREV_IDLE=$(echo "${fileCont}" | tail -n 1)
|
||||
fi
|
||||
|
||||
CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics.
|
||||
unset CPU[0] # Discard the "cpu" prefix.
|
||||
IDLE=${CPU[4]} # Get the idle CPU time.
|
||||
|
||||
# Calculate the total CPU time.
|
||||
TOTAL=0
|
||||
|
||||
for VALUE in "${CPU[@]:0:4}"; do
|
||||
let "TOTAL=$TOTAL+$VALUE"
|
||||
done
|
||||
|
||||
if [[ "${PREV_TOTAL}" != "" ]] && [[ "${PREV_IDLE}" != "" ]]; then
|
||||
# Calculate the CPU usage since we last checked.
|
||||
let "DIFF_IDLE=$IDLE-$PREV_IDLE"
|
||||
let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
|
||||
let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10"
|
||||
echo "${DIFF_USAGE}"
|
||||
else
|
||||
echo "?"
|
||||
fi
|
||||
|
||||
# Remember the total and idle CPU times for the next check.
|
||||
echo "${TOTAL}" > "${cpuFile}"
|
||||
echo "${IDLE}" >> "${cpuFile}"
|
||||
}
|
||||
|
||||
## Get Used memory
|
||||
get_mem() {
|
||||
printf "%.0f\n" "$(free -m | grep Mem | awk '{print ($3/$2)*100}')"
|
||||
}
|
||||
|
||||
## Get Volume
|
||||
get_vol() {
|
||||
pamixer --get-volume
|
||||
}
|
||||
|
||||
## Get Brightness
|
||||
get_brightness() {
|
||||
if [ -z "$DISPLAY_DEVICE" ]; then
|
||||
brightnessctl i --machine-readable | tr ',' ' ' | awk '{print $4}' | tr -d '%'
|
||||
else
|
||||
brightnessctl i -d $DISPLAY_DEVICE --machine-readable | tr ',' ' ' | awk '{print $4}' | tr -d '%'
|
||||
fi
|
||||
}
|
||||
|
||||
## Execute accordingly
|
||||
if [[ "$1" == "--cpu" ]]; then
|
||||
get_cpu
|
||||
elif [[ "$1" == "--mem" ]]; then
|
||||
get_mem
|
||||
elif [[ "$1" == "--vol" ]]; then
|
||||
get_vol
|
||||
elif [[ "$1" == "--bri" ]]; then
|
||||
get_brightness
|
||||
fi
|
||||
157
config/eww/Main/scripts/weather
Executable file
157
config/eww/Main/scripts/weather
Executable file
@@ -0,0 +1,157 @@
|
||||
#!/bin/bash
|
||||
|
||||
## Collect data
|
||||
cache_dir="$HOME/.cache/eww/weather"
|
||||
cache_weather_stat=${cache_dir}/weather-stat
|
||||
cache_weather_degree=${cache_dir}/weather-degree
|
||||
cache_weather_hex=${cache_dir}/weather-hex
|
||||
cache_weather_icon=${cache_dir}/weather-icon
|
||||
cache_weather_updatetime=${cache_dir}/weather-updatetime
|
||||
|
||||
if [[ -z "$OPENWEATHER_API_KEY" ]]; then
|
||||
echo "Please set the OPENWEATHER_API_KEY environment variable."
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "$OPENWEATHER_LAT" ]]; then
|
||||
echo "Please set the OPENWEATHER_LAT environment variable."
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "$OPENWEATHER_LON" ]]; then
|
||||
echo "Please set the OPENWEATHER_LON environment variable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Weather data
|
||||
KEY=$OPENWEATHER_API_KEY
|
||||
LAT=$OPENWEATHER_LAT
|
||||
LON=$OPENWEATHER_LON
|
||||
UNITS=metric
|
||||
|
||||
## Make cache dir
|
||||
if [[ ! -d "$cache_dir" ]]; then
|
||||
mkdir -p "${cache_dir}"
|
||||
fi
|
||||
|
||||
## Get data
|
||||
get_weather_data() {
|
||||
weather=$(curl -sf "http://api.openweathermap.org/data/3.0/onecall?lat=${LAT}&lon=${LON}&exclude=minutely,hourly,daily&appid=${KEY}&units=${UNITS}")
|
||||
echo "${weather}" >&2
|
||||
weather=$(echo "$weather" | jq -r ".current")
|
||||
|
||||
if [ -n "$weather" ]; then
|
||||
weather_temp=$(echo "$weather" | jq ".temp" | cut -d "." -f 1)
|
||||
weather_icon_code=$(echo "$weather" | jq -r ".weather[].icon" | head -1)
|
||||
weather_description=$(echo "$weather" | jq -r ".weather[].description" | head -1 | sed -e "s/\b\(.\)/\u\1/g")
|
||||
|
||||
#Big long if statement of doom
|
||||
if [ "$weather_icon_code" == "50d" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#7aa2f7"
|
||||
elif [ "$weather_icon_code" == "50n" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#7aa2f7"
|
||||
elif [ "$weather_icon_code" == "01d" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#e0af68"
|
||||
elif [ "$weather_icon_code" == "01n" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#c0caf5"
|
||||
elif [ "$weather_icon_code" == "02d" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#7aa2f7"
|
||||
elif [ "$weather_icon_code" == "02n" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#7aa2f7"
|
||||
elif [ "$weather_icon_code" == "03d" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#7aa2f7"
|
||||
elif [ "$weather_icon_code" == "03n" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#7aa2f7"
|
||||
elif [ "$weather_icon_code" == "04d" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#7aa2f7"
|
||||
elif [ "$weather_icon_code" == "04n" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#7aa2f7"
|
||||
elif [ "$weather_icon_code" == "09d" ]; then
|
||||
weather_icon=""
|
||||
weather_hex="#7dcfff"
|
||||
elif [ "$weather_icon_code" == "09n" ]; then
|
||||
weather_icon=""
|
||||
weather_hex="#7dcfff"
|
||||
elif [ "$weather_icon_code" == "10d" ]; then
|
||||
weather_icon=""
|
||||
weather_hex="#7dcfff"
|
||||
elif [ "$weather_icon_code" == "10n" ]; then
|
||||
weather_icon=""
|
||||
weather_hex="#7dcfff"
|
||||
elif [ "$weather_icon_code" == "11d" ]; then
|
||||
weather_icon=""
|
||||
weather_hex="#ff9e64"
|
||||
elif [ "$weather_icon_code" == "11n" ]; then
|
||||
weather_icon=""
|
||||
weather_hex="#ff9e64"
|
||||
elif [ "$weather_icon_code" == "13d" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#c0caf5"
|
||||
elif [ "$weather_icon_code" == "13n" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#c0caf5"
|
||||
elif [ "$weather_icon_code" == "40d" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#7dcfff"
|
||||
elif [ "$weather_icon_code" == "40n" ]; then
|
||||
weather_icon=" "
|
||||
weather_hex="#7dcfff"
|
||||
else
|
||||
weather_icon=" "
|
||||
weather_hex="#c0caf5"
|
||||
fi
|
||||
echo "$weather_icon" > "${cache_weather_icon}"
|
||||
echo "$weather_description" > "${cache_weather_stat}"
|
||||
echo "$weather_temp""°C" > "${cache_weather_degree}"
|
||||
echo "$weather_hex" > "${cache_weather_hex}"
|
||||
date "+%Y-%m-%d %H:%M:%S" | tee "${cache_weather_updatetime}" >/dev/null
|
||||
else
|
||||
echo "Weather Unavailable" > "${cache_weather_stat}"
|
||||
echo " " > "${cache_weather_icon}"
|
||||
echo "-" > "${cache_weather_degree}"
|
||||
echo "#adadff" > "${cache_weather_hex}"
|
||||
date "+%Y-%m-%d %H:%M:%S" | tee "${cache_weather_updatetime}" >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
check_network() {
|
||||
local max=12
|
||||
local cnt=0
|
||||
|
||||
while [ $cnt -lt $max ]; do
|
||||
if ping -c1 8.8.8.8 &>/dev/null || ping -c1 1.1.1.1 &>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
echo "Waiting for network connection... (attempt: $((cnt + 1))/$max)" >&2
|
||||
sleep 5
|
||||
((cnt++))
|
||||
done
|
||||
|
||||
echo "Network connection failed after $max attempts." >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
## Execute
|
||||
if [[ "$1" == "--getdata" ]]; then
|
||||
if check_network; then
|
||||
get_weather_data
|
||||
fi
|
||||
elif [[ "$1" == "--icon" ]]; then
|
||||
cat "${cache_weather_icon}"
|
||||
elif [[ "$1" == "--temp" ]]; then
|
||||
cat "${cache_weather_degree}"
|
||||
elif [[ "$1" == "--hex" ]]; then
|
||||
tail -F "${cache_weather_hex}"
|
||||
elif [[ "$1" == "--stat" ]]; then
|
||||
cat "${cache_weather_stat}"
|
||||
elif [[ "$1" == "--updatetime" ]]; then
|
||||
cat "${cache_weather_updatetime}"
|
||||
fi
|
||||
20
config/eww/apply-color
Executable file
20
config/eww/apply-color
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
path=$(dirname "$(readlink -f "$0")")
|
||||
. "$path"/../../utils/apply-color-helper
|
||||
|
||||
file="$path"/eww.scss
|
||||
|
||||
sed -i "s|^\$border: #[0-9a-fA-F]\{6\};\$|\$border: #${colorHex};|" "$file" || {
|
||||
log_error "Failed to edit ${file}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if pgrep -x eww >/dev/null -u "$USER"; then
|
||||
eww reload || {
|
||||
log_error "Failed to reload eww, is it running?"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
log_success "eww"
|
||||
23
config/eww/eww.scss
Normal file
23
config/eww/eww.scss
Normal file
@@ -0,0 +1,23 @@
|
||||
/** Colors *******************************************/
|
||||
$bg: #1e1e2e;
|
||||
$bg-alt: #181825;
|
||||
$fg: #cdd6f4;
|
||||
$fg-alt: #a6adc8;
|
||||
$red: #f38ba8;
|
||||
$green: #a6e3a1;
|
||||
$yellow: #f9e2af;
|
||||
$orange: #fab387;
|
||||
$blue: #89b4fa;
|
||||
$purple: #cba6f7;
|
||||
$cyan: #89dceb;
|
||||
$gray: #585b70;
|
||||
$gray-alt: #292a3c;
|
||||
$lavender: #b4befe;
|
||||
$sapphire: #74c7ec;
|
||||
$teal: #94e2d5;
|
||||
$peach: #fab387;
|
||||
|
||||
$border: #89b4fa;
|
||||
|
||||
@import './Main/eww.scss';
|
||||
@import './Lyrics/eww.scss';
|
||||
2
config/eww/eww.yuck
Normal file
2
config/eww/eww.yuck
Normal file
@@ -0,0 +1,2 @@
|
||||
(include "./Main/eww.yuck")
|
||||
(include "./Lyrics/eww.yuck")
|
||||
Reference in New Issue
Block a user