Add flock wrapper for running only one process

This commit is contained in:
Aleksey Samoilov 2023-07-11 19:18:35 +04:00
parent c7969c5a1d
commit f53f4013ea
3 changed files with 13 additions and 4 deletions

View file

@ -145,7 +145,7 @@
"warning": 70,
"critical": 90
},
"on-click": "swaymsg exec \\$term_float btop"
"on-click": "swaymsg exec \\$flock \\$term_float btop"
},
"memory": {
@ -155,7 +155,7 @@
"warning": 70,
"critical": 90
},
"on-click": "swaymsg exec \\$term_float btop"
"on-click": "swaymsg exec \\$flock \\$term_float btop"
},
@ -174,7 +174,7 @@
"tooltip-format-wifi": "{icon} {ifname} ({essid}): {ipaddr}",
"tooltip-format-disconnected": "{icon} disconnected",
"tooltip-format-disabled": "{icon} disabled",
"on-click": "swaymsg exec \\$term_float nmtui connect"
"on-click": "swaymsg exec \\$flock \\$term_float nmtui connect"
},
"bluetooth": {

View file

@ -9,6 +9,9 @@ set $down j
set $up k
set $right l
# flock wrapper for running only one process
set $flock /usr/share/sway/scripts/flock.sh
# Your preferred terminal emulator
set $term alacritty
set $term_cwd $term --working-directory "$(/usr/share/sway/scripts/swaycwd.sh 2>/dev/null || echo $HOME)"
@ -24,7 +27,7 @@ set $menu rofi -show combi -combi-modi "drun,run" -terminal $term -ssh-command "
set $bindsym bindsym --to-code
# Bluetooth menu
set $bluetooth $term_float bluetuith
set $bluetooth $flock $term_float bluetuith
# Volume notification
set $volume_bar /usr/share/sway/scripts/volume-notify.sh

View file

@ -0,0 +1,6 @@
#!/usr/bin/env sh
HASH="$(echo "$@" | shasum | cut -f1 -d" " | cut -c1-7)"
mkdir -p "$HOME/.local/state"
flock --verbose -n "$HOME/.local/state/${HASH}.lock" "$@"