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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.faqforge.com/linux/eject-cddvd-tray-command-line-linux/