From f2d8b762b102f0b900027196cb23f9e65d43561b Mon Sep 17 00:00:00 2001 From: claudiux <33965039+claudiux@users.noreply.github.com> Date: Sat, 4 Jan 2025 17:38:07 +0100 Subject: [PATCH] v1.2.0: Introduces action delayers to avoid errors (#6736) --- .../files/xsession@claudiux/CHANGELOG.md | 3 + .../files/xsession@claudiux/applet.js | 76 ++++++++++++++++--- .../files/xsession@claudiux/metadata.json | 2 +- 3 files changed, 68 insertions(+), 13 deletions(-) diff --git a/xsession@claudiux/files/xsession@claudiux/CHANGELOG.md b/xsession@claudiux/files/xsession@claudiux/CHANGELOG.md index 29e88ffa9f0..a13a6ad48be 100644 --- a/xsession@claudiux/files/xsession@claudiux/CHANGELOG.md +++ b/xsession@claudiux/files/xsession@claudiux/CHANGELOG.md @@ -1,3 +1,6 @@ +### v1.2.0~20250104 + * Introduces action delayers to avoid errors. + ### v1.1.0~20241005 * Opens the settings for the spices you use. diff --git a/xsession@claudiux/files/xsession@claudiux/applet.js b/xsession@claudiux/files/xsession@claudiux/applet.js index 7af4f8bdfab..e1bb2d23be3 100644 --- a/xsession@claudiux/files/xsession@claudiux/applet.js +++ b/xsession@claudiux/files/xsession@claudiux/applet.js @@ -143,7 +143,14 @@ class LGS extends Applet.IconApplet { }); itemWatchXSE.connect( "activate", - () => Util.spawnCommandLineAsync("bash -c '"+WATCHXSE_SCRIPT+"'") + () => { + if (this.menu.isOpen) this.menu.close(); + let to = setTimeout( () => { + Util.spawnCommandLineAsync("bash -c '"+WATCHXSE_SCRIPT+"'"); + clearTimeout(to); + }, + 300); + } ); this.menu.addMenuItem(itemWatchXSE); @@ -156,7 +163,11 @@ class LGS extends Applet.IconApplet { "activate", () => { if (this.menu.isOpen) this.menu.close(); - restartCinnamon(true) + let to = setTimeout( () => { + restartCinnamon(true); + clearTimeout(to); + }, + 300); } ); @@ -178,7 +189,11 @@ class LGS extends Applet.IconApplet { }); s.connect("activate", () => { if (this.menu.isOpen) this.menu.close(); - reloadExtension(applet, Type.APPLET) + let to = setTimeout( () => { + reloadExtension(applet, Type.APPLET); + clearTimeout(to); + }, + 300); }); this.subMenuReloadApplets.menu.addMenuItem(s) } @@ -193,7 +208,11 @@ class LGS extends Applet.IconApplet { }); s.connect("activate", () => { if (this.menu.isOpen) this.menu.close(); - reloadExtension(desklet, Type.DESKLET) + let to = setTimeout( () => { + reloadExtension(desklet, Type.DESKLET); + clearTimeout(to); + }, + 300); }); this.subMenuReloadDesklets.menu.addMenuItem(s) } @@ -208,7 +227,11 @@ class LGS extends Applet.IconApplet { }); s.connect("activate", () => { if (this.menu.isOpen) this.menu.close(); - reloadExtension(extension, Type.EXTENSION) + let to = setTimeout( () => { + reloadExtension(extension, Type.EXTENSION); + clearTimeout(to); + }, + 300); }); this.subMenuReloadExtensions.menu.addMenuItem(s) } @@ -229,7 +252,11 @@ class LGS extends Applet.IconApplet { }); s.connect("activate", () => { if (this.menu.isOpen) this.menu.close(); - Util.spawnCommandLineAsync('bash -c "cinnamon-settings applets %s"'.format(applet)) + let to = setTimeout( () => { + Util.spawnCommandLineAsync('bash -c "cinnamon-settings applets %s"'.format(applet)); + clearTimeout(to); + }, + 300); }); this.subMenuSettingsApplets.menu.addMenuItem(s) } @@ -244,7 +271,11 @@ class LGS extends Applet.IconApplet { }); s.connect("activate", () => { if (this.menu.isOpen) this.menu.close(); - Util.spawnCommandLineAsync('bash -c "cinnamon-settings desklets %s"'.format(desklet)) + let to = setTimeout( () => { + Util.spawnCommandLineAsync('bash -c "cinnamon-settings desklets %s"'.format(desklet)); + clearTimeout(to); + }, + 300); }); this.subMenuSettingsDesklets.menu.addMenuItem(s) } @@ -259,7 +290,11 @@ class LGS extends Applet.IconApplet { }); s.connect("activate", () => { if (this.menu.isOpen) this.menu.close(); - Util.spawnCommandLineAsync('bash -c "cinnamon-settings extensions %s"'.format(extension)) + let to = setTimeout( () => { + Util.spawnCommandLineAsync('bash -c "cinnamon-settings extensions %s"'.format(extension)); + clearTimeout(to); + }, + 300); }); this.subMenuSettingsExtensions.menu.addMenuItem(s) } @@ -280,7 +315,11 @@ class LGS extends Applet.IconApplet { }); s.connect("activate", () => { if (this.menu.isOpen) this.menu.close(); - Util.spawnCommandLineAsync('bash -c "xdg-open %s/applets/%s/"'.format(SPICES_DIR, applet)) + let to = setTimeout( () => { + Util.spawnCommandLineAsync('bash -c "xdg-open %s/applets/%s/"'.format(SPICES_DIR, applet)); + clearTimeout(to); + }, + 300); }); this.subMenuCodeApplets.menu.addMenuItem(s) } @@ -295,7 +334,11 @@ class LGS extends Applet.IconApplet { }); s.connect("activate", () => { if (this.menu.isOpen) this.menu.close(); - Util.spawnCommandLineAsync('bash -c "xdg-open %s/desklets/%s/"'.format(SPICES_DIR, desklet)) + let to = setTimeout( () => { + Util.spawnCommandLineAsync('bash -c "xdg-open %s/desklets/%s/"'.format(SPICES_DIR, desklet)); + clearTimeout(to); + }, + 300); }); this.subMenuCodeDesklets.menu.addMenuItem(s) } @@ -310,7 +353,11 @@ class LGS extends Applet.IconApplet { }); s.connect("activate", () => { if (this.menu.isOpen) this.menu.close(); - Util.spawnCommandLineAsync('bash -c "xdg-open %s/extensions/%s/"'.format(SPICES_DIR, extension)) + let to = setTimeout( () => { + Util.spawnCommandLineAsync('bash -c "xdg-open %s/extensions/%s/"'.format(SPICES_DIR, extension)); + clearTimeout(to); + }, + 300); }); this.subMenuCodeExtensions.menu.addMenuItem(s) } @@ -318,7 +365,12 @@ class LGS extends Applet.IconApplet { }; // End of makeMenu on_applet_middle_clicked(event) { - Util.spawnCommandLineAsync("bash -c '"+WATCHXSE_SCRIPT+"'") + if (this.menu.isOpen) this.menu.close(); + let to = setTimeout( () => { + Util.spawnCommandLineAsync("bash -c '"+WATCHXSE_SCRIPT+"'"); + clearTimeout(to); + }, + 300); } } // End of class LGS diff --git a/xsession@claudiux/files/xsession@claudiux/metadata.json b/xsession@claudiux/files/xsession@claudiux/metadata.json index dbbd8c869b4..f8eac79aea1 100644 --- a/xsession@claudiux/files/xsession@claudiux/metadata.json +++ b/xsession@claudiux/files/xsession@claudiux/metadata.json @@ -3,7 +3,7 @@ "name": "Xsession", "max-instances": "1", "hide-configuration": true, - "version": "1.1.0", + "version": "1.2.0", "description": "Restart, access source code and configure your Spices (Applets, Desklets, Extensions). View the contents of your .xsession-errors file in real time. Restart Cinnamon.", "author": "claudiux" }