-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwallpaper.bash
More file actions
executable file
·90 lines (73 loc) · 2.01 KB
/
Copy pathwallpaper.bash
File metadata and controls
executable file
·90 lines (73 loc) · 2.01 KB
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
#!/usr/bin/env bash
# Set random wallpaper
projectdir=$(realpath `dirname $0`)
path_to_app=$projectdir/out/note-linux-x64/note
function getImageName
{
local tag=$(echo "$1" | rev | cut -d'/' -f2 | rev)
local name=$(echo "$1" | rev | cut -d'/' -f1 | rev | cut -d'.' -f1)
local file="$projectdir/content/_images/$tag.$name.png"
echo "$file"
}
function saveImg
{
local file=$(getImageName "$1")
cp -u "$projectdir/image_of_page.png" "$file"
}
function getColorScheme
{
local color_scheme=$(gsettings get org.gnome.desktop.interface color-scheme)
if [[ "$color_scheme" = "prefer-dark" ]]; then
local color_scheme="picture-uri-dark"
else
local color_scheme="picture-uri"
fi
echo "$color_scheme"
}
function callActionWallpaperSet
{
gsettings set org.gnome.desktop.background $(getColorScheme) "file://$1"
}
function setWallpaper
{
if [[ -n $1 ]]; then
callActionWallpaperSet "$1"
exit
fi
callActionWallpaperSet "$projectdir/image_of_page.png"
}
function setFromExist
{
local file=$(getImageName "$1")
if [[ -e $file ]]; then
setWallpaper "$file"
exit
fi
}
function isNeedUpdate
{
local directoryDate=$(stat ./dist | grep Modify | cut -d' ' -f2)
git log --oneline --after $directoryDate | wc -l
}
if [[ ! -e $path_to_app ]]; then
echo "App for create and set wallpaper not exist!"
echo "First you need to build it, run: npm run make"
exit
fi
if [[ ! -d "$projectdir/dist" ]]; then
echo "HTML pages not exist!"
echo "First you need build static web site, run: npm run build-static"
exit
fi
if [[ ! isNeedUpdate -eq 0 ]]; then
echo "You need update web version of applicattion, *.html files"
echo "Run command 'npm run build-static' in application directory"
exit
fi
files=($projectdir/dist/**/*.html)
randomfile=$(printf "%s\n" "${files[RANDOM % ${#files[@]}]}")
setFromExist "$randomfile"
$path_to_app $projectdir $randomfile 2>/dev/null
saveImg "$randomfile"
sleep 10s
setWallpaper