-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
grimblast: only allow one instance (modified) #114
Conversation
@fufexan I fixed it |
I don't think it's necessary to write to a file, just have it exist. This is similar to something I've tried which didn't work. Maybe we can combine the two approaches? diff --git a/grimblast/grimblast b/grimblast/grimblast
index 3d8026c..531de5d 100755
--- a/grimblast/grimblast
+++ b/grimblast/grimblast
@@ -18,9 +18,15 @@
## hyprctl equivalents.
## https://github.com/swaywm/sway/blob/master/contrib/grimshot
+# Set up lockfile
+LOCKFILE="${XDG_RUNTIME_DIR:-$XDG_CACHE_DIR:-$HOME/.cache}/grimblast.lock"
+
# Check whether another instance is running
-if pgrep slurp; then
+if [ -e "$LOCKFILE" ]; then
exit 2
+# Else create a lockfile
+else
+ touch "$LOCKFILE"
fi
getTargetDirectory() {
@@ -153,6 +159,7 @@ killHyprpicker() {
die() {
killHyprpicker
+ rm "$LOCKFILE"
MSG=${1:-Bye}
notifyError "Error: $MSG"
exit 2
@@ -228,7 +235,7 @@ elif [ "$SUBJECT" = "area" ]; then
WORKSPACES="$(hyprctl monitors -j | jq -r '[(foreach .[] as $monitor (0; if $monitor.specialWorkspace.name == "" then $monitor.activeWorkspace else $monitor.specialWorkspace end)).id]')"
WINDOWS="$(hyprctl clients -j | jq -r --argjson workspaces "$WORKSPACES" 'map(select([.workspace.id] | inside($workspaces)))')"
# shellcheck disable=2086 # if we don't split, spaces mess up slurp
- GEOM=$(echo "$WINDOWS" | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | slurp $SLURP_ARGS)
+ GEOM=$(echo "$WINDOWS" | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | slurp $SLURP_ARGS || die "selection cancelled")
# Check if user exited slurp without selecting the area
if [ -z "$GEOM" ]; then
@@ -278,3 +285,4 @@ else
fi
killHyprpicker
+rm "$LOCKFILE" |
I tried this and it's working for me. Can you check if it's also working for you @fufexan? :
|
That seems to work, as long as I don't launch using |
I can't think of a fix for that... But I don't think people are going to do that anyways. |
All good, just needs the Changelog entry. |
Done @fufexan |
Description of changes
Things done
For new programs
maintainer
it)
CI checks matrix
For changes