You are not logged in.
As the header says. Is there an easy way to detect if an unmounted disc is in my dvd drive, from within a bash script?
Last edited by orphius1970 (2010-06-28 20:11:29)
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
Maybe u could try to compare the output of
mount -l
with the contents of
/dev/dvd
or just check if /dev/dvd is readable like that:
sudo cat /dev/dvd
if [ $? -eq 0 ]
then DOSOMETHING
fi;
{ Github } {Blog and other stuff }
Offline
[[ ! -b /dev/sr0 ]] && echo 'zomg, drive not found!'
edit: sorry, that probably just checks that a disc is in the tray.
grep -Fq '/dev/sr0' /proc/mounts || echo 'zomg, drive not mounted!'
should check if it's actually mounted somewhere
Last edited by brisbin33 (2010-06-27 19:16:04)
//github/
Offline
Brisbin,
The first one is what I need. How would I work that into conky? I want to have a message display when a disc is on
drive or if not. Something like:
Disc
NoDisc
I know I can use the if_mounted option in conky. I really want to know if there is disk in drive, even when not mounted
First one seems to not work
NEW!
I just discovered that when a cd or dvd is inserted. Folder "/dev/dvd/by-label" is created and removed when disk is ejected.
So I have the following script.
#!/bin/bash
directory="/dev/dvd/by-label"
# bash check if directory exists
if [ -d $directory ]; then
echo "Directory Exists"
else
echo "Directory does not exists"
fi
How would I alter this to work inside conky?
SOLVED IT!!
Changed script to:
#!/bin/bash
directory="/dev/dvd/by-label"
# bash check if directory exists
if [ -d $directory ]; then
echo "+ Dvd +"
else
echo "- Dvd -"
fi
+ = disc in drive
- = disc not in drive
Added it to conky with ${exec script}
Last edited by orphius1970 (2010-06-28 20:11:01)
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline