blob: 7e17b820c71aa3cf04d54a3570d340bd26900366 (
plain)
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
|
#!/usr/bin/bash
wallDir=/media/Wall
cmd='nitrogen --set-zoom-fill %s'
if [ -n "$WAYLAND_DISPLAY" ] ; then
cmd='swaymsg output "*" background %s fill'
fi
if [ -e ~/.savedWall ] ; then
wall=$(cat ~/.savedWall)
cmd=$(printf "${cmd}" ${wall})
echo ${cmd}
eval ${cmd}
exit
fi
for action in $@
do
if [ ${action:0:1} = "+" ]
then
if [ -d ${wallDir}/${action:1} ]
then
echo ${action:1}/ >> ${wallDir}/listDirWall
fi
fi
if [ ${action} = "list" ]
then
for d in `ls ${wallDir}`
do
if [ -d "${wallDir}/${d}" ]; then
echo "$d/"
fi
done
echo
fi
if [ ${action} = "save" ]
then
cp ~/.actWall ~/.savedWall
exit
fi
if [ ${action} = "unsave" ]
then
rm ~/.savedWall
exit
fi
if [ ${action:0:1} = "-" ]
then
if [ -d ${wallDir}/${action:1} ]
then
sed -i "/${action:1}/d" ${wallDir}/listDirWall
fi
fi
if [ ${action:0:1} = "=" ]
then
if [ -d ${wallDir}/${action:1} ]
then
sed -i "/^${action:1}\/$/d" ${wallDir}/listDirWall
fi
fi
done
cmpWall=0
for ligne in `cat ${wallDir}/listDirWall`
do
cmpWall=$(( cmpWall + `ls "${wallDir}/$ligne" | wc -l` ))
echo "$ligne : "
done
randWall=$[( $RANDOM % $cmpWall )]
for ligne in `cat ${wallDir}/listDirWall`
do
if [ `ls "${wallDir}/$ligne" | wc -l` -gt $randWall ]
then
wall=${wallDir}/$ligne`ls ${wallDir}/$ligne | head -n $randWall | tail -n 1`
echo ${wall} > ~/.actWall
cmd=$(printf "${cmd}" ${wall})
echo ${cmd}
eval ${cmd}
echo "Wall set $wall"
break
else
randWall=$(( randWall - `ls "${wallDir}/$ligne" | wc -l` ))
fi
done
echo $cmpWall
|