-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwallpaper-augment
executable file
·100 lines (87 loc) · 3.33 KB
/
wallpaper-augment
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#! /usr/bin/env bash
TEMP_DIR=/home/rohitt/ramdisk
FILE_TO_WATCH=$TEMP_DIR/wallpaper-augment-file
convert -size 1920X1080 gradient:none-#000000aa -function Polynomial -4,4,0 -evaluate Pow 0.9 $TEMP_DIR/grad.png
check_if_wallpaper_needs_changing() {
CMUS=$(cmus-status | cut -f 2- -d ')')
WATSON="Watson: $(watson status)"
CURR_URL=$(gsettings get org.gnome.desktop.background picture-uri)
CURR_URL=${CURR_URL#"'file://"}
CURR_URL=${CURR_URL%"'"}
TIME=$(date "+%I:%M %p")
PLAYING=$(cmus-remote -Q | head -n 1 | cut -f 2 -d ' ')
BLUR_VALUE=$(jq .wallpaper.blur ~/.config/rohitt.json)
STATUS_CONTENT="$CMUS|$WATSON|$CURR_URL|$TIME|$PLAYING|$BLUR_VALUE"
FILE_CONTENT=$(cat $FILE_TO_WATCH | tr '\n' ' ')
diff -w <(echo "$FILE_CONTENT") <(echo "$STATUS_CONTENT" | cut -c 2-) >/dev/null
if [ $? != 0 ]; then
echo $STATUS_CONTENT > $FILE_TO_WATCH
echo "wallpaper-augment: Writing changes."
return 0 # trigger change
fi
return 1
}
augment_wallpaper() {
CURR_URL=$(gsettings get org.gnome.desktop.background picture-uri)
CURR_URL=${CURR_URL#"'file://"}
CURR_URL=${CURR_URL%"'"}
string='My long string'
if [[ $CURR_URL != *"variety/wallpaper/wallpaper-filter"* ]]; then
# Fail if not a variety wallpaper. We do not want to modify wallpapers not by variety
# or we can accidentally modify the original wallpaper file.
echo "wallpaper-augment: Fatal error. Tried operating on a non-variety wallpaper."
return 1
fi
if test -f "$CURR_URL.original"; then
echo "wallpaper-augment: Using existing wallpaper."
else
echo "wallpaper-augment: Using new wallpaper."
rm ~/.config/variety/wallpaper/*.original
# add black overlay to wallpaper, and use it as base for further changes.
convert $CURR_URL $TEMP_DIR/grad.png -gravity center -compose hardlight -composite $CURR_URL.original
fi
CMUS=$(cmus-status | cut -f 2- -d ')')
WATSON="Watson: $(watson status)"
TIME=$(date "+%I:%M %p")
DATE=$(date "+%A, %B %d")
PLAYING=$(cmus-remote -Q | head -n 1 | cut -f 2 -d ' ')
BLUR_VALUE=$(jq .wallpaper.blur ~/.config/rohitt.json)
PLAYING_ICON="play.png"
CMUS_COLOR="white"
if [ "$PLAYING" = "paused" ]; then
PLAYING_ICON="dull_pause.png"
CMUS_COLOR="#77777777"
fi
WATSON_COLOR="white"
if [ "$WATSON" = "Watson: No project started." ]; then
WATSON_COLOR="#77777777"
fi
convert $CURR_URL.original -channel RGBA -blur 0x$BLUR_VALUE $TEMP_DIR/post-blur
convert $TEMP_DIR/post-blur -font 'Roboto-Condensed-Regular'\
-gravity west -pointsize 30\
-fill '#00000044' -annotate +88+418 "$CMUS"\
-fill $CMUS_COLOR -annotate +90+420 "$CMUS"\
-fill '#00000044' -annotate +88+458 "$WATSON"\
-fill $WATSON_COLOR -annotate +90+460 "$WATSON"\
-gravity East -pointsize 100\
-fill '#00000044' -annotate +48+383 "$TIME"\
-fill white -annotate +50+385 "$TIME"\
-pointsize 30\
-fill '#00000044' -annotate +48+458 "$DATE"\
-fill '#77777777' -annotate +50+460 "$DATE"\
$TEMP_DIR/post-text
convert $TEMP_DIR/post-text /home/rohitt/Documents/scripts/assets/$PLAYING_ICON\
-gravity west -geometry +50+420 -composite $TEMP_DIR/post-icon
cp $TEMP_DIR/post-icon $CURR_URL
# rm $CURR_URL.*.temp
echo "wallpaper-augment: Setting $CURR_URL."
}
augment_wallpaper
while true; do
if check_if_wallpaper_needs_changing; then
augment_wallpaper
fi
sleep 1
done
# kill all processes
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT