Last active
August 3, 2021 14:08
-
-
Save rvzzz/d7bef0c7ff49bf3734d374ce056a8089 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from platform import system as platform_name | |
from os import system | |
import ctypes | |
platforms_dictionary = { | |
"Windows": { | |
"open" : 'ctypes.windll.WINMM.mciSendStringW(u"set cdaudio door open", None, 0, None)', | |
"close": 'ctypes.windll.WINMM.mciSendStringW(u"set cdaudio door closed", None, 0, None)' | |
}, | |
"Darwin": { | |
"open" : 'system("drutil tray open")', | |
"close": 'system("drutil tray closed")' | |
}, | |
"Linux": { | |
"open" : 'system("eject cdrom")', | |
"close": 'system("eject -t cdrom")' | |
}, | |
"NetBSD": { | |
"open" : 'system("eject cd")', | |
"close": 'system("eject -t cd")' | |
}, | |
"FreeBSD": { | |
"open" : 'system("sudo cdcontrol eject")', | |
"close": 'system("sudo cdcontrol close")' | |
} | |
} | |
if platform_name() in platforms_dictionary: | |
exec(platforms_dictionary[platform_name()]["open"]) | |
exec(platforms_dictionary[platform_name()]["close"]) | |
else: | |
print("Sorry, no OS found") |
https://www.faqforge.com/linux/eject-cddvd-tray-command-line-linux/
eject /dev/cdrom
eject /dev/cdrw
eject /dev/dvd
eject /dev/dvdrom
eject /dev/dvdrw
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey i like this fork from the original; i found for Windows if you want to use a different drive, in my case
L:
i had to alias the drive with anOPEN
command first then i was able to open/close the tray afterwards ; perhaps another way to achieve the same?See: https://gist.github.com/TakesTheBiscuit/a2e3d36c1d20731821fdb41b3831406e