Téléverser les fichiers vers "/"
This commit is contained in:
parent
8ea8820cb3
commit
bbaf2820fa
1 changed files with 46 additions and 0 deletions
46
rgb.sh
Normal file
46
rgb.sh
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ "$(whoami)" != 'root' ]; then
|
||||
echo "Script needs to be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Creating Python Script...";
|
||||
cat << 'EOF' > /var/rgb.py
|
||||
#!/bin/python
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
steps = 20
|
||||
|
||||
colors = [[255, 0, 0], [0, 255, 0], [0, 0, 255], [0, 255, 255], [255, 0, 255], [255, 255, 0], [255, 255, 255]]
|
||||
|
||||
def aTob(a, b):
|
||||
incr = [(b[0] - a[0]) / steps, (b[1] - a[1]) / steps, (b[2] - a[2]) / steps]
|
||||
tmp = [a[0], a[1], a[2]]
|
||||
for i in range(steps):
|
||||
tmp[0] += incr[0]
|
||||
tmp[1] += incr[1]
|
||||
tmp[2] += incr[2]
|
||||
subprocess.run(f"echo \"{int(tmp[0])} {int(tmp[1])} {int(tmp[2])}\" > /sys/class/leds/rgb:kbd_backlight/multi_intensity", shell=True)
|
||||
time.sleep(0.1)
|
||||
|
||||
while True:
|
||||
c = colors[0]
|
||||
for i in range(1, len(colors)):
|
||||
aTob(c, colors[i])
|
||||
c = colors[i]
|
||||
aTob(c, colors[0])
|
||||
EOF
|
||||
|
||||
chmod +x /var/rgb.py
|
||||
|
||||
if [ ! $(crontab -l|grep -q "@reboot cd /var && ./rgb.py") ]; then
|
||||
echo "Addind Cron job...";
|
||||
crontab -l > cronhistory;
|
||||
echo "@reboot cd /var && ./rgb.py" >> cronhistory;
|
||||
crontab cronhistory
|
||||
rm cronhistory
|
||||
fi
|
||||
|
||||
echo "Finished!"
|
Loading…
Add table
Reference in a new issue