All Projects → Liupold → pidswallow

Liupold / pidswallow

Licence: Apache-2.0 license
A swallower script using process hierarchy.

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to pidswallow

archlinuxcn-dotfiles-collection
来自社区小伙伴们的 dotfiles 集锦
Stars: ✭ 73 (+82.5%)
Mutual labels:  kde, bspwm, i3wm
konsave
Konsave lets use save your Linux customization and restore them very easily!
Stars: ✭ 336 (+740%)
Mutual labels:  kde, plasma
dmenu-hotkeys
View for your hotkeys in rofi/dmenu style
Stars: ✭ 51 (+27.5%)
Mutual labels:  openbox, bspwm
MIF
Файлик M.I.F. от проекта @plafonlinux
Stars: ✭ 41 (+2.5%)
Mutual labels:  kde, gnome
plexydesk
Lightweight Desktop Manager for Gnu/Linux and FreeBSD - Ideal for Low resource computers
Stars: ✭ 33 (-17.5%)
Mutual labels:  kde, gnome
Wallutils
🌆 Utilities for handling monitors, resolutions, wallpapers and timed wallpapers
Stars: ✭ 145 (+262.5%)
Mutual labels:  plasma, gnome
gahshomar
A Persian (Jalali/Farsi) calendar for Linux
Stars: ✭ 69 (+72.5%)
Mutual labels:  kde, gnome
dotfiles
Config files for my setup
Stars: ✭ 289 (+622.5%)
Mutual labels:  bspwm, i3wm
EmojiRunner
Search for emojis in Krunner and copy/paste them
Stars: ✭ 33 (-17.5%)
Mutual labels:  kde, plasma5
darkine-kde
Darkine KDE - Theme for KDE Plasma 5 desktop > Mirror of https://git.rokin.in/Rokin/darkine-kde
Stars: ✭ 41 (+2.5%)
Mutual labels:  kde, plasma
Dotfiles
i3 + Plasma: using the i3 window manager on the top of KDE Plasma and other dotfiles, configurations, scripts, workarounds and practises from my Debian Sid machines.
Stars: ✭ 651 (+1527.5%)
Mutual labels:  plasma, i3wm
mmwm
Modern Minimalistic Window Manager
Stars: ✭ 45 (+12.5%)
Mutual labels:  wm, window
I3 And Kde Plasma
How to install the i3 window manager on KDE
Stars: ✭ 279 (+597.5%)
Mutual labels:  plasma, i3wm
JetBrainsRunner
A Krunner Plugin which allows you to open your recent projects
Stars: ✭ 31 (-22.5%)
Mutual labels:  kde, plasma5
Snowflake
NixOS Flake Configuration.
Stars: ✭ 22 (-45%)
Mutual labels:  plasma, gnome
I3 Gnome
Use i3wm/i3-gaps with GNOME Session infrastructure.
Stars: ✭ 677 (+1592.5%)
Mutual labels:  gnome, i3wm
Dotfiles
A Mess....
Stars: ✭ 15 (-62.5%)
Mutual labels:  openbox, bspwm
mcwm
mcwm window manager
Stars: ✭ 34 (-15%)
Mutual labels:  wm, window
La Capitaine Icon Theme
La Capitaine is an icon pack designed to integrate with most desktop environments. The set of icons takes inspiration from the latest iterations of macOS and Google's Material Design.
Stars: ✭ 1,858 (+4545%)
Mutual labels:  kde, gnome
plasma-docker
Plasmoid for KDE Plasma to control docker containers
Stars: ✭ 38 (-5%)
Mutual labels:  kde, plasma

A stupid simple swallower 😉.

(Based on Process hierarchy)

Super easy to config. Uses xdo WM/DE independent.

PKGBUILD-STATUS SHELLCHECK-STATUS license

