noctalia-shell icon indicating copy to clipboard operation
noctalia-shell copied to clipboard

Option to only show dock when overview is open

Open tokebe opened this issue 1 year ago • 3 comments

Feature Description

An additional dock display option which shows the dock when the Niri overview is active, and hides it otherwise.

Why Is This Needed?

I like to use the dock for pinned applications, however it would be cool to be able to have it show up only when the overview is active. This could be combined with a third-party daemon or future niri hot-corner/edge support for a pretty slick mouse workflow.

Suggested Solutions

I imagine this would be best presented as another alternative under Dock > Display.

Additional Context

I realize this isn't very different from the existing autohide, it just serves a different aesthetic preference. Overview state can be checked in Niri IPC and is presented by the event-stream.

tokebe avatar Nov 16 '25 04:11 tokebe

I don't think this kind of operation targeting a specific synthesizer should exist in Noctalia, because Noctalia supports more than one synthesizer. However, we could add an IPC command to toggle the dock display, and you could customize a script to determine when to switch the display. What do you think?

lonerOrz avatar Nov 17 '25 11:11 lonerOrz

Makes sense, and that's a good alternative solution!

tokebe avatar Nov 17 '25 14:11 tokebe

For future people searching issues, here's a script I threw together using this new functionality:

#!/usr/bin/env python3
# Adapted from gvolpe's nfsm daemon: https://github.com/gvolpe/nfsm

import json
import subprocess
import sys
import threading
import traceback
from typing import Any


def handle_overview(_event: dict[str, Any]) -> None:
    _ = subprocess.run(
        ["qs -c $HOME/.config/quickshell/noctalia-shell/ ipc call dock toggle"],
        shell=True,
    )


def handle_event(event: dict[str, Any]) -> None:
    if "OverviewOpenedOrClosed" in event:
        handle_overview(event)


def niri_stream() -> None:
    """Keep a Niri event stream open, parsing and handling events."""
    event_stream = subprocess.Popen(
        ["stdbuf", "-oL", "niri", "msg", "--json", "event-stream"],
        stdout=subprocess.PIPE,
        text=True,
    )

    listen = False

    if event_stream.stdout is None:
        print("ERROR: Event stream stdout is None.")
        return

    for line in event_stream.stdout:
        line = line.strip()
        if not line:
            continue

        try:
            event: dict[str, Any] = json.loads(line)

            # Can't set dock to show or hide, only toggle, so have to ignore initial state
            # Wait until first config load to start handling events
            if "ConfigLoaded" in event:
                listen = True
            if listen:
                handle_event(event)
        except json.JSONDecodeError:
            print("ERROR: Event JSON parse failure.")
            continue
        except Exception:
            print("ERROR: Event handling failed.")
            print(traceback.format_exc())
            continue


def main() -> None:
    threads = list[threading.Thread]()
    threads.append(threading.Thread(target=niri_stream))

    for thread in threads:
        thread.start()

    try:
        for thread in threads:
            thread.join()
    except KeyboardInterrupt:
        sys.exit()


if __name__ == "__main__":
    main()

tokebe avatar Nov 22 '25 19:11 tokebe