-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.xinitrc
65 lines (58 loc) · 1.74 KB
/
.xinitrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
xset -b
xbindkeys
bat_dir=/sys/class/power_supply/BAT0/
batfull=`cat $bat_dir/energy_full`
while true; do
# Date and time
date_str=`date "+%A %d. %B %H:%M"`
# Memory
mem_str=`free | sed -n 2p | awk '{ printf "%d.2%s", 100*$3/$2, "%" }'`
mem_str="[MEM] $mem_str"
# Battery
bat_str=$((100 * `cat $bat_dir/energy_now` / batfull))
if [ "$(cat $bat_dir/status)" = "Discharging" ]; then
bat_str="[BAT] $bat_str%"
else
bat_str="[AC] ($bat_str%)"
fi
# Network
net_str=`ip -br -4 a | grep UP | awk '{printf "%s %s -- ", $1, $3 }'`
xsetroot -name "$net_str$bat_str -- $mem_str -- $date_str"
sleep 10s
done&
hsetroot -full ~/suckless.org/bkg.png
recent=~/.config/spotify/Users/kjempelodott-user/recently_played.bnk
font=/usr/share/texmf/fonts/opentype/public/tex-gyre/texgyreadventor-regular.otf
img_orig=$(mktemp)
img=$(mktemp)
last=
last_thumb=
while true; do
if pgrep spotify 2>&1 >/dev/null
then
cur=$(strings -20 $recent | grep track | head -1)
if [[ "$cur" != "$last" ]]
then
url="https://embed.spotify.com/oembed/?url=${cur:1}"
json=$(curl -X GET "$url" 2>/dev/null)
thumb=$(echo $json | jq -r '.thumbnail_url' | sed 's/cover/640/')
if [[ "$thumb" != "$last_thumb" ]]
then
curl -X GET "$thumb" 2>/dev/null > $img_orig
last_thumb=$thumb
fi
title=$(echo $json | jq -r '.title')
convert $img_orig -brightness-contrast -20x-20 $img
convert +append $img $img_orig $img $img
convert $img -bordercolor Black -border 0x100 $img
convert $img -gravity south -font $font -pointsize 50 -fill White -annotate 0 "$title" $img
hsetroot -center $img
last=$cur
fi
sleep 5
fi
sleep 10
done&
xss-lock slock &
xautolock -time 5 -locker slock &
exec dwm