We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I made a patch to copy IP to clipboard on click with a setting switch. Still refreshes IP on click.
index 92490ff..81b0331 100644 --- a/extension.js +++ b/extension.js @@ -16,6 +16,9 @@ const NO_CONNECTION = 'Waiting for connection'; const CANT_GET_LOCAL_IP = `Can't get local ip`; const CONNECTION_REFUSED = 'Connection refused'; +const Clipboard = St.Clipboard.get_default(); +const CLIPBOARD_TYPE = St.ClipboardType.CLIPBOARD; + let _label, _icon; const makeHttpSession = () => { @@ -170,6 +173,10 @@ const updateDisplay = (displayMode = 'ip-and-flag') => { service.process(requestCallback); }; +const copyDisplay = () => { + Clipboard.set_text(CLIPBOARD_TYPE, _label.text); +}; + let IpInfoIndicator = class IpInfoIndicator extends PanelMenu.Button { _init(menuAlignment, nameText, dontCreateMenu) { @@ -233,6 +240,8 @@ let IpInfoIndicator = class IpInfoIndicator extends PanelMenu.Button { this.onClick = () => { this.update(); + Settings.get_boolean('enable-onclick-copy') + && copyDisplay(); } this.updateService = () => { diff --git a/prefs.js b/prefs.js index 84623c6..b20620d 100644 --- a/prefs.js +++ b/prefs.js @@ -11,6 +11,7 @@ const DISPLAY_MODES = ['only-flag', 'only-ip', 'ip-and-flag']; const INDICATOR_ALIGN = 'indicator-panel-align'; const INDICATOR_ALIGNS = ['left', 'right', 'center']; const ON_MOUSE_OVER_STATE = 'enable-onmouse-display'; +const ON_CLICK_STATE = 'enable-onclick-copy'; const init = () => {/* Empty */}; @@ -98,6 +99,20 @@ class PublicIpPrefs extends Gtk.Grid { container.pack_end(switchWidget, 0,0,0); this.attach(container, 0, 5, 1, 1); + /* Enable onClick copy */ + container = new Gtk.HBox({spacing: 5}); + label = new Gtk.Label({ + label: "Enable onClick copy", + margin_left: 10 + }); + + let copySwitchWidget = new Gtk.Switch(); + copySwitchWidget.set_sensitive(true); + copySwitchWidget.set_active(this._settings.get_boolean(ON_CLICK_STATE)); + this._settings.bind(ON_CLICK_STATE, copySwitchWidget, 'active', Gio.SettingsBindFlags.DEFAULT); + container.pack_start(label, 0,0,0); + container.pack_end(copySwitchWidget, 0,0,0); + this.attach(container, 0, 6, 1, 1); } }); diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index 5f740f4..b320100 100644 Binary files a/schemas/gschemas.compiled and b/schemas/gschemas.compiled differ diff --git a/schemas/org.gnome.shell.extensions.public-ip-extension.gschema.xml b/schemas/org.gnome.shell.extensions.public-ip-extension.gschema.xml index 779b7db..609a259 100644 --- a/schemas/org.gnome.shell.extensions.public-ip-extension.gschema.xml +++ b/schemas/org.gnome.shell.extensions.public-ip-extension.gschema.xml @@ -23,5 +23,12 @@ Enables 'ip-and-flag' mode on mouse over event. </description> </key> + <key type="b" name="enable-onclick-copy"> + <default>false</default> + <summary>Enable clipboard copy onClick</summary> + <description> + Enables copy current IP to clipboard on click event. + </description> + </key> </schema> </schemalist> \ No newline at end of file```
The text was updated successfully, but these errors were encountered:
Perfect ! Just need to run glib-compile-schemas ~/.local/share/gnome-shell/extensions/[email protected]/schemas/ after modifying the files.
glib-compile-schemas ~/.local/share/gnome-shell/extensions/[email protected]/schemas/
Sorry, something went wrong.
Hi, sorry for the long delay in response and thanks for your contribution.
I will add this feature in a big patch with other features and fixes in compatibility.
No branches or pull requests
I made a patch to copy IP to clipboard on click with a setting switch. Still refreshes IP on click.
The text was updated successfully, but these errors were encountered: