File: test-title.js

package info (click to toggle)
gnome-shell 43.9-0%2Bdeb12u2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,540 kB
  • sloc: ansic: 59,716; javascript: 57,588; xml: 1,632; python: 437; sh: 410; makefile: 29; perl: 13
file content (37 lines) | stat: -rwxr-xr-x 650 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env gjs

imports.gi.versions.Gtk = '3.0';

const { GLib, Gtk } = imports.gi;

function nextTitle() {
    let length = Math.random() * 20;
    let str = '';

    for (let i = 0; i < length; i++) {
        // 97 == 'a'
        str += String.fromCharCode(97 + Math.random() * 26);
    }

    return str;
}

function main() {
    Gtk.init(null);

    let win = new Gtk.Window({ title: nextTitle() });
    win.connect('destroy', () => {
        Gtk.main_quit();
    });
    win.present();

    GLib.timeout_add(GLib.PRIORITY_DEFAULT, 5000, function() {
        win.title = nextTitle();
        return true;
    });

    Gtk.main();
}

main();