Shihira / gnome-extension-quicktoggler

DEPRECATED: Switched to KDE, so goodbye friends. Toggling services, launching apps in one click.
https://extensions.gnome.org/extension/1077/quick-toggler/
40 stars 9 forks source link

Support for systemd user services #5

Open suyash192 opened 7 years ago

suyash192 commented 7 years ago

There does not seem to be any support for systemd user services. There should be an option for this. For example, redshift service has to be started using:

systemctl --user start redshift.service

Which also doesn't require the user's password since it's not a system service. There can be an option in entries.json that specifies if it is a system or a user service.

{
    "type": "systemd",
    "title: "Redshift",
    "unit": "redshift",
    "user": true
}
deepaksp commented 7 years ago

i think you should use pkexec replace nginx with redshift { "type": "toggler", "title": "Nginx Server", "command_on": "/usr/bin/pkexec systemctl start nginx", "commandoff": "/usr/bin/pkexec systemctl stop nginx", "detector": "ps cax | grep nginx | grep -o '^[ ][0-9]_'", "notify_when" : ["on"] }

and creatrea pkexec policy

Shihira commented 7 years ago

@suyash192 As @deepakSP has said, the extension provides you flexible way to configure your entries. Originally I implemented only toggler, and for convenience to toggle system-wide services I derived systemd from it. Of course those derived entries are not complete and satisfy everyone, and then the choice you can make is to directly use the base type.

I am working on some more flexible derivation policy. Take the example of yours to explain this idea:

{
    "deftype": "systemd",
    "base": "toggler",
    "var": ["user", "unit"],
    "command_on": "systemctl $(if [${user}]; then echo --user; fi) start ${unit}",
    "command_off": "systemctl $(if [${user}]; then echo --user; fi) stop ${unit}",
    "detector": "systemctl $(if [${user}]; then echo --user; fi) status ${unit} | grep 'Active: activ[ei]'"
}

where user and unit are passed in through environment variable. It can take quite some time to implement this. Please keep watching.

Shihira commented 7 years ago

@suyash192 This policy has been implemented in the lastest commit 34fa6c59f05af69623f24ca97817ccb24ee1eaf3. Have a try under the guidance of README, and report to me if there are any problems.