You are not logged in.

#1 Yesterday 07:53:35

bivan
Member
Registered: 2026-02-03
Posts: 103

A command or app to display black?

Is there a command or app to display black, on CLI or GUI (at least, KDE)? Not "Turn off screen" on KDE because I need audio, see https://bbs.archlinux.org/viewtopic.php?id=315325 .

Googling "linux how to display black" I found 2 commands using xrandr or xset but as their names suggest it's X, GUI KDE I use Wayland & on CLI they don't work.

#!/bin/bash
gwenview -f /home/a/.png

(.png is a 1920*1080 (resolution of my display) black image) but only GUI & then I must close Gwenview.

The ideal:
I click on a file, I enter a shortcut or a command: black display (still audio),
then any input e.g. pressing any key: back to normal.
On CLI or GUI (at least, KDE).


Arch Linux KDE

Offline

#2 Yesterday 08:40:44

killertofus
Member
Registered: 2025-02-10
Posts: 294

Re: A command or app to display black?

Small python script that renders a black rectangle window that can be maximized with right click and closed with left click. Use -m to start it in fullscreen Requires tk package installed

karabaja4 made the script

 #!/usr/bin/env python3
import sys
import os
import tkinter as tk

class ToggleFullscreenApp:
    def __init__(self, root, start_fullscreen=False):
        self.root = root
        self.fullscreen = False

        # Initial window size (rectangle)
        self.width = 1280
        self.height = 800
        self.root.geometry(f"{self.width}x{self.height}")  # let WM place it
        self.root.configure(background="black")
        
        pid = os.getpid()
        self.root.title(f"OLED saver [{pid}]")

        # Bind click events
        self.root.bind("<Button-3>", self.toggle_fullscreen)
        self.root.bind("<Button-1>", self.exit_app)

        # Force window manager to place window and get actual geometry
        self.root.update_idletasks()
        x = self.root.winfo_x()
        y = self.root.winfo_y()
        w = self.root.winfo_width()
        h = self.root.winfo_height()
        self.saved_geometry = f"{w}x{h}+{x}+{y}"

        # Start in fullscreen if requested
        if start_fullscreen:
            self.toggle_fullscreen()

    def toggle_fullscreen(self, event=None):
        self.fullscreen = not self.fullscreen
        if self.fullscreen:
            # Save current geometry
            self.root.update_idletasks()
            x = self.root.winfo_x()
            y = self.root.winfo_y()
            w = self.root.winfo_width()
            h = self.root.winfo_height()
            self.saved_geometry = f"{w}x{h}+{x}+{y}"

            # Go fullscreen
            self.root.attributes("-fullscreen", True)
        else:
            # Restore original size and position
            self.root.attributes("-fullscreen", False)
            self.root.geometry(self.saved_geometry)

    def exit_app(self, event=None):
        self.root.quit()


if __name__ == "__main__":
    script_name = sys.argv[0]
    
    if "-h" in sys.argv or "--help" in sys.argv:
        print(
            f"Usage: python3 {script_name} [options]\n\n"
            "Options:\n"
            "  -h, --help      Show this help message and exit\n"
            "  -m              Start the application in fullscreen mode\n\n"
            "Controls:\n"
            "  Right-click     Toggle fullscreen on/off\n"
            "  Left-click      Exit the application"
        )
        sys.exit(0)
    
    start_fullscreen = "-m" in sys.argv
    root = tk.Tk()
    app = ToggleFullscreenApp(root, start_fullscreen=start_fullscreen)
    root.mainloop()

I Have Linux Perl Can i Download Gnome???

Offline

#3 Yesterday 09:02:23

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,953

Re: A command or app to display black?

Afaiu DPMS should™ not cut down the audio signal - does your monitor have settings to control its DPMS (powersaving) behavior?
Otherwise it's not very hard to write a tiny Qt/wlr program to create a black window but the most reasonable approach would likely be a kwin script that just stops all rendering.

Edit: F5

Last edited by seth (Yesterday 09:02:45)

Online

#4 Yesterday 12:33:26

bivan
Member
Registered: 2026-02-03
Posts: 103

Re: A command or app to display black?

should is trademarked?

Yes my ViewSonic VP16-OLED has Sleep & Auto Power Off, but what link? Googling "displayport audio only": "It cannot transmit an "audio-only" signal by itself because DisplayPort architecture requires an accompanying video stream/handshake to function." https://en.wikipedia.org/wiki/DisplayPort#Main_link , so "Turn off screen" cuts audio.

