diff --git a/etc/skel/.config/waybar/config.jsonc b/etc/skel/.config/waybar/config.jsonc index 04739a6..fd048cb 100644 --- a/etc/skel/.config/waybar/config.jsonc +++ b/etc/skel/.config/waybar/config.jsonc @@ -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": { diff --git a/etc/sway/variables b/etc/sway/variables index fce5326..560c5f0 100644 --- a/etc/sway/variables +++ b/etc/sway/variables @@ -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 diff --git a/usr/share/sway/scripts/flock.sh b/usr/share/sway/scripts/flock.sh new file mode 100755 index 0000000..75115a4 --- /dev/null +++ b/usr/share/sway/scripts/flock.sh @@ -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" "$@"