From 870ac64511bf20ae5c9b4d0f9f7297522b259169 Mon Sep 17 00:00:00 2001 From: retrozinndev Date: Sun, 26 Oct 2025 16:52:43 -0300 Subject: [PATCH] :wrench: chore(app, update): import ags overrides from absolute directory, check if repo is already cloned before cloning --- src/app.ts | 32 ++++++++++++++++---------------- update.sh | 13 ++++++++++--- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/app.ts b/src/app.ts index d6e01e0..c8013c8 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,5 +1,5 @@ // thanks Aylur!! -import "../node_modules/ags/lib/overrides"; +import "/usr/share/ags/js/lib/overrides"; import "./config"; import { PluginApps, @@ -210,24 +210,24 @@ you should use the socket in the XDG_RUNTIME_DIR/colorshell.sock for a faster re // handle communication via socket createScopedConnection(this.#socketService, "incoming", (conn) => { - const inputStream = Gio.DataInputStream.new(conn.inputStream); - inputStream.read_upto_async('\x00', -1, GLib.PRIORITY_DEFAULT, null, (_, res) => { - const [args, len] = inputStream.read_upto_finish(res); - inputStream.close(null); - conn.inputStream.close(null); + const inputStream = Gio.DataInputStream.new(conn.inputStream); + inputStream.read_upto_async('\x00', -1, GLib.PRIORITY_DEFAULT, null, (_, res) => { + const [args, len] = inputStream.read_upto_finish(res); + inputStream.close(null); + conn.inputStream.close(null); - if(len < 1) { - console.error(`Colorshell: No args provided via socket call`); - return; - } + if(len < 1) { + console.error(`Colorshell: No args provided via socket call`); + return; + } - try { - const [success, parsedArgs] = GLib.shell_parse_argv(`colorshell ${args}`); - parsedArgs?.splice(0, 1); // remove the unnecessary `colorshell` part + try { + const [success, parsedArgs] = GLib.shell_parse_argv(`colorshell ${args}`); + parsedArgs?.splice(0, 1); // remove the unnecessary `colorshell` part - if(success) { - handleArguments({ - print_literal: (msg) => conn.outputStream.write_bytes( + if(success) { + handleArguments({ + print_literal: (msg) => conn.outputStream.write_bytes( encoder.encode(`${msg}\n`), null ), diff --git a/update.sh b/update.sh index c613bfe..651766e 100755 --- a/update.sh +++ b/update.sh @@ -68,16 +68,23 @@ Send_log warn "!! By running this, you assume total responsability for issues th if [[ "$answer" == y ]] || [[ "$skip_prompts" ]]; then if [[ "$is_standalone" ]]; then Send_log "The installer noticed that you're calling the script remotely" - rm -rf $repo_directory 2> /dev/null Send_log "Cloning repository in \`$repo_directory\`..." - git clone https://github.com/retrozinndev/colorshell.git "$repo_directory" + if [[ -d $repo_directory ]]; then + Send_log "repo is already cloned! let's just fetch the latest changes..." + git -C "$repo_directory" stash # if there are changes, let's just stash them + git -C "$repo_directory" fetch && git -C "$repo_directory" pull --rebase + git -C "$repo_directory" stash pop # pop changes back if there are any + else + git clone https://github.com/retrozinndev/colorshell.git "$repo_directory" + fi fi Ask "Nice! Update to latest stable version instead of unstable(latest commit)?" if [[ -z "$skip_prompts" ]] && [[ "$answer" == y ]]; then Send_log "fetching latest release from colorshell repository" - latest_tag=`curl -s "$repo_api_url/releases" | jq -r '. | select(.[].prerelease == false) | .[0].tag_name'` + # use `head -n1` because for some reason, github api shows the same release 3 times :'( + latest_tag=`curl -s "$repo_api_url/releases" | jq -r '. | select(.[].prerelease == false) | .[0].tag_name' | head -n1` Send_log "Done fetching" Send_log "Checking out latest non-pre-release version: $latest_tag"