Closed asahaf closed 3 years ago
I totally get where you're coming from and I've been thinking about this myself, since I use a couple of shortcuts that spawn basic TUI programs and I could use a solution to make sure only one instance of each can be on screen. But this is also why I don't think this should be solved within the script when it would be easy enough to craft a wrapper script that takes arbitrary commands as parameters and makes sure the command can only run once.
However, such a wrapper script would be a nice addition to the readme.
You're right, it would be cleaner with a wrapper as this script might be used in different in setups where forced single instance is not desired.
I force single instance this way on sway config:
set $MENU_LOCK_DIR /tmp/sway.launcher.desktop.lock
set $menu mkdir "$MENU_LOCK_DIR" && trap 'rmdir "$MENU_LOCK_DIR"' EXIT INT && TERMINAL_COMMAND="$term -e " $term --class $term-sway-launcher -e <path-to>/sway-launcher-desktop.sh
We can force only single launcher instance by using lock file like so at line 143:
To make is easy to switch between single/multiple instances, we can have a flag at the top of the script