Skip to content

Refuse to run if i3lock is already running#380

Closed
MithicSpirit wants to merge 2 commits intobetterlockscreen:nextfrom
MithicSpirit:next
Closed

Refuse to run if i3lock is already running#380
MithicSpirit wants to merge 2 commits intobetterlockscreen:nextfrom
MithicSpirit:next

Conversation

@MithicSpirit
Copy link

Description

betterlockscreen now refuses to run if a process with name including i3lock is already running by the same user (as otherwise running i3lock again fails with i3lock: Cannot grab pointer/keyboard).

This primarily fixes a minor gripe I had where betterlockscreen would attempt to run twice when I put computer to sleep (once from the systemd service and once from xautolock). This was particularly annoying when, for some reason (probably a sort of race condition), dpms would not be reset correctly.

It might be desirable to change how it detects whether it is already running. Maybe checking based on $i3lockcolor_bin or just checking for betterlockscreen itself? Additionally, this will probably run into issues (untested) when running betterlockscreen on multiple $DISPLAYs at once as the same user, as any subsequent ones will fail. We could probably try to detect what $DISPLAY the i3lock (or whatever) process is on, but that sounds like a lot of hassle, so maybe just adding a config option to disable this check would be easier. I'd be fine with implementing any of these changes if so desired.

How Has This Been Tested?

  • Tried running betterlockscreen by itself and it worked as normal
  • Tried running betterlockscreen twice and i3lock only ran once
  • Tried putting my computer to sleep and i3lock only ran once (see above)

Checklist:

  • I have performed a self-review of my own code/checked that ShellCheck succeeds
  • I have made corresponding changes to the documentation (if applicable)

@SebTM
Copy link
Collaborator

SebTM commented Feb 5, 2023

Must at least use $i3lockcolor_bin, but I'm not sure in which cases this would happen if not false usage

Copy link
Collaborator

@SebTM SebTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks ✌️

@SebTM SebTM self-requested a review August 1, 2023 20:43
@SebTM SebTM mentioned this pull request Aug 1, 2023
2 tasks
@SebTM
Copy link
Collaborator

SebTM commented Aug 1, 2023

Couldn't re-run action so added it to my PR for 4.1.0 - thanks for the contribution 😃

@SebTM SebTM closed this Aug 1, 2023
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.

2 participants