Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a PNG file in a Gnome Shell extension for St.Icon

My Gnome Shell extension has a folder 'icons' and there is an icon file called 'MyIcon.png' inside. I want to take it as a parameter to an St.Icon object.

let icon = new St.Icon({ /* I need what to code here*/ });

Thanks for any help.

Selcuk.

like image 262
The_Cute_Hedgehog Avatar asked Dec 05 '13 08:12

The_Cute_Hedgehog


People also ask

How do you customize GNOME extensions?

Install GNOME Shell Extensions Using GNOME Tweaks ToolHit Alt + F2, type "r", and press Enter. To start Tweaks, click Show Applications in the lower-left corner of the screen. Type "tweaks" in the search box and click the Tweaks icon. Click Extensions in the left pane on the Tweaks dialog box.

How do I add extensions to GNOME extensions?

Open you Firefox browser and click on the GNOME extension icon. Search for and select an extension you wish to install. Flip the provided switch to install the desired extension.

Where are Gnome extension settings?

Local extensions are ones installed by each user in their home directories ( ~/. local/share/gnome-shell/extensions ), whereas system-wide extensions are installed by administrators in system directories ( /usr/share/gnome-shell/extensions/ ).


1 Answers

Here is a solution for GnomeShell v3.8.4:

const St = imports.gi.St;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Gio = imports.gi.Gio;
let gicon = Gio.icon_new_for_string(Me.path + "/icons/my_icon.png");
icon = new St.Icon({ gicon });
like image 188
Edouard Chevalier Avatar answered Sep 20 '22 19:09

Edouard Chevalier