Preventing Deluge-Gtk from starting without usb disk connected

General support for problems installing or using Deluge
Post Reply
XORORNOR
New User
New User
Posts: 1
Joined: Wed Feb 02, 2022 11:45 am

Preventing Deluge-Gtk from starting without usb disk connected

Post by XORORNOR »

Sometimes it happens that I forget to connect usb disk to the laptop before starting Deluge. Then after connecting disk and restarting Deluge it re-checks every torrent which could last very long time. Recently I’ve made this little script to resolve the issue. I decided to put I it here to help people with the same problem.

How it works? First you need to set DISK_NAME variable to your actual usb disk name. Then you run Deluge using this script. It asks you if you really like to start the program without disk connected. It should work on Mint and Ubuntu, on others it might need changing mountpoint.

Code: Select all

#!/bin/bash
DISK_NAME='disk_name'


if [[ $(mount | grep "/media/$USER/$DISK_NAME") != '' ]]
then
	nohup /usr/bin/deluge-gtk %U >/dev/null 2>&1 &
else 
	zenity \
	--warning \
	--text="<span font=\"12\">Device: $DISK_NAME is not available. Starting Deluge will cause torrent re-check afterwards.</span>\n" \
	--title="Deluge" \
	--ok-label="Run anyway" --width=500 --height=100 \
	--extra-button "Cancel"

	
	if [[ $? -eq 0 ]]
	then
		nohup /usr/bin/deluge-gtk %U >/dev/null 2>&1 &
	fi
fi
Post Reply