From 43c8f684a56e636f454b7eb44edfa6bd99b0209c Mon Sep 17 00:00:00 2001 From: Nerd Date: Sat, 7 May 2022 13:07:50 -0700 Subject: [PATCH] GNOME Shell 42 Compat --- extension.js | 11 +++++++---- metadata.json | 10 ++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/extension.js b/extension.js index eab6e06..651d92c 100644 --- a/extension.js +++ b/extension.js @@ -4,6 +4,7 @@ const Gio = imports.gi.Gio; const GLib = imports.gi.GLib; const GObject = imports.gi.GObject; const St = imports.gi.St; +const ByteArray = imports.byteArray; const ExtensionUtils = imports.misc.extensionUtils; const Util = imports.misc.util; @@ -12,6 +13,7 @@ const Main = imports.ui.main; const PanelMenu = imports.ui.panelMenu; const Config = imports.misc.config; +const SHELL_MAJOR = parseInt(Config.PACKAGE_VERSION.split('.')[0]); const SHELL_MINOR = parseInt(Config.PACKAGE_VERSION.split('.')[1]); let SSHQuickConnect = class SSHQuickConnect extends PanelMenu.Button { @@ -21,7 +23,9 @@ let SSHQuickConnect = class SSHQuickConnect extends PanelMenu.Button { this.createIcon(); // Get ~/.ssh/config as string - const hostString = GLib.spawn_command_line_sync("cat " + GLib.get_home_dir() + "/.ssh/config")[1].toString(); + const hostString = ByteArray.toString( + GLib.file_get_contents(GLib.get_home_dir() + '/.ssh/config')[1] + ); // Parse string into array of Hosts this.hosts = hostString.split('\n').join('{{NEWLINE}}').split('\r').join('{{NEWLINE}}').split('{{NEWLINE}}') .map(item => item.trim()) @@ -70,8 +74,7 @@ let SSHQuickConnect = class SSHQuickConnect extends PanelMenu.Button { * EXTENSION BOILERPLATE */ -// Compatibility with gnome-shell >= 3.32 -if (SHELL_MINOR > 30) { +if (SHELL_MAJOR > 39 || SHELL_MINOR > 30) { SSHQuickConnect = GObject.registerClass( { GTypeName: 'SSHQuickConnect' }, SSHQuickConnect @@ -96,4 +99,4 @@ function disable() { indicator.destroy(); indicator = null; } -} +} \ No newline at end of file diff --git a/metadata.json b/metadata.json index 3d7a4ff..c1fb2fb 100644 --- a/metadata.json +++ b/metadata.json @@ -1,10 +1,8 @@ { "uuid": "ssh-quick-connect@ibrokemy.computer", "name": "SSH Quick Connect", - "description": "This extension puts an icon in the panel with a simple dropdown menu that launches items from your ~.ssh/config", - "version": 1, - "shell-version": [ - "3.36" - ], - "url": "https://www.github.com/ibrokemycomputer/gnome-shell-extension-ssh-quick-connect" + "description": "This extension puts an icon in the panel with a simple dropdown menu that launches items from your ssh configs", + "shell-version": [ "3.36", "40", "41", "42" ], + "url": "https://www.github.com/ibrokemycomputer/gnome-shell-extension-ssh-quick-connect", + "version": 2 } \ No newline at end of file