|
4 | 4 |
|
5 | 5 | local utils = require 'mp.utils' |
6 | 6 |
|
| 7 | +local xorg = os.getenv('XDG_SESSION_TYPE') == 'x11' |
| 8 | + |
7 | 9 | local MULTIMEDIA = table.concat({ |
8 | 10 | '*.aac', |
9 | 11 | '*.avi', |
@@ -52,20 +54,24 @@ local function KDialog(opts) |
52 | 54 | path = path == nil and '' or utils.split_path( |
53 | 55 | utils.join_path(utils.getcwd(), path) |
54 | 56 | ) |
| 57 | + local args = { |
| 58 | + 'kdialog', opts.default or path, |
| 59 | + '--title', opts.title, |
| 60 | + '--icon', ICON, |
| 61 | + '--multiple', '--separate-output', |
| 62 | + opts.type or '--getopenfilename', opts.text, |
| 63 | + } |
55 | 64 | local ontop = mp.get_property_native('ontop') |
56 | | - local focus = utils.subprocess { |
57 | | - args = {'xdotool', 'getwindowfocus'} |
58 | | - }.stdout:gsub('\n$', '') |
| 65 | + if xorg then |
| 66 | + local focus = utils.subprocess { |
| 67 | + args = {'xdotool', 'getwindowfocus'} |
| 68 | + }.stdout:gsub('\n$', '') |
| 69 | + table.insert(args, 5, '--attach') |
| 70 | + table.insert(args, 6, focus) |
| 71 | + end |
59 | 72 | mp.set_property_native('ontop', false) |
60 | 73 | local kdialog = utils.subprocess { |
61 | | - args = { |
62 | | - 'kdialog', opts.default or path, |
63 | | - '--title', opts.title, |
64 | | - '--attach', focus, |
65 | | - '--icon', ICON, |
66 | | - '--multiple', '--separate-output', |
67 | | - opts.type or '--getopenfilename', opts.text, |
68 | | - }, cancellable = false, |
| 74 | + args = args, cancellable = false |
69 | 75 | } |
70 | 76 | mp.set_property_native('ontop', ontop) |
71 | 77 | if kdialog.status ~= 0 then return end |
|
0 commit comments