forked from William/kvs-linuxmint-dloadx
41 lines
873 B
Bash
41 lines
873 B
Bash
|
#!/bin/bash
|
||
|
USERNAME="$1" # Provided by service file
|
||
|
|
||
|
if [[ $EUID -ne 0 ]]; then
|
||
|
echo "This script must be run as root."
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ -z "$1" ]; then
|
||
|
echo "No arguments were supplied."
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
function doTheThang
|
||
|
{
|
||
|
# Wait for USB device to initialize
|
||
|
sleep 1
|
||
|
|
||
|
# TTY is empty if no serial device is detected
|
||
|
TTY=$(setserial -g /dev/ttyUSB[0-9] | awk -F"," '{print $1}')
|
||
|
|
||
|
if [ ! -z "$TTY" ]; then
|
||
|
echo -e "\e[1;32mUsing serial device: $TTY\e[0m"
|
||
|
ln -s $TTY /home/$USERNAME/.wine/dosdevices/com1 &&
|
||
|
ls -l /home/$USERNAME/.wine/dosdevices/ | grep $TTY
|
||
|
else
|
||
|
echo -e "\e[1;31mNo serial device\e[0m"
|
||
|
fi
|
||
|
}
|
||
|
doTheThang
|
||
|
|
||
|
LSUSB=$(lsusb)
|
||
|
while :
|
||
|
do
|
||
|
if [ "$LSUSB" != "$(lsusb)" ]; then
|
||
|
LSUSB=$(lsusb)
|
||
|
echo "=======USB Change detected======="
|
||
|
doTheThang
|
||
|
fi
|
||
|
sleep 1
|
||
|
done
|