Kod: Markera allt
#!/bin/bash
trans1=$(which transmission | grep -o "transmission")
trans2=$(which transmission-gtk | grep -o "transmission-gtk")
if [[ ! -z "$(which $1)" ]]; then
trans=$1
elif [[ "$trans1" == "transmission" ]]; then
trans='transmission'
elif [[ "$trans2" == "transmission-gtk" ]]; then
trans='transmission-gtk'
else
# echo "Script could not find transmission or transmission-gtk. $(date +%Y\-%m\-%d\ %H\:%M)." >> transmission.txt
exit
fi
while true; do
# echo "Script was executed $(date +%Y\-%m\-%d\ %H\:%M)." >> transmission.txt
sleep 60
status=$(LC_ALL=C gnome-screensaver-command -q | grep -o "active\|inactive")
pid=$(pidof $trans)
if [[ "$status" == "active" && -z "$pid" ]]; then
$trans &
check=yes
elif [[ "$status" == "inactive" && "$check" == "yes" ]]; then
killall -q $trans
check=no
fi
done
1. Skapa ett tomt dokument och kopiera och klistra in koden här ovanför.
2. Sätt exekveringsrättigheter på filen med kommandot:
Kod: Markera allt
chmod +x /path/to/script.bash
3. Lägg in sökvägen till skriptet i Ubuntus Uppstartsprogram (System -> Preferences -> Startup Applications), t.ex.: /home/username/Scripts/script.bash
4. Ladda ner ett gäng linuxdistros som vanligt med Transmission så att det finns något att dela ut när skriptet startar Transmission nästa gång (tänk på att ladda ner distron via BitTorrent):
http://www.ubuntu.com/download/ubuntu/a ... ownload#bt
http://www.linuxmint.com/release.php?id=15
http://www.kubuntu.org/getkubuntu/download
http://fedoraproject.org/en/get-fedora-all
Klart!