-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
101 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from setuptools import setup | ||
|
||
APP = ['src/CastMenu.py'] | ||
DATA_FILES = [] | ||
OPTIONS = { | ||
'argv_emulation': True, | ||
'plist': { | ||
'LSUIElement': True, | ||
'CFBundleIdentifier': 'com.pierrejacquier.castmenu', | ||
'CFBundleGetInfoString': 'CastMenu. Control your Chromecast-enabled devices from the macOS Menu.', | ||
'CFBundleDisplayName': 'CastMenu', | ||
}, | ||
'packages': ['rumps', 'keyboard', 'pychromecast'], | ||
'iconfile': 'icon.icns', | ||
'resources': ['src/icons/cast_connected.png', 'src/icons/cast_disconnected.png'], | ||
} | ||
|
||
setup( | ||
app=APP, | ||
data_files=DATA_FILES, | ||
options={'py2app': OPTIONS}, | ||
setup_requires=['py2app'], | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import keyboard | ||
import os | ||
import subprocess | ||
import sys | ||
import platform | ||
|
||
from app import CastMenuApp | ||
|
||
def _mac_elevate(): | ||
"""Relaunch asking for root privileges.""" | ||
print("Relaunching with root permissions") | ||
# applescript = ('do shell script "python3 ./src/CastMenu.py" ' | ||
# 'with administrator privileges') | ||
applescript = ('do shell script "../MacOS/CastMenu" ' | ||
'with administrator privileges') | ||
exit_code = subprocess.call(['osascript', '-e', applescript]) | ||
sys.exit(exit_code) | ||
|
||
def _elevate(): | ||
"""Elevate user permissions if needed""" | ||
if platform.system() == 'Darwin': | ||
try: | ||
os.setuid(0) | ||
except OSError: | ||
_mac_elevate() | ||
|
||
_elevate() | ||
app = CastMenuApp() | ||
app.run() | ||
keyboard.wait() |
This file contains 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.