Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added an option to filter out system services #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pylaunchd_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ def on_refresh(self, which):
self.initialize_data(domain_index)
self.statusBar().showMessage(f'Total jobs: {len(self.data)}')

def on_toggle_filter_system(self, which):
self.on_refresh(which)

def createActions(self):

self.actionOpenFile = QtWidgets.QAction(
Expand Down Expand Up @@ -330,6 +333,9 @@ def createToolBars(self):
self.comboBoxDomain.setCurrentIndex(self.domain_id)
self.comboBoxDomain.activated.connect(self.on_domain_changed)
self.toolBar.addWidget(self.comboBoxDomain)
self.checkBoxFilterSystem = QtWidgets.QCheckBox("filter out system services")
self.checkBoxFilterSystem.stateChanged.connect(self.on_toggle_filter_system)
self.toolBar.addWidget(self.checkBoxFilterSystem)
self.toolBar.addAction(self.actionOpenFile)
self.toolBar.addAction(self.actionStart)
self.toolBar.addAction(self.actionStop)
Expand Down Expand Up @@ -358,10 +364,19 @@ def load_data_launchctl(self, domain_id=0):

services = gui_processes.split('services = {\n')[1].split('\t}')[0]


for line in services.splitlines():
label = line.split('\t')[-1]
if label:
details = self.exec(['launchctl', 'print', f'{domain}{user_identifier}/{label}'])
if self.checkBoxFilterSystem.isChecked():
properties = details.split('properties = ')[1].split('}')[0]
if "=" in properties:
is_system = properties.split("system service = ")[1][0]
if is_system == "1":
continue
elif "system service" in properties :
continue
self.jobs[label] = details
paths = re.findall('^\s+path =\s(.*$)', details, re.MULTILINE)
path = len(paths) and paths[0] or None
Expand Down