-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtgoeswallctrl
executable file
·95 lines (77 loc) · 2.32 KB
/
tgoeswallctrl
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
#!/bin/bash
#This file is part of the TinyTools distribution (https://github.com/Calebe94/TinyTools).
#Copyright (C) TinyTools
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, version 3 of the License.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
CFG_FILE_PATH="/etc/tinytools/tgoeswall.conf"
image_path="/tmp/tgoeswall"
resolution_image="1808"
feh_args="--bg-max"
load_config_file()
{
echo "Loading config from file..."
aux_image_path=$(tyaml $CFG_FILE_PATH -v path)
[ ! -z $aux_image_path ] && image_path=$aux_image_path
aux_resolution_image=$(tyaml $CFG_FILE_PATH -v resolution)
[ ! -z $aux_resolution_image ] && resolution_image=$aux_resolution_image
aux_feh_args=$(tyaml $CFG_FILE_PATH -v feh_args)
[ ! -z $aux_feh_args ] && feh_args=$aux_feh_args
echo "Config loaded:"
echo "$image_path"
echo "$resolution_image"
echo "$feh_args"
}
download_goes_image()
{
echo "Downloading image with resolution $resolution_image..."
tgoeswall -r $resolution_image $image_path
}
apply_wallpaper()
{
echo "Applying image with resolution ($resolution_image) with feh args($feh_args)..."
DISPLAY=:0 XAUTHORITY=~/.Xauthority feh $feh_args $image_path/$resolution_image*.jpg
}
[ -f $CFG_FILE_PATH ] && load_config_file
[ ! -d $image_path ] && mkdir $image_path
daemon_reload()
{
systemctl --user daemon-reload
}
start_method()
{
systemctl --user start tgoeswall.timer
}
enable_method()
{
systemctl --user enable tgoeswall.timer
start_method
}
usage()
{
echo "usage: tgoeswallctrl"
echo "options:"
echo "-s|--start|start: start the service"
echo "-h|--help|help: show the usage"
exit 0
}
case "$1" in
-s | --start | start)
daemon_reload
enable_method
start_method
;;
-h | --help | help)
usage
;;
*)
download_goes_image
apply_wallpaper
;;
esac