- ๐ญ Iโm currently working on ____________.
liupold / pidswallow Goto Github PK
View Code? Open in Web Editor NEWA swallower script using process hierarchy.
License: Apache License 2.0
A swallower script using process hierarchy.
License: Apache License 2.0
If my terminal is focused and I launch a program using dmenu, the terminal is being swallowed. That shouldn't be happening. The terminal should only be swallowed if I launch a program using the terminal.
Hi!
I'm using sxhkd as a systemd user service. I've made a small modification to the unit too (KillMode=process
).
The thing is, this makes systemd the "parent" process. Running pidswallow
with verbose=1
on an Alacritty window gives this output:
systemd(724)---alacritty(25793)---zsh(25799)
Thus, the script doesn't work.
I tried messing around with the script for a bit, but I don't know much about process handling and the variable names just confused me more. So I gave up and made an issue.
Is there a way to work around this?
Edit: I'm honestly not sure if systemd has anything to do with it. I'm just assuming here (sorry if I'm wrong), since using a simpler sxhkd &
inside bspwmrc doesn't cause any problems.
There is probably some sort of work-around for this, but I think it's worth bringing up.
If I open dmenu to open something like firefox while the current focused window is a terminal that is whitelisted (in my case, st), the terminal swallows the program despite being launched from dmenu instead of from the terminal.
Is there a workaround for this? Thanks
EDIT: Oops, I'm commenting on the wrong project but since I'm here, I'll try this out too :)
A lot of the terms are dbus based, (This will not work correctly)
We probably need to maintain a list of this,
Conversation started here
Happens when the shell init is sourced quickly, before the terminal window has appeared: xdo id
won't catch the terminal as it doesn't exist yet.
This could be worked around when/if #2817 on Alacritty gets implemented. For now, the best way to go is to fall back to the terminal pid based approach (i.e. not adding setup lines to .bashrc/.zshrc/shell init).
I was messing around again with pstree
to understand what sed
did in the new changes, and this is an example output I got:
$ pstree -ATsp "$$" | sed -e 's|(|:|g' -e 's|)||g'
systemd:1---systemd:709---alacritty:2734---zsh:2742-+-pstree:5774
`-sed:5775
I felt like this could break the script, so I started looking around and found this stackoverflow answer that recommends not parsing pstree
. This leads me back to the conclusion that a better solution is to use the /proc
filesystem once again.
This has the performance problem though, because we have to parse /proc/<...>/status
for each and every parent until coming across a swallowable.
So right now I'm looking for an alternative to pstree
that's reliable enough for scripting and know will work 100% of the time.
I know, maybe a scenario like the output I got above will never really happen, but I feel like being nitpicky and really want a solution that always works ;) hehe
So, for example pidswallow -Vgl
has the same behavior as pidswallow -lgV
. This has the drawback of only allowing 1 action per invocation, but I think that's how it should work.
I already have something kind of prepared for this but I'm not sure how to handle return values.
Thoughts on this?
When running a urxvt in client-server mode xwininfo | awk '/Window id:/{print $4}' | tr '[a-f]' '[A-F]' | pidswallow -t
fails with bspc error for an invalid descriptor. Also interesting is that printing the cname of the client as found by the swallow function reveals the name of the daemon (urxvtd). I have no idea if this is expected or not
Can't edit it myself ;)
It happens because our only check for a window already being swallowed is this line, which only checks if the current child window (cwid
) has any window swallowed.
In the case of sub-windows (e.g. when a program creates a pop-up window), the child window will be different to the one that originally swallowed. This causes pidswallow to think it's our first time swallowing it and proceeds to do it again.
This isn't noticeable with default configuration because xdotool unmapwindow
will just fail and not do anything. However, when using the recommended bspwm-specific configuration, bspc node {%pwid} --flag hidden=on
has a very different result when {%pwid}
is left as blank.
Right now it's late for me so this looks like a hard thing to solve, maybe even requiring some changes to how the /tmp
files are handled. But I might wake up tomorrow and realize it's some easy check.
It's a bummer but I think we just can't support that one.
What do you think of adding a configuration option for this? I personally like the parent to always regain focus.
Another idea I have is to monitor the child window focus. And only if it was focused when it closed, re-focus the parent. This feels like overkill though.
Opening the terminal from somewhere other than the application finder (e.g. through exo-open
, by defining the Xfce Terminal as a "default application") won't use the --disable-server
flag. I'm not sure how to set it up.
xprop -spy
only outputs lines when windows are focused. I'm not sure if this is intended.
I hadn't noticed this before because I have a special keybind that does something every once in a while that also triggers xprop -spy
.
This is a problem in bspwm, for example, where moving the window around won't update the position and resizing won't update the size.
Edit: to reproduce, have a floating terminal and move it around with super + mouse (assuming that config hasn't been changed). Launching anything from that terminal will use the old position and not the new one.
Edit: I just realized it's kind of program-dependant. For instance, I'm testing Alacritty.
Hi
First of all, thanks a lot for the great work. Unfortunately I can't make it work. What am I missing?
I have the latest version. I am on Arch/bspwm and I use Alacritty.
I added alacritty to this line in pidswallow
swallowable=" $TERMINAL alacritty urxvt kitty "
I added that at the bottom of bspwmrc
bspc subscribe node_add node_remove \ | grep -o --line-buffered '0x[0-9A-F]\+$' | xargs -n1 pidswallow &
In Alacritty I get
sxiv Pictures/wallpapers-stray.jpg !9984 No such user name: found. /home/ioio85/.local/bin/pidswallow: line 38: pls report this issue to https://github.com/liupold/pidswallow: No such file or directory
In urxvt it does not work either but I don't get any error.
Thanks for your help
First of all, a terminal has to be started from the plasma menu.
After that, when opening the plasma menu (making pidswallow check if it's a swallowable), if the first line of the pstree
output (the line we're parsing) has a swallowable like konsole
and the plasmashell
, the plasma menu is gonna be handled incorrectly and moved to the top left corner of the screen.
Sorry for the rushed explanation. I'm coming back to this later to clarify exactly what's going on.
Whether running sxiv directly from the terminal, or if it gets launched from a file manager like lf, the launching window is not getting swallowed.
$ pstree -ATlsp $$
systemd(1)---plasmashell(4588)---konsole(39639)---zsh(39645)---pstree(39710)
$ xdotool search --pid 39639
73400321
73400323
73400362
73400382
71303175
For some reason, even though there's only 1 konsole instance with 1 konsole window, multiple WIDs are output (from the same PID!)
This is really confusing me. I'll check it out later.
Testing plasma also led me to find out about another issue that seems to happen even on the master branch nope, only DEs, so I'll check that first. Edit: Fixed that one
Using xdo close
on a seperate window from the windows currently being swallowed in bspwm on the same workspace as a swallowed window, causes the swallow effect to stop.
Focus is jumping from one desktop to another during toggle.
Steps to reproduce:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.