Features

  • Based on process hierarchy (don't care about window focus).
  • cli like options. (super easy to use within scripts).
  • Window Managers and Desktop Environment Independent.
pidswallow (pid swallow WM/DE independent)
Hides terminal window automatically, so that you don't have to

pidswallow [OPTION ...]

OPTIONS:
        -h  --help              Show this message
        -s  --swallow <CWID>    Hides parent window of the given child window id.
        -v  --vomit <CWID>      Unhides parent window of the given child window id.
        -t  --toggle <CWID>     toggle between swallow and vomit. (default)
        -g  --glue              treat if parent and child window are same. (recommended)
        -l  --loop              listen and hide / unhide window on launch / remove.
        -V  --verbose           Shows useful information.

bugs/issues: https://github.com/liupold/pidswallow.
  • POSIX compliant shell script.
  • Just pass in the window id of the swallower.
  • Work on a toggle mode. (swallow if not swallowed else vomit).
  • Super fast. (Really!) (28.0ms). (using dash).
Benchmark #1: pidswallow -s 0x02A00003
  Time (mean ± σ):      28.0 ms ±   4.3 ms    [User: 13.8 ms, System: 18.0 ms]
  Range (min … max):    24.1 ms …  48.0 ms    74 runs

Demo

Demo

How it works

takes wid as as arg --> gets process tree --> check blacklist --> hide parent.

Dependencies

  1. xdo
  2. xprop (--loop and --glue).
  3. xev (--glue).
  4. xdotool (cross-workspace --glue, optional).

Installation

Using AUR

  • stable release. (Currently on 2.0)
yay -S pidswallow
  • dev (git)
yay -S pidswallow-dev-git

Manual

Add pidswallow to your path.

Autostart

  1. Launch when WM/DE starts (Example: .xinitrc, i3-config, bspwrc)
pgrep -fl 'pidswallow -gl' || pidswallow -gl
  1. Add the following to your bashrc, zshrc or shell init script. This step isn't strictly necessary, but it fixes problems with daemon-based terminals and also improves the performance of pidswallow. Note: You might want to skip this step if you use Alacritty (see Known Issues). Note: Your window manager has to focus new terminals as soon as they are spawned for this to work correctly.
[ -n "$DISPLAY" ]  && command -v xdo >/dev/null 2>&1 && xdo id > /tmp/term-wid-"$$"
trap "( rm -f /tmp/term-wid-"$$" )" EXIT HUP
  1. Restart wm and terminals.

Additional Configuration

Environment variables can be exported to change the behavior of pidswallow.

The following ones accept lists of space separated process names.

  • PIDSWALLOW_SHELL: your shell(s) (e.g bash). Default: Taken from $SHELL
  • PIDSWALLOW_TERMINAL: your terminal(s), as fallback if shell is not used (and if terminal supports it). Default: $TERMINAL
  • PIDSWALLOW_BLACKLIST: parent cannot be swallowed, (if you launch one term from another you might want to add it to blacklist). Default: same as $PIDSWALLOW_TERMINAL
  • PIDSWALLOW_GLUE_BLACKLIST: not touched by --glue. Default: empty

The ones following are executed in a subshell (/bin/sh) and support the special strings $pwid and $cwid, holding the parent and child window IDs, respectively.

  • PIDSWALLOW_SWALLOW_COMMAND: used to swallow (hide) windows. Default: xdo hide $pwid
  • PIDSWALLOW_VOMIT_COMMAND: used to vomit (unhide) windows. Default: xdo show $pwid
  • PIDSWALLOW_PREGLUE_HOOK: executed before swallowing new child window when using --glue. Useful for floating windows in tiled WMs. Default: empty

Tested on

(If you did please let me know, If it dosent work create a issue).

Known Issues

Tricks

Manual swallow (toggle)

  1. Add pidswallow to your path.
  2. run this and click on the child window (not the term) to swallow.
 xwininfo | awk '/Window id:/{print $4}' | pidswallow -gt
  1. or pass the window-id via keyboard shortcut. (Eg: sxhkd toggle).
super + v
    xdo id | pidswallow -gt

Launch a program from term wihout being swallowed.

setsid -f <command>  # this will not swallow the terminal.

WM specific recommendations.

bspwm

Add each set of lines to your bspwmrc, right before running pidswallow.

  • Let bspwm handle window hiding.
export PIDSWALLOW_SWALLOW_COMMAND='bspc node $pwid --flag hidden=on'
export PIDSWALLOW_VOMIT_COMMAND='bspc node $pwid --flag hidden=off'

This way bspwm will remember window positions and won't lose track of swallowed windows.

  • Follow floating state of parent (when using --glue).
export PIDSWALLOW_PREGLUE_HOOK='bspc query -N -n $pwid.floating >/dev/null && bspc node $cwid --state floating'

Check if parent window state is floating and apply the same to the child if that's the case. This example should work in most cases, but feel free to add more complex hooks to your setup. (e.g. to mimic more properties of the parent).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].