From 23cacbbe8971696c4ffcecb402cfb6bd49a5c42f Mon Sep 17 00:00:00 2001 From: retrozinndev Date: Sun, 26 Oct 2025 16:26:44 -0300 Subject: [PATCH] :wrench: chore(update): restart colorshell if there's an instance running after updating --- scripts/start.sh | 15 +++------------ scripts/utils.sh | 15 +++++++++++++++ update.sh | 8 ++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/scripts/start.sh b/scripts/start.sh index afdfc6d..a463307 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -1,18 +1,9 @@ +source ./scripts/utils.sh + file="${1:-./build/colorshell}" -function is_running() { - if gdbus introspect --session \ - --dest io.github.retrozinndev.colorshell \ - --object-path /io/github/retrozinndev/colorshell > /dev/null 2>&1 - then - return 0 - fi - - return 1 -} - function start() { - if is_running; then + if Is_running; then echo "[info] killing previous instance" colorshell quit || killall gjs fi diff --git a/scripts/utils.sh b/scripts/utils.sh index 6d1d3d3..5f980ac 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -63,6 +63,21 @@ function Ask() { export answer } +# ------------- +# Checks if there's currently a colorshell instance running +# Returns code 0 if none, 1 if there is one +# ------------- +function Is_running() { + if gdbus introspect --session \ + --dest io.github.retrozinndev.colorshell \ + --object-path /io/github/retrozinndev/colorshell > /dev/null 2>&1 + then + return 0 + fi + + return 1 +} + # ------------- # Check if colorshell is installed # Returns code 0 if installed, 1 if not diff --git a/update.sh b/update.sh index 0e0f5de..a895ba4 100755 --- a/update.sh +++ b/update.sh @@ -121,6 +121,14 @@ if [[ "$answer" == y ]] || [[ "$skip_prompts" ]]; then mkdir -p $APPS_HOME cp -f $repo_directory/build/release/colorshell.desktop $APPS_HOME + if Is_running; then + Send_log "colorshell is running, restarting shell..." + colorshell quit || killall gjs + # wait 2s, because the shell can take a little bit of time to close + # (the cli is closed before the action is completed) + sleep 2s && hyprctl dispatch exec "bash $XDG_CONFIG_HOME/hypr/scripts/exec.sh colorshell" + fi + if [[ -z "$skip_prompts" ]]; then echo "Colorshell is updated! :D"