Skip to content

Commit

Permalink
window: catch errors when xprop not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
jonian committed Mar 22, 2021
1 parent 3c7b5cc commit 56964c7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion unite@hardpixel.eu/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ const MOTIF_HINTS = '_MOTIF_WM_HINTS'
const _SHOW_FLAGS = ['0x2', '0x0', '0x1', '0x0', '0x0']
const _HIDE_FLAGS = ['0x2', '0x0', '0x2', '0x0', '0x0']

function safeSpawn(command) {
try {
return GLib.spawn_command_line_sync(command)
} catch (e) {
return [false, Bytes.fromString('')]
}
}

function isValid(win) {
return win && VALID_TYPES.includes(win.window_type)
}
Expand All @@ -39,7 +47,7 @@ function getXid(win) {
}

function getHint(xid, name, fallback) {
const result = GLib.spawn_command_line_sync(`xprop -id ${xid} ${name}`)
const result = safeSpawn(`xprop -id ${xid} ${name}`)
const string = Bytes.toString(result[1])

if (!string.match(/=/)) {
Expand Down

0 comments on commit 56964c7

Please # to comment.