eww updated and removed unnecessary things

This commit is contained in:
foglar 2025-02-18 17:43:51 +01:00
parent da01ac5190
commit 21f01007ca
13 changed files with 77 additions and 634 deletions

View File

@ -10,8 +10,8 @@
};
config = lib.mkIf config.app_list.programming.enable {
home.packages =
(with pkgs; [
home.packages = (
with pkgs; [
arduino-ide
distrobox
go

View File

@ -8,11 +8,17 @@
".local/share/icons/kogami/keyboard.svg".source = ../../../../config/icons/keyboard.svg;
};
services.playerctld.enable = true;
#services.mpd = {
# enable = true;
# musicDirectory = /home/shinya/Music;
#};
services.hypridle = {
enable = true;
settings = {
general = {
lock_cmd = "hyprctl switchxkblayout at-translated-set-2-keyboard 0 ; pidof hyprlock || hyprlock"; # avoid starting multiple hyprlock instances.
lock_cmd = "pidof hyprlock || hyprlock"; # avoid starting multiple hyprlock instances.
before_sleep_cmd = "loginctl lock-session"; # lock before suspend.
after_sleep_cmd = "hyprctl dispatch dpms on"; # to avoid having to press a key twice to turn on the display.
};
@ -55,6 +61,7 @@
wl-clipboard
cliphist
bc
#swww

View File

@ -2,6 +2,7 @@
lib,
config,
pkgs,
userSettings,
...
}: let
EWW_PATH = ".config/eww/dashboard";
@ -37,7 +38,7 @@ in {
".config/eww/dashboard/images/bg.jpg" = {
enable = true;
source = ./eww/dashboard/images/bg.jpg;
source = ../../../../config/backgrounds/${userSettings.background};
};
".config/eww/dashboard/eww.scss" = {
@ -59,7 +60,7 @@ in {
/** Generic window ***********************************/
.genwin {
background-color: #${config.lib.stylix.colors.base01};
background-color: #${config.lib.stylix.colors.base00};
border-radius: 16px;
}
@ -73,13 +74,13 @@ in {
}
.fullname {
color: #${config.lib.stylix.colors.base06};
color: #${config.lib.stylix.colors.base16};
font-size: 30px;
font-weight: bold;
}
.username {
color: #${config.lib.stylix.colors.base04};
color: #${config.lib.stylix.colors.base06};
font-size: 22px;
font-weight: bold;
margin: -15px 0px 0px 0px;
@ -97,13 +98,13 @@ in {
color: #${config.lib.stylix.colors.base05};
}
.iconmem {
color: #${config.lib.stylix.colors.base07};
color: #${config.lib.stylix.colors.base05};
}
.iconbright {
color: #${config.lib.stylix.colors.base02};
color: #${config.lib.stylix.colors.base05};
}
.iconbat {
color: #${config.lib.stylix.colors.base10};
color: #${config.lib.stylix.colors.base05};
}
.cpu_bar,
@ -112,7 +113,7 @@ in {
.bat_bar,
scale trough {
all: unset;
background-color: #${config.lib.stylix.colors.base11};
background-color: #${config.lib.stylix.colors.base02};
border-radius: 16px;
min-height: 28px;
min-width: 240px;
@ -128,16 +129,16 @@ in {
}
.cpu_bar scale trough highlight {
background-color: #${config.lib.stylix.colors.base05};
background-color: #${config.lib.stylix.colors.base09};
}
.mem_bar scale trough highlight {
background-color: #${config.lib.stylix.colors.base07};
background-color: #${config.lib.stylix.colors.base09};
}
.bright_bar scale trough highlight {
background-color: #${config.lib.stylix.colors.base02};
background-color: #${config.lib.stylix.colors.base09};
}
.bat_bar scale trough highlight {
background-color: #${config.lib.stylix.colors.base10};
background-color: #${config.lib.stylix.colors.base09};
}
/** Clock ********************************************/
@ -221,7 +222,7 @@ in {
font-weight: normal;
}
.btn_play {
color: #${config.lib.stylix.colors.base07};
color: #${config.lib.stylix.colors.base06};
font-size: 48px;
font-weight: bold;
}
@ -233,12 +234,12 @@ in {
.music_bar scale trough highlight {
all: unset;
background-color: #${config.lib.stylix.colors.base13};
background-color: #${config.lib.stylix.colors.base02};
border-radius: 8px;
}
.music_bar scale trough {
all: unset;
background-color: #${config.lib.stylix.colors.base11};
background-color: #${config.lib.stylix.colors.base04};
border-radius: 8px;
min-height: 20px;
min-width: 310px;
@ -470,7 +471,6 @@ in {
home.packages = with pkgs; [
brightnessctl
busybox
(writeShellScriptBin "eww-dashboard-toggle" ''
FILE="$HOME/${EWW_CACHE}"
@ -490,13 +490,7 @@ in {
system \
clock \
uptime \
music \
apps \
logout \
sleep \
reboot \
poweroff \
folders
music
}
## Launch or close widgets accordingly
@ -523,35 +517,26 @@ in {
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.
read -r _ user nice system idle rest < <(grep '^cpu ' /proc/stat)
IDLE=''${idle}
TOTAL=$((user + nice + system + idle))
# 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"
if [[ -n "''${PREV_TOTAL}" && -n "''${PREV_IDLE}" ]]; then
DIFF_IDLE=$((IDLE - PREV_IDLE))
DIFF_TOTAL=$((TOTAL - PREV_TOTAL))
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}')
free -m | awk '/^Mem:/ {printf "%.0f\n", ($3/$2)*100}'
}
## Execute accordingly

View File

@ -13,8 +13,8 @@
;; System vars
(defpoll HOST :interval "5s" `hostname`)
(defpoll CPU_USAGE :interval "1s" `scripts/sys_info --cpu`)
(defpoll MEM_USAGE :interval "1s" `scripts/sys_info --mem`)
(defpoll CPU_USAGE :interval "1s" `sys_info --cpu`)
(defpoll MEM_USAGE :interval "1s" `sys_info --mem`)
(defpoll BLIGHT :interval "1s" `echo $(( ($(brightnessctl g) * 100 + $(brightnessctl m) / 2) / $(brightnessctl m) ))`)
(defpoll BATTERY :interval "5s" `battery-hyprlock -p`)
@ -32,28 +32,15 @@
(defpoll ARTIST :interval "1s" `playerctl-hyprlock --artist`)
(defpoll STATUS :interval "1s" `playerctl-hyprlock --status`)
(defpoll COVER :interval "1s" `playerctl-hyprlock --cover`)
(defpoll CURRENT :interval "1s" `scripts/music_info --time`)
(defpoll CTIME :interval "1s" `scripts/music_info --ctime`)
(defpoll TTIME :interval "1s" `scripts/music_info --ttime`)
;; Weather vars
(defpoll ICON :interval "15m" `scripts/weather_info --icon`)
(defpoll STAT :interval "15m" `scripts/weather_info --stat`)
(defpoll TEMP :interval "15m" `scripts/weather_info --temp`)
(defpoll HEX :interval "15m" `scripts/weather_info --hex`)
(defpoll QUOTE :interval "15m" `scripts/weather_info --quote`)
(defpoll QUOTE2 :interval "15m" `scripts/weather_info --quote2`)
;; Apps vars
(defpoll MAILS :interval "5m" `scripts/mails`)
(defpoll CURRENT :interval "1s" `echo "scale=2; $(playerctl metadata --format "{{ position }}") / $(playerctl metadata --format "{{ mpris:length }}") * 100" | bc`)
(defpoll CTIME :interval "1s" `playerctl metadata --format "{{ duration(position) }}"`)
(defpoll TTIME :interval "1s" `playerctl metadata --format "{{ duration(mpris:length) }}"`)
;; Files vars
(defpoll FREE :interval "5s" `df -h / | awk '{print $4}' | tail -n 1 | sed 's/G/GB/'`)
;; ** Widgets *************************************************************************
;; background
(defwidget bg []
(box :class "bg")
@ -113,77 +100,7 @@
(button :class "btn_play" :onclick "playerctl play-pause" STATUS)
(button :class "btn_next" :onclick "playerctl next" ""))
(box :class "music_bar" :halign "center" :vexpand "false" :hexpand "false"
(scale :onscroll "mpc -q seek +1" :min 0 :active "true" :max 100 :value CURRENT)))))
;; github
(defwidget github []
(box :class "github" :vexpand "false" :hexpand "false"
(button :class "iconweb" :onclick "scripts/open_links --gh" " ")))
;; reddit
(defwidget reddit []
(box :class "reddit" :vexpand "false" :hexpand "false"
(button :class "iconweb" :onclick "scripts/open_links --rd" "󰑍 ")))
;; twitter
(defwidget twitter []
(box :class "twitter" :vexpand "false" :hexpand "false"
(button :class "iconweb" :onclick "scripts/open_links --tw" "")))
;; youtube
(defwidget youtube []
(box :class "youtube" :vexpand "false" :hexpand "false"
(button :class "iconweb" :onclick "scripts/open_links --yt" "")))
;; mail
(defwidget mail []
(box :class "mail"
(box :orientation "h" :halign "center" :spacing 20 :space-evenly "false" :vexpand "false" :hexpand "false"
(button :class "iconmail" :onclick "scripts/open_links --mail" "󰊫 ")
(box :class "mailbox" :space-evenly "false" :vexpand "false" :hexpand "false"
(button :class "label_mails" :onclick "scripts/open_links --mail" MAILS)))))
;; weather
(defwidget weather []
(box :class "genwin"
(box :orientation "v" :spacing 10 :space-evenly "false" :vexpand "false" :hexpand "false"
(box :orientation "h" :vexpand "false" :hexpand "false"
(label :class "iconweather" :halign "start" :style "color: ${HEX};" :text ICON)
(label :class "label_temp" :halign "end" :text TEMP))
(box :orientation "v" :spacing 10 :halign "center" :space-evenly "false" :vexpand "false" :hexpand "false"
(label :class "label_stat" :text STAT)
(label :class "label_quote" :text QUOTE)
(label :class "label_quote" :text QUOTE2)))))
;; apps
(defwidget apps []
(box :class "genwin" :orientation "v" :space-evenly "false" :vexpand "false" :hexpand "false"
(box :class "appbox" :orientation "h" :space-evenly "false" :vexpand "false" :hexpand "false"
(button :style "background-image: url('images/icons/firefox.svg');" :class "app_fox" :onclick "scripts/open_apps --ff")
(button :style "background-image: url('images/icons/telegram.svg');" :class "app_telegram" :onclick "scripts/open_apps --tg")
(button :style "background-image: url('images/icons/discord.svg');" :class "app_discord" :onclick "scripts/open_apps --dc"))
(box :class "appbox" :orientation "h" :space-evenly "false" :vexpand "false" :hexpand "false"
(button :style "background-image: url('images/icons/terminal.svg');" :class "app_terminal" :onclick "scripts/open_apps --tr")
(button :style "background-image: url('images/icons/files.svg');" :class "app_files" :onclick "scripts/open_apps --fm")
(button :style "background-image: url('images/icons/geany.svg');" :class "app_geany" :onclick "scripts/open_apps --ge"))
(box :class "appbox" :orientation "h" :space-evenly "false" :vexpand "false" :hexpand "false"
(button :style "background-image: url('images/icons/code.svg');" :class "app_code" :onclick "scripts/open_apps --cd")
(button :style "background-image: url('images/icons/gimp.svg');" :class "app_gimp" :onclick "scripts/open_apps --gp")
(button :style "background-image: url('images/icons/virtualbox.svg');" :class "app_vbox" :onclick "scripts/open_apps --vb"))))
;; power buttons
(defwidget logout []
(box :class "genwin" :vexpand "false" :hexpand "false"
(button :class "btn_logout" :onclick "" "󰍃 ")))
(defwidget sleep []
(box :class "genwin" :vexpand "false" :hexpand "false"
(button :class "btn_sleep" :onclick "systemctl suspend" "󰤄 ")))
(defwidget reboot []
(box :class "genwin" :vexpand "false" :hexpand "false"
(button :class "btn_reboot" :onclick "systemctl reboot" "󰑓 ")))
(defwidget poweroff []
(box :class "genwin" :vexpand "false" :hexpand "false"
(button :class "btn_poweroff" :onclick "systemctl poweroff" " ")))
(scale :onscroll "playerctl position 1+" :min 0 :active "true" :max 100 :value CURRENT)))))
;; folders
(defwidget folders []
@ -247,61 +164,6 @@
:geometry (geometry :x 515 :y 490 :width 610 :height 280)
(music))
;; github
(defwindow github :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 515 :y 785 :width 141 :height 145)
(github))
;; reddit
(defwindow reddit :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 671 :y 785 :width 141 :height 145)
(reddit))
;; twitter
(defwindow twitter :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 827 :y 785 :width 141 :height 145)
(twitter))
;; youtube
(defwindow youtube :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 983 :y 785 :width 142 :height 145)
(youtube))
;; weather
(defwindow weather :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 880 :y 150 :width 550 :height 325)
(weather))
;; apps
(defwindow apps :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 1140 :y 490 :width 290 :height 280)
(apps))
;; mail
(defwindow mail :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 1140 :y 785 :width 290 :height 145)
(mail))
;; logout
(defwindow logout :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 1445 :y 150 :width 155 :height 155)
(logout))
;; sleep
(defwindow sleep :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 1615 :y 150 :width 155 :height 155)
(sleep))
;; reboot
(defwindow reboot :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 1445 :y 320 :width 155 :height 155)
(reboot))
;; poweroff
(defwindow poweroff :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 1615 :y 320 :width 155 :height 155)
(poweroff))
;; folders
(defwindow folders :stacking "fg" :focusable "false" :monitor 0
:geometry (geometry :x 1445 :y 490 :width 325 :height 440)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 626 KiB

View File

@ -1,7 +0,0 @@
#!/bin/python
import imaplib
obj = imaplib.IMAP4_SSL('imap.gmail.com',993)
obj.login('username@gmail.com','PASSWORD') # write your email and password
obj.select()
print(len(obj.search(None, 'UnSeen')[1][0].split()))

View File

@ -1,103 +0,0 @@
#!/bin/sh
## Get data
STATUS="$(playerctl status)"
COVER="/tmp/.music_cover.jpg"
MUSIC_DIR="$HOME/Music"
## Get status
get_status() {
if [[ $STATUS == *"Playing"* ]]; then
echo ""
else
echo ""
fi
}
## Get song
get_song() {
playerctl-hyprlock --title
}
## Get artist
get_artist() {
playerctl-hyprlock --artist
}
## Get time
get_time() {
time=$(mpc status | grep "%)" | awk '{print $4}' | tr -d '(%)')
if [[ -z "$time" ]]; then
echo "0"
else
echo "$time"
fi
}
get_ctime() {
ctime=$(mpc status | grep "#" | awk '{print $3}' | sed 's|/.*||g')
if [[ -z "$ctime" ]]; then
echo "0:00"
else
echo "$ctime"
fi
}
get_ttime() {
ttime=$(mpc -f %time% current)
if [[ -z "$ttime" ]]; then
echo "0:00"
else
echo "$ttime"
fi
}
## Get cover
get_cover() {
DOWNLOAD_PATH="$HOME/.cache/cover.png"
FALLBACK_PATH="./images/music.png" # Change this to your static image path
# Get the image URL from playerctl
URL=$(playerctl metadata mpris:artUrl 2>/dev/null)
# If the URL is empty or playerctl fails, return the fallback path
if [[ -z "$URL" ]]; then
echo "$FALLBACK_PATH"
return
fi
# Try downloading the image
if curl -s -o "$DOWNLOAD_PATH" "$URL"; then
echo "$DOWNLOAD_PATH"
else
echo "$FALLBACK_PATH"
fi
}
## Execute accordingly
if [[ "$1" == "--song" ]]; then
get_song
elif [[ "$1" == "--artist" ]]; then
get_artist
elif [[ "$1" == "--status" ]]; then
get_status
elif [[ "$1" == "--time" ]]; then
get_time
elif [[ "$1" == "--ctime" ]]; then
get_ctime
elif [[ "$1" == "--ttime" ]]; then
get_ttime
elif [[ "$1" == "--cover" ]]; then
get_cover
elif [[ "$1" == "--toggle" ]]; then
mpc -q toggle
elif [[ "$1" == "--next" ]]; then
{
mpc -q next
get_cover
}
elif [[ "$1" == "--prev" ]]; then
{
mpc -q prev
get_cover
}
fi

View File

@ -1,42 +0,0 @@
#!/bin/sh
## Open Applications
FILE="$HOME/.cache/eww_launch.dashboard"
CFG="$HOME/.config/eww/dashboard"
EWW=$(which eww)
close_dash() {
${EWW} --config "$CFG" close \
background profile system clock uptime music github \
reddit twitter youtube weather apps mail logout sleep reboot poweroff folders
rm -rf "$FILE"
}
if [[ "$1" == "--ff" ]]; then
close_dash && firefox &
elif [[ "$1" == "--tg" ]]; then
close_dash && telegram-desktop &
elif [[ "$1" == "--dc" ]]; then
close_dash && discord &
elif [[ "$1" == "--tr" ]]; then
close_dash && alacritty --working-directory ~ &
elif [[ "$1" == "--fm" ]]; then
close_dash && thunar ~ &
elif [[ "$1" == "--ge" ]]; then
close_dash && geany &
elif [[ "$1" == "--cd" ]]; then
close_dash && code &
elif [[ "$1" == "--gp" ]]; then
close_dash && gimp &
elif [[ "$1" == "--vb" ]]; then
close_dash && virtualbox &
fi

View File

@ -1,33 +0,0 @@
#!/bin/sh
## Open folders in thunar
FILE="$HOME/.cache/eww_launch.dashboard"
CFG="$HOME/.config/eww/dashboard"
EWW=$(which eww)
close_dash() {
${EWW} --config "$CFG" close \
background profile system clock uptime music github \
reddit twitter youtube weather apps mail logout sleep reboot poweroff folders
rm -rf "$FILE"
}
if [[ "$1" == "--dl" ]]; then
close_dash && xdg-open ~/Downloads &
elif [[ "$1" == "--docs" ]]; then
close_dash && xdg-open ~/Documents &
elif [[ "$1" == "--music" ]]; then
close_dash && xdg-open ~/Music &
elif [[ "$1" == "--pics" ]]; then
close_dash && xdg-open ~/Pictures &
elif [[ "$1" == "--cfg" ]]; then
close_dash && xdg-open ~/.config &
elif [[ "$1" == "--local" ]]; then
close_dash && xdg-open ~/.local/share &
fi

View File

@ -1,31 +0,0 @@
#!/bin/sh
## Open links in firefox
FILE="$HOME/.cache/eww_launch.dashboard"
CFG="$HOME/.config/eww/dashboard"
EWW=$(which eww)
cmd="xdg-open"
close_dash() {
${EWW} --config "$CFG" close \
background profile system clock uptime music github \
reddit twitter youtube weather apps mail logout sleep reboot poweroff folders
rm -rf "$FILE"
}
if [[ "$1" == "--mail" ]]; then
close_dash && ${cmd} "https://mail.google.com"
elif [[ "$1" == "--gh" ]]; then
close_dash && ${cmd} "https://github.com"
elif [[ "$1" == "--rd" ]]; then
close_dash && ${cmd} "https://reddit.com"
elif [[ "$1" == "--tw" ]]; then
close_dash && ${cmd} "https://twitter.com"
elif [[ "$1" == "--yt" ]]; then
close_dash && ${cmd} "https://youtube.com"
fi

View File

@ -1,67 +0,0 @@
#!/bin/sh
## 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 Brightness
get_blight() {
echo $(( ($(brightnessctl g) * 100 + $(brightnessctl m) / 2) / $(brightnessctl m) ))
}
## Get Battery
get_battery() {
BAT=`ls /sys/class/power_supply | grep BAT | head -n 1`
cat /sys/class/power_supply/${BAT}/capacity
}
## Execute accordingly
if [[ "$1" == "--cpu" ]]; then
get_cpu
elif [[ "$1" == "--mem" ]]; then
get_mem
elif [[ "$1" == "--blight" ]]; then
get_blight
elif [[ "$1" == "--bat" ]]; then
get_battery
fi

View File

@ -1,146 +0,0 @@
#!/bin/sh
## Collect data
cache_dir="$HOME/.cache/eww/weather"
cache_weather_stat=${cache_dir}/weather-stat
cache_weather_degree=${cache_dir}/weather-degree
cache_weather_quote=${cache_dir}/weather-quote
cache_weather_hex=${cache_dir}/weather-hex
cache_weather_icon=${cache_dir}/weather-icon
## Weather data
KEY="YOUR_KEY"
ID="CITY_ID"
UNIT="metric" # Available options : 'metric' or 'imperial'
## 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/2.5/weather?APPID="$KEY"&id="$ID"&units="$UNIT"")
echo ${weather}
if [ ! -z "$weather" ]; then
weather_temp=$(echo "$weather" | jq ".main.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_quote="Forecast says it's misty \nMake sure you don't get lost on your way..."
weather_hex="#84afdb"
elif [ "$weather_icon_code" == "50n" ]; then
weather_icon=" "
weather_quote="Forecast says it's a misty night \nDon't go anywhere tonight or you might get lost..."
weather_hex="#84afdb"
elif [ "$weather_icon_code" == "01d" ]; then
weather_icon=" "
weather_quote="It's a sunny day, gonna be fun! \nDon't go wandering all by yourself though..."
weather_hex="#ffd86b"
elif [ "$weather_icon_code" == "01n" ]; then
weather_icon=" "
weather_quote="It's a clear night \nYou might want to take a evening stroll to relax..."
weather_hex="#fcdcf6"
elif [ "$weather_icon_code" == "02d" ]; then
weather_icon=" "
weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..."
weather_hex="#adadff"
elif [ "$weather_icon_code" == "02n" ]; then
weather_icon=" "
weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?"
weather_hex="#adadff"
elif [ "$weather_icon_code" == "03d" ]; then
weather_icon=" "
weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..."
weather_hex="#adadff"
elif [ "$weather_icon_code" == "03n" ]; then
weather_icon=" "
weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?"
weather_hex="#adadff"
elif [ "$weather_icon_code" == "04d" ]; then
weather_icon=" "
weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..."
weather_hex="#adadff"
elif [ "$weather_icon_code" == "04n" ]; then
weather_icon=" "
weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?"
weather_hex="#adadff"
elif [ "$weather_icon_code" == "09d" ]; then
weather_icon=" "
weather_quote="It's rainy, it's a great day! \nGet some ramen and watch as the rain falls..."
weather_hex="#6b95ff"
elif [ "$weather_icon_code" == "09n" ]; then
weather_icon=" "
weather_quote=" It's gonna rain tonight it seems \nMake sure your clothes aren't still outside..."
weather_hex="#6b95ff"
elif [ "$weather_icon_code" == "10d" ]; then
weather_icon=" "
weather_quote="It's rainy, it's a great day! \nGet some ramen and watch as the rain falls..."
weather_hex="#6b95ff"
elif [ "$weather_icon_code" == "10n" ]; then
weather_icon=" "
weather_quote=" It's gonna rain tonight it seems \nMake sure your clothes aren't still outside..."
weather_hex="#6b95ff"
elif [ "$weather_icon_code" == "11d" ]; then
weather_icon=""
weather_quote="There's storm for forecast today \nMake sure you don't get blown away..."
weather_hex="#ffeb57"
elif [ "$weather_icon_code" == "11n" ]; then
weather_icon=""
weather_quote="There's gonna be storms tonight \nMake sure you're warm in bed and the windows are shut..."
weather_hex="#ffeb57"
elif [ "$weather_icon_code" == "13d" ]; then
weather_icon=" "
weather_quote="It's gonna snow today \nYou'd better wear thick clothes and make a snowman as well!"
weather_hex="#e3e6fc"
elif [ "$weather_icon_code" == "13n" ]; then
weather_icon=" "
weather_quote="It's gonna snow tonight \nMake sure you get up early tomorrow to see the sights..."
weather_hex="#e3e6fc"
elif [ "$weather_icon_code" == "40d" ]; then
weather_icon=" "
weather_quote="Forecast says it's misty \nMake sure you don't get lost on your way..."
weather_hex="#84afdb"
elif [ "$weather_icon_code" == "40n" ]; then
weather_icon=" "
weather_quote="Forecast says it's a misty night \nDon't go anywhere tonight or you might get lost..."
weather_hex="#84afdb"
else
weather_icon=" "
weather_quote="Sort of odd, I don't know what to forecast \nMake sure you have a good time!"
weather_hex="#adadff"
fi
echo "$weather_icon" >${cache_weather_icon}
echo "$weather_description" >${cache_weather_stat}
echo "$weather_temp""°C" >${cache_weather_degree}
echo -e "$weather_quote" >${cache_weather_quote}
echo "$weather_hex" >${cache_weather_hex}
else
echo "Weather Unavailable" >${cache_weather_stat}
echo " " >${cache_weather_icon}
echo -e "Ah well, no weather huh? \nEven if there's no weather, it's gonna be a great day!" >${cache_weather_quote}
echo "-" >${cache_weather_degree}
echo "#adadff" >${tcache_weather_hex}
fi
}
## Execute
if [[ "$1" == "--getdata" ]]; then
get_weather_data
elif [[ "$1" == "--icon" ]]; then
cat ${cache_weather_icon}
elif [[ "$1" == "--temp" ]]; then
cat ${cache_weather_degree}
elif [[ "$1" == "--hex" ]]; then
cat ${cache_weather_hex}
elif [[ "$1" == "--stat" ]]; then
cat ${cache_weather_stat}
elif [[ "$1" == "--quote" ]]; then
cat ${cache_weather_quote} | head -n1
elif [[ "$1" == "--quote2" ]]; then
cat ${cache_weather_quote} | tail -n1
fi

View File

@ -113,6 +113,18 @@
fi
}
get_watched_length() {
total_length=$(playerctl metadata --format "{{ duration(mpris:length) }}" | awk -F: '{ print ($1 * 60) + $2 }')
current_position=$(playerctl metadata --format "{{ duration(position) }}" | awk -F: '{ print ($1 * 60) + $2 }')
if [[ "$total_length" -gt 0 ]]; then
percentage=$(awk "BEGIN { printf \"%.2f\", ($current_position / $total_length) * 100 }")
echo "$percentage"
else
echo "Error: Unable to retrieve media length."
fi
}
# Function to truncate text with ellipsis if necessary
truncate_with_ellipsis() {
text=$1
@ -158,7 +170,7 @@
elif [[ $status == "Paused" ]]; then
echo ""
else
echo ""
echo ""
fi
;;
--album)
@ -183,6 +195,12 @@
--cover)
get_cover
;;
--watched)
get_watched_length
;;
--current)
echo "scale=2; $(playerctl metadata --format "{{ position }}") / $(playerctl metadata --format "{{ mpris:length }}") * 100" | ${pkgs.bc}/bin/bc
;;
*)
echo "Invalid option: $1"
echo "Usage: $0 --title | --artist | --album | --source | --source-symbol"