Code Monkey home page Code Monkey logo

pidswallow's Introduction

Hi ๐Ÿ‘‹, I'm Liupold

A passionate tinkerer.

liupold

  • ๐Ÿ”ญ Iโ€™m currently working on ____________.

Languages and Tools:

c cplusplus git go linux matlab python rust

liupold

liupold

pidswallow's People

Contributors

liupold avatar seerlite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pidswallow's Issues

terminal getting swallowed using dmenu

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.

Doesn't work if sxhkd is run as a systemd service.

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.

Issue with dmenu

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 :)

Daemon Based Terminal Will not work

A lot of the terms are dbus based, (This will not work correctly)

  • urxvtd (daemon #17)
  • xfce-terminal
  • gnome-termiinal

We probably need to maintain a list of this,

Shell-based swallowing doesn't always work correctly in Alacritty

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).

We shouldn't rely on pstree output to get parent processes

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

Allow flags in any order

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?

Does not work with urxvt daemon

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

Sub-windows re-swallowing an alraedy swallowed parent

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.

Configuration for re-focusing parent window when vomiting child

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.

Instructions for Xfce Terminal don't work globally.

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 doesn't detect window changes

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.

No such file or directory

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

Plasma menu may be handled incorrectly in specific instances

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.

not working with sxiv

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.

Unable to swallow Konsole on Plasma

$ 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

Swallow stops after closing a window

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.

Jumping desktop focus.

Focus is jumping from one desktop to another during toggle.

Steps to reproduce:

  • Open a window at any given desktop(say x) (from terminal)
  • Move the window to other desktop.(say y)
  • Close the window (at y). Focus should stay at y, but moving to x.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.