I want to write a simple gnome extension that prints some text on my top bar from a text file. I managed to print the text but i'm having trouble with updating it every 60 seconds. Is it even possible with gjs?
this is what i came up with:
const {St, Clutter} = imports.gi;
const Main = imports.ui.main;
const GLib = imports.gi.GLib;
let panelButton;
function init () {
// Create a Button with "Hello World" text
panelButton = new St.Bin({
style_class : "panel-button",
});
let fileContents = String(GLib.file_get_contents("path/to/myfile.txt")[1]);
let panelButtonText = new St.Label({
text : fileContents,
y_align: Clutter.ActorAlign.CENTER,
});
panelButton.set_child(panelButtonText);
}
function enable () {
// Add the button to the panel
Main.panel._centerBox.insert_child_at_index(panelButton, 2);
}
function disable () {
// Remove the added button from panel
Main.panel._centerBox.remove_child(panelButton);
}