/kwin-panel-auto-hide

A KWin script that hides Plasma panels when there are maximized windows

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

Panel Auto Hide

Important

This project is no longer being maintained

Now that Plasma 6 has been released with Dodge Window feature builtin, I have no need for this anymore. If anyone need to have this on Plasma 5 feel free to fork and fix it or start a new one.

A KWin script that hides Plasma panels when there are maximized windows (all/top/bottom/left/right).

2023-07-18_03-46-27.mp4

Why? Why not?

  • I like to have a panel on a clean desktop but to stay away if I maximize
  • There is windows can cover but panel still shows behind translucent/blurred windows and I don't like that
  • Windows can cover sometimes doesnt show when hovering if maximized windows is present
  • To replicate Latte Dock's "dodge" mode

Some notes

  • This had only been tested on single/double monitor setups and can only handle a single window as of now
  • Panel on screen edge between two monitors does not auto hide, this is a Plasma BUG:351175
  • Primary monitor must be the left one!

    If the right monitor is set as primary it will toggle panels on the opposite screen??? I could not find a solution for this due to my lack of knowledge on how Plasma and KWin scripting work but if someone knows how let me know or open a PR :)

  • I am a newbie so expect messy code and bugs 🐞

Features

Current

  • Configurable which panels to hide (top, bottom, left, right)
  • Toggles auto hide only on screen with visible maximized window
    • Unhides panel on minimize of maximized window
    • Hides panel on unminimize of maximized window
    • Whitelist mode
  • Virtual desktop switching support
  • Configurable window class blacklist
  • Handle multiple windows on same screen
    • Minimizing/maximizing stacked windows (partially)
    • Handle tiled windows
  • Multi monitor support
    • Handle windows position relative to the screen they are on
    • Handle windows switching between screens (Alt+F3>Move to Screen)
  • Show on Peek at desktop
  • Dodge mode (hide when a window enters panel area)
    • Dodge on panels set to dodge (only for panels with auto-hide enabled)

May be added

  • ?

Installing

Download it from KDE Store or use KWin Scripts > Get New Scripts/Discover > Plasma Addons > search > panel auto hide

Building

Just clone the repo. make commands have been set up to do all the things.

  • make build - Build the .kwinscript file
  • make clean - Remove the .kwinscript file
  • make install - Install the script to your Plasma
  • make uninstall - Uninstall the script from your Plasma
  • make debug - See print() outputs (unfortunately shows all kwin scripts on your system and does not update in real time)

How does it work (or at least tries to)?

  1. When a window is created/maximized/unmaximized it gets on which iscreen it is
  2. Then calls org.kde.plasmashell /PlasmaShell evaluateScript using callDBus with passed screen and window properties
  3. The plasma script loops through all panels
    1. Checks if the panel screen property is the same as the window one
    2. If it is then toggles between autohide and windowsbelow depending on the window maximized state
  4. The dodge mode works by listening for windows geometry chanages
    1. If a windows enters the area of a panel that can hide and has dodge mode enabled, the panel will be hidden
    2. When the window leaves the panel area the panel is restored
  5. The reason for using windowsbelow is because:
    • Tiled windows using shortcuts automatically enter the panel, making it dodge as intended
    • Dodge movement seems smoother
    • Switching from autohide to windowscover doesnt bring the panel back without hovering it first

Contributing

PRs are welcome!

Credits & Resources