diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-10-02 09:24:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-02 09:24:32 +0200 |
commit | bfe8847d72cd0893230f2e654242658214943e61 (patch) | |
tree | 3384b02ebad7a74cbb106ddd95546e0e24ff0bb8 /src/lib/DBus.js | |
parent | fix: Fix navigation shortcut accelerator for non-macos (fixes #1172) (#2012) (diff) | |
download | ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.tar.gz ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.tar.zst ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.zip |
chore: convert various files from JS to TS (#2010)
Diffstat (limited to 'src/lib/DBus.js')
-rw-r--r-- | src/lib/DBus.js | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/lib/DBus.js b/src/lib/DBus.js deleted file mode 100644 index 9baaea014..000000000 --- a/src/lib/DBus.js +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | import { sessionBus } from 'dbus-next'; | ||
2 | import { isLinux } from '../environment'; | ||
3 | |||
4 | export default class DBus { | ||
5 | bus = null; | ||
6 | |||
7 | constructor(trayIcon) { | ||
8 | this.trayIcon = trayIcon; | ||
9 | } | ||
10 | |||
11 | start() { | ||
12 | if (!isLinux || this.bus) return; | ||
13 | |||
14 | try { | ||
15 | this.bus = sessionBus(); | ||
16 | } catch { | ||
17 | // Error connecting to the bus. | ||
18 | return; | ||
19 | } | ||
20 | |||
21 | // HACK Hook onto the MessageBus to track StatusNotifierWatchers | ||
22 | this.bus._addMatch("type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',path='/org/freedesktop/DBus',member='NameOwnerChanged'"); | ||
23 | const mangled = JSON.stringify({ | ||
24 | path: '/org/freedesktop/DBus', | ||
25 | interface: 'org.freedesktop.DBus', | ||
26 | member: 'NameOwnerChanged', | ||
27 | }); | ||
28 | this.bus._signals.on(mangled, (msg) => { | ||
29 | const [name, oldOwner, newOwner] = msg.body; | ||
30 | if (name === 'org.kde.StatusNotifierWatcher' && oldOwner !== newOwner && newOwner !== '') { | ||
31 | // Leave ample time for the StatusNotifierWatcher to be initialized | ||
32 | setTimeout(() => { | ||
33 | this.trayIcon.recreateIfVisible(); | ||
34 | }, 400); | ||
35 | } | ||
36 | }); | ||
37 | } | ||
38 | |||
39 | stop() { | ||
40 | if (!this.bus) return; | ||
41 | |||
42 | this.bus.disconnect(); | ||
43 | this.bus = null; | ||
44 | } | ||
45 | } | ||