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

Removed need for sudo/root permissions on Linux #22

Merged
merged 4 commits into from
Feb 24, 2023

Conversation

Lampe2020
Copy link
Contributor

@Lampe2020 Lampe2020 commented Feb 23, 2023

Added DBus support to wakepy on Linux:

  • If DBus is available, wakepy doesn't need root permissions to work.
  • Wakelock gets automatically released when the process setting it dies/exits.
  • When the wakelock gets released by one process it should stay active for any other process also using wakepy.
  • systemctl mask solution still available as a fallback

* If DBus is available, wakepy doesn't need root permissions to work.   
* Wakelock gets automatically released when the process setting it dies/exits.   
* `systemctl mask` solution still available as a fallback
@fohrloop
Copy link
Owner

Wow that was fast! I'll take a closer look on this in the near future! :)

@Lampe2020
Copy link
Contributor Author

Lampe2020 commented Feb 23, 2023

Tested behaviour on Ubuntu Unity 22.04 LTS and Linux Mint 21.1 with the GNOME-based Cinnamon desktop. Works flawlessly.
@np-8 I was so fast because I found a working solution in a script online (in this gist) and I refined it a little and implemented that in this PR.
I'm normally not that fast but right now I don't have school ("sportlov" in Sweden) so I have time.

I accidentally left in a development artefact (I tried to also get the GNOME context manager, didn't work...) that caused there to be up to two nested exceptions (captured in variables `e1` and `e2`).
@fohrloop
Copy link
Owner

Which dbus python package did you install for this? I'm planning to test this on Ubuntu, too :)

@Lampe2020
Copy link
Contributor Author

Lampe2020 commented Feb 24, 2023

@np-8 I used the pre-installed module dbus.
It's pre-installed on the newest Linux Mint and on the newest Ubuntu Unity.
I've checked in my VM, it's also pre-installed on normal Ubuntu, with the standard GNOME desktop environment.

And if the module should be missing on some distro, my implementation will just fall back to the systemctl mask solution.

@fohrloop
Copy link
Owner

Oh, I see, also on my Ubuntu 22.04 it was installed. It is located at /usr/lib/python3/dist-packages/dbus/__init__.py and from the source code it looks like it must be dbus-python.

I tested this PR and it works flawlessly. Thanks a ton! I will merge this but I will think a moment before publishing a new version on PyPI. Installing dbus-python to a virtual environment needs something else than simple python -m pip install dbus-python. At least I faced

ERROR: Dependency lookup for dbus-1 with method 'pkgconfig' failed: Pkg-config binary for machine 1 not found.

during the installation process. There are also other dbus alternatives. I wonder if they can be installed more easily, or even better, if I could copy-paste just the part needed for wakepy..

Thanks again, and hello from the neighbor country! (Finland)

@fohrloop fohrloop merged commit 438eadd into fohrloop:master Feb 24, 2023
@Lampe2020 Lampe2020 deleted the patch-1 branch February 24, 2023 20:07
Lampe2020 added a commit to Lampe2020/wakepy that referenced this pull request Feb 27, 2023
Sorry, I forgot to update the plaintext description of the Linux behaviour when making the PR fohrloop#22 ...
@Lampe2020 Lampe2020 mentioned this pull request Feb 27, 2023
fohrloop pushed a commit that referenced this pull request Feb 27, 2023
Sorry, I forgot to update the plaintext description of the Linux behaviour when making the PR #22 ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants