Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
trayopen [2013/07/13 21:55] – created beandog | trayopen [2014/02/17 02:41] (current) – beandog | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== trayopen ====== | + | ====== trayopen |
+ | |||
+ | I wrote a similar program in C that does the same thing, but with more states. | ||
+ | |||
+ | ==== Archives | ||
This code has been a lifesaver to me when it comes to checking to see if a tray is open or not. Believe it or not, there' | This code has been a lifesaver to me when it comes to checking to see if a tray is open or not. Believe it or not, there' | ||
Line 35: | Line 39: | ||
exit(status); | exit(status); | ||
} | } | ||
+ | </ | ||
+ | |||
+ | Just download the code, and compile it with gcc: | ||
+ | |||
+ | < | ||
+ | gcc trayopen.c -o trayopen | ||
+ | </ | ||
+ | |||
+ | Then, running it, it will return a 0 if it's open, or a 1 if it's closed. | ||
+ | |||
+ | Here's a sample bash script to call it: | ||
+ | |||
+ | < | ||
+ | #!/bin/bash | ||
+ | trayopen /dev/dvd | ||
+ | if [[ $? -eq 0 ]]; then | ||
+ | echo "Open for business!" | ||
+ | elif [[ $? -eq 1 ]]; then | ||
+ | echo " | ||
+ | fi | ||
</ | </ |