Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
trayopen [2013/07/13 15:55] beandog created |
trayopen [2014/02/16 19:41] (current) beandog |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== trayopen ====== | + | ====== trayopen (archives) ====== |
+ | |||
+ | I wrote a similar program in C that does the same thing, but with more states. See [[dvd_drive_status]]. | ||
+ | |||
+ | ==== 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's nothing good out there to query it! (And I've looked, too.) | 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's nothing good out there to query it! (And I've looked, too.) | ||
Line 35: | Line 39: | ||
exit(status); | exit(status); | ||
} | } | ||
+ | </code> | ||
+ | |||
+ | Just download the code, and compile it with gcc: | ||
+ | |||
+ | <code> | ||
+ | gcc trayopen.c -o trayopen | ||
+ | </code> | ||
+ | |||
+ | 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: | ||
+ | |||
+ | <code> | ||
+ | #!/bin/bash | ||
+ | trayopen /dev/dvd | ||
+ | if [[ $? -eq 0 ]]; then | ||
+ | echo "Open for business!" | ||
+ | elif [[ $? -eq 1 ]]; then | ||
+ | echo "Sorry, already occupied." | ||
+ | fi | ||
</code> | </code> |