hyprwm / contrib

Community scripts and utilities for Hypr projects
MIT License
294 stars 39 forks source link

grimblast: only allow one instance #113

Closed fufexan closed 3 months ago

fufexan commented 3 months ago

Description of changes

Allow only one instance of grimblast to be active at a time. Fixes #112

Things done

fufexan commented 3 months ago

@DHDcc can you test this?

DHDcc commented 3 months ago

@fufexan it works IF I don't spam my keybind:

No spaming: https://github.com/user-attachments/assets/ad69f75a-9d44-4c5d-ace3-ffff9a93f179

Spaming: https://github.com/user-attachments/assets/9d0e3d44-38ff-41e9-9197-4a531beb1246

Insted of having 10+ instances, I have 2 instances max (if I spam my keybind)

fufexan commented 3 months ago

Looks like I can't make grimblast only allow one instance of itself to be running from within itself. I've tried using lockfiles, but that doesn't work either. And pgrep seems too slow to be useful when called from within the script.

However, I have these binds in my hyprland config which work exceptionally well, even when spamming the key:

bind=, Print, exec, pgrep grimblast || grimblast --notify copysave area
bind=CTRL, Print, exec, pgrep grimblast || grimblast --notify --cursor copysave output
bind=ALT, Print, exec, pgrep grimblast || grimblast --notify --cursor copysave screen