Created
May 14, 2018 18:06
-
-
Save flozz/cf5492f483841f38500c633cef13dc27 to your computer and use it in GitHub Desktop.
A small hack that allows to manipulate windows on GNOME Shell / Wayland
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import pydbus | |
GNOME_SHELL = "org.gnome.Shell" | |
META_WINDOW_JS = """ | |
(function(params) { | |
function _findWindow(windowTitle) { | |
for (var i = 0 ; i < windowActors.length ; i++) { | |
var win = windowActors[i].get_meta_window(); | |
if (win.get_title() == windowTitle) { | |
return win; | |
} | |
} | |
return null; | |
} | |
var windowActors = global.get_window_actors(); | |
var win = _findWindow(params.uuid); | |
if (win) { | |
if (params.position !== undefined) { | |
win.move_frame(false, params.position[0], params.position[1]); | |
} | |
if (params.above === true) { | |
win.make_above(); | |
} | |
if (params.above === false) { | |
win.unmake_above(); | |
} | |
if (params.stick === true) { | |
win.stick(); | |
} | |
if (params.stick === false) { | |
win.unstick(); | |
} | |
} | |
})(%s); | |
""" | |
def _exec_js(js, params): | |
js = js % json.dumps(params) | |
bus = pydbus.SessionBus() | |
shell = bus.get(GNOME_SHELL) | |
shell.Eval(js) | |
_exec_js(META_WINDOW_JS, { | |
"uuid": "Simple Screencast", | |
"above": True | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment