mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-03-09 15:40:18 +00:00
QML: open Display settings app using config file
This commit is contained in:
parent
04290f76db
commit
6436dbd8ff
2 changed files with 12 additions and 7 deletions
|
@ -127,7 +127,7 @@ ColumnLayout {
|
||||||
backend.startVNC(settings.vnc.port);
|
backend.startVNC(settings.vnc.port);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
backend.openDisplaySetting();
|
backend.openDisplaySetting(settings.displaySettingApp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ from netifaces import interfaces, ifaddresses, AF_INET
|
||||||
# Path.home() to look up in the password directory (pwd module)
|
# Path.home() to look up in the password directory (pwd module)
|
||||||
if 'HOME' in os.environ:
|
if 'HOME' in os.environ:
|
||||||
del os.environ['HOME']
|
del os.environ['HOME']
|
||||||
|
os.environ['HOME'] = str(Path.home())
|
||||||
os.environ['PATH'] = os.confstr("CS_PATH") # Sanitize $PATH
|
os.environ['PATH'] = os.confstr("CS_PATH") # Sanitize $PATH
|
||||||
|
|
||||||
# Setting home path and base path
|
# Setting home path and base path
|
||||||
|
@ -33,7 +34,7 @@ os.environ['PATH'] = os.confstr("CS_PATH") # Sanitize $PATH
|
||||||
if 'XDG_CONFIG_HOME' in os.environ and os.environ['XDG_CONFIG_HOME']:
|
if 'XDG_CONFIG_HOME' in os.environ and os.environ['XDG_CONFIG_HOME']:
|
||||||
HOME_PATH = os.environ['XDG_CONFIG_HOME']
|
HOME_PATH = os.environ['XDG_CONFIG_HOME']
|
||||||
else:
|
else:
|
||||||
HOME_PATH = str(Path.home())
|
HOME_PATH = os.environ['HOME']
|
||||||
if HOME_PATH is not None:
|
if HOME_PATH is not None:
|
||||||
HOME_PATH = HOME_PATH + "/.config"
|
HOME_PATH = HOME_PATH + "/.config"
|
||||||
if HOME_PATH is not None:
|
if HOME_PATH is not None:
|
||||||
|
@ -453,7 +454,7 @@ class Backend(QObject):
|
||||||
# Qt properties
|
# Qt properties
|
||||||
@pyqtProperty(str, constant=True)
|
@pyqtProperty(str, constant=True)
|
||||||
def settings(self):
|
def settings(self):
|
||||||
with open(DEFAULT_CONFIG_PATH, "r") as f:
|
with open(CONFIG_PATH, "r") as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
@settings.setter
|
@settings.setter
|
||||||
|
@ -627,8 +628,8 @@ class Backend(QObject):
|
||||||
# auto stop on exit
|
# auto stop on exit
|
||||||
atexit.register(self.stopVNC, force=True)
|
atexit.register(self.stopVNC, force=True)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot(str)
|
||||||
def openDisplaySetting(self):
|
def openDisplaySetting(self, app: str = "arandr"):
|
||||||
# define callbacks
|
# define callbacks
|
||||||
def _onConnected():
|
def _onConnected():
|
||||||
print("External Display Setting opened.")
|
print("External Display Setting opened.")
|
||||||
|
@ -641,8 +642,12 @@ class Backend(QObject):
|
||||||
self.onDisplaySettingClosed.emit()
|
self.onDisplaySettingClosed.emit()
|
||||||
if exitCode is not 0:
|
if exitCode is not 0:
|
||||||
self.onError.emit(f'Error opening "{running_program}".')
|
self.onError.emit(f'Error opening "{running_program}".')
|
||||||
|
with open(DATA_PATH, 'r') as f:
|
||||||
program_list = ["gnome-control-center display", "kcmshell5 kcm_kscreen", "arandr"]
|
data = json.load(f)['displaySettingApps']
|
||||||
|
if app not in data:
|
||||||
|
self.onError.emit('Wrong display settings program')
|
||||||
|
return
|
||||||
|
program_list = [data[app]['args'], "arandr"]
|
||||||
program = ProcessProtocol(_onConnected, _onReceived, _onReceived, _onEnded, None)
|
program = ProcessProtocol(_onConnected, _onReceived, _onReceived, _onEnded, None)
|
||||||
running_program = ''
|
running_program = ''
|
||||||
for arg in program_list:
|
for arg in program_list:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue