
Adding Glue to a Desktop Environment - zdw
https://venam.nixers.net/blog/unix/2019/01/07/win-automation.html
======
Asooka
One more thing not shown: Attach GDB to a GUI program by clicking on it. I
have this in my setup:

    
    
        python
        import gdb
        import subprocess
        class AttachOnClick(gdb.Command):
            def __init__(self):
                super(AttachOnClick, self).__init__('attach_onclick', gdb.COMMAND_RUNNING, gdb.COMPLETE_NONE)
    
            def invoke(self, arg, from_tty):
                if not from_tty:
                    print('Only supported in interactive mode (from tty)')
                    return
                if arg:
                    print('No arguments supported')
                    return
                xprop = subprocess.Popen(['xprop'], stdout=subprocess.PIPE)
                awk = subprocess.Popen(['awk', '/^_NET_WM_PID/{print $3}'], stdin=xprop.stdout, stdout=subprocess.PIPE)
                xprop.stdout.close()
                try:
                    bpid = awk.communicate(timeout=60)[0]
                except subprocess.TimeoutExpired:
                    print('No click within 60 seconds, giving up')
                    xprop.terminate()
                    awk.terminate()
                    awk.wait(1)
                    xprop.wait(1)
                    return
                awk.wait(1)
                xprop.wait(1)
                spid = bpid.decode('ASCII').strip()
                if not spid:
                    print('No pid could be obtained')
                    return
                cmd = 'attach ' + spid
                gdb.execute(cmd, True)
    
        AttachOnClick()
    
        end
    

Then you can type attach_onclick at the gdb command prompt and just click on a
window to attach to it.

------
iod
For being written in 2019, I am surprised that the article had no mention of
the existence of Wayland. On my systems I have already moved off of Xorg onto
Sway¹ as my compositor and window manager and have no intention of going back.
Sway has a great programability via it's own swaymsg IPC protocol that allows
me to do all the manipulations that I would care to do, and even works on my
dual-paned HiDPI 5K monitor.

¹ [https://swaywm.org](https://swaywm.org)

~~~
dkersten
Oh. I was planning on trying out i3 for the first time this weekend. I assume
you’d recommend swaywm instead, given that it says its basically a drop in
replacement for i3? What else does it give you that i3 doesn’t, or make it a
better choice than i3? Besides being a wayland compositor; or is that the main
reason to choose it?

~~~
iod
I came from i3, so I pretty much copied over my i3 config mostly intact. Had
to add the output configuration for non-default resolutions. Had to add
environment GDK_BACKEND=wayland to applications to tell them to use wayland
instead of x11 via Xwayland such as firefox (65 and newer has wayland enbaled
by default), vlc, gedit, terminal and anything else that supports wayland.

Downsides to Sway is that's it has only just entered beta and doesn't really
have nice packaged/maintained releases yet. Also I use X11 gnome-panel overlay
on top of the swaybar panel, because I wanted a real taskbar, which is kind of
a hack and also why I know about the window manipulation features.

~~~
dkersten
Thanks!

------
NasKe
With Xorg on his way out, are there similar options for Wayland? I quite like
being able to use xbindkeys with xautomation or xdotool in basically every
Xorg WM. I might try Wayland once there is a tiling WM that supports the
Master layout (like dwm).

~~~
openbasic
What makes you think Xorg is on his way out?

~~~
DonHopkins
And what makes you think Xorg is male? ;)

~~~
jolmg
It's probably a language thing that stayed in translation. At least Spanish
doesn't have gender-less pronouns, so every object, living or not, has a
"gender". In any case, it makes more sense for Xorg to be male than female.

------
DonHopkins
Check out Simon Schneegans' useful and beautiful application launcher, Gnome-
Pie, which he's been developing for many years, and is rearchitecting as
OpenPie for Wayland.

Gnome-Pie 0.4 (7 years ago):
[https://vimeo.com/35385121](https://vimeo.com/35385121)

Gnome-Pie (6 years ago):
[https://vimeo.com/30618179](https://vimeo.com/30618179)

Gnome-Pie 0.6.1 (3 years ago):
[https://vimeo.com/125339537](https://vimeo.com/125339537)

Wayland Gnome-Pie 2 (WIP) (1 year ago):
[https://vimeo.com/224827490](https://vimeo.com/224827490)

He's written all about Gnome-Pie and the concepts behind it on his site:

[http://gnome-pie.simonschneegans.de](http://gnome-pie.simonschneegans.de)

And his Bachelor Thesis analyzes Gnome-Pie and realizes some really innovative
and cool looking forms of pie menus:

[http://simmesimme.github.io/news/2012/10/10/bachelor-
thesis](http://simmesimme.github.io/news/2012/10/10/bachelor-thesis)

Including the Coral Menu (6 years ago):
[https://vimeo.com/51072812](https://vimeo.com/51072812)

And the Trace Menu (6 years ago):
[https://vimeo.com/51073078](https://vimeo.com/51073078)

He discusses the problems of Wayland properly supporting pie menus and other
non-traditional, deeply customizable user interfaces here:
[http://simmesimme.github.io/news/2017/07/09/gnome-
pie-071](http://simmesimme.github.io/news/2017/07/09/gnome-pie-071)

>Wayland – in it’s current state – makes applications such as Gnome-Pie hardly
possible. Due to security concerns, applications are much more isolated. There
is a good summary on the cairo-dock forums. Here are the big bummers: [...]

More recently he's written about his latest ideas for bringing pie menus to
the modern Linux desktop with OpenPie, with a new architecture that solves
some of the problems with Wayland, and enables any application to use pie
menus and other novel types of menus:

OpenPie:
[http://simmesimme.github.io/news/2018/05/31/openpie](http://simmesimme.github.io/news/2018/05/31/openpie)

>With the advent of Wayland Gnome-Pie will slowly die. OpenPie is my new
concept for bringing (pie-) menus to the Linux desktop. In this post I will
give a motivation and describe the planned software architecture.

I've written more about the work he and other people have done with pie menus
here:

Pie Menus: A 30 Year Retrospective: [https://medium.com/@donhopkins/pie-
menus-936fed383ff1](https://medium.com/@donhopkins/pie-menus-936fed383ff1)

------
snazz
Interestingly enough, I use cwm on OpenBSD and I have never run into half of
those tools. The interaction simulation ones could be used to fuzz user input
in graphical applications for crashes. Has anyone tried this before?

------
pinebox
Practical use I've found for some of these tools: Shell script that detects
when any app is full screen (ex: Kodi, or Steam in Big Picture mode) and
prevents Xscreensaver from activating.

------
Walkman
And you can write your own. I use i3wm and was not satisfied how it handles
Window Titles by default, so I wrote my own daemon for renaming windows
automatically, which makes a huge difference for me:
[https://github.com/kissgyorgy/i3-window-title-
changer](https://github.com/kissgyorgy/i3-window-title-changer)

------
rkangel
Unfortunately the opening sentence "Windows are objects living in the X
server" is increasingly untrue as the world migrates to Wayland.

~~~
mwfunk
It is in the context of X servers, which is the context of the article.