According to Gemini & I think it's right: stopping all rendering would freeze...

killertofus I've better: Gemini gave me a C code using SDL: it works! But cuts audio on CLI... https://share.gemini.google/HskqfqlkkigD

Last edited by bivan (Yesterday 13:43:36)


Arch Linux KDE

Offline

#5 Yesterday 13:41:07

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,953

Re: A command or app to display black?

Yes should™ is trademarked to separate it from "should" which indicates a neglect of reality wink

The other thread said HDMI, but either way I'd ask the LLM for a kwin script that will also skip all rendering overhead.
As for the CLI, setterm -blank will likely cause DPMS, but ctrl+l should™ do most of it ?

Online

#6 Yesterday 13:54:33

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,554
Website

Re: A command or app to display black?

seth wrote:

As for the CLI ... ctrl+l should™ do most of it ?

Or the following script will do all of it.  And if you have a TE with a black (or suitably dark) background, launching a fullscreen terminal to run this script would work in the GUI as well.

#!/bin/sh

printf '\033[?25l'
clear
read -n 1
printf '\033[?25h'

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 Yesterday 14:40:00

bivan
Member
Registered: 2026-02-03
Posts: 103

Re: A command or app to display black?

Googling "hdmi vs displayport": it seems complicated... I use HDMI because my old PC hasn't USB-C but in the future I'll use USB-C (DisplayPort & PD power delivery) by a new mini PC.

"a kwin script that will also skip all rendering overhead" like window shadow etc? No need, I all disabled.

setterm --blank returns 0 ...

TE terminal?

Nice your script, there's audio! Good job inspector. But Konsole even fullscreen by F11 there's still a bar above.

Last edited by bivan (Yesterday 14:44:36)


Arch Linux KDE

Offline

#8 Yesterday 14:47:46

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,953

Re: A command or app to display black?

"Terminal Emulator", the command would be "setterm --blank force"

like window shadow etc?

"Like everything" - notably all windows etc.  leaving only the (default black) canvas.

You're losing audio when entering DPMS via HDMI? Is it maybe because the monitor completely shuts down and unregisters?

Online

#9 Yesterday 19:56:42

bivan
Member
Registered: 2026-02-03
Posts: 103

Re: A command or app to display black?

My bad I didn't read man setterm : setterm --blank 1 works, but cuts audio...

Also the script of inspector parrot has the inconvenience of clearing the console.

"Turn off screen" stops any signal from the PC to the monitor, "No Signal" displayed.

Maybe this app, having a black wallpaper:
minimize all windows, hide the pointer & the desktop icons
any input: back to before.

I asked this to Gemini:
Minimize all windows:

qdbus6 org.kde.kglobalaccel /component/kwin invokeShortcut "Show Desktop"

Hide the pointer: there's System Settings > Window management > Desktop Effects > Hide Cursor but idk the command.

Hide the desktop icons: https://github.com/wispware/plasma-tidy .

WIP...

Last edited by bivan (Yesterday 20:42:05)


Arch Linux KDE

Offline

#10 Yesterday 21:11:29

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,953

Re: A command or app to display black?

This isn't about minimizing windows or so, https://develop.kde.org/docs/plasma/kwin/ essentially should™ (my knowledge here is a decade old) allow you to completely skip rendering anything.

Also the script of inspector parrot has the inconvenience of clearing the console.

#!/bin/sh
printf '\e[?1049h'
printf '\e[?25l'
clear
read -n 1
printf '\e[?25h'
printf '\e[?1049l'

Online

#11 Yesterday 22:39:56

bivan
Member
Registered: 2026-02-03
Posts: 103

Re: A command or app to display black?

Do you mean

pkill plasmashell

? No desktop icons & panel but there are still windows & the pointer, then

plasmashell --replace

desktop icons & panel reappear but it's linked to Konsole: you close it, like above...

omg I'll build a pyramid for you god seth.


Arch Linux KDE

Offline

#12 Yesterday 22:50:50

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,953

Re: A command or app to display black?

No, I meant you can write a script or https://develop.kde.org/docs/plasma/kwineffect/ that just tells kwin to forego all further rendering though it seems only QML effects are supported and you can no longer control window rendering itself?

killing plasmashell will just terminate the desktop (wallpaper, panels, widget) but not impact any other windows.

Online

Board footer

Powered by FluxBB