KDE night color (Nightshift), disabling/enabling Night color when using a video or photo application

Problem:

You want to use kde “night color” feature
and
when launching video or photo application you want to disable automatically “night color”
and
when quitting the application you want to enable automatically “night color”.

Solution:

In kde settings with kde shortcut manager in kwin define a shortcut for “toggle night color”, for example “Alt_n”.

With Yast software manager install xdotool, a virtual keyboard and mouse

then

for example for VLC

in ~/bin/ create vlcn.sh
set “executable” this file
put in this file these contents


#!/bin/bash
#
xdotool key Alt+n
/usr/bin/vlc
xdotool key Alt+n


With kde menu editor change the call of vlc by ~/bin/vlcn.sh

for Digikam

in ~/bin/ create digikamn.sh
set “executable” this file
put in this file these contents


#!/bin/bash
#
xdotool key Alt+n
/usr/bin/digikam
xdotool key Alt+n

With kde menu editor change the call of digikam by ~/bin/digikamn.sh

note:

“xdotool key Alt+n” send “Alt_n” to kwin

sometime the first statement

xdotool key Alt+n

does nothing, it seems the key does not reach kwin.
i don’t know why. It’s too techie for me.

i found a workaround. i add a delay.


#!/bin/bash
#
sleep 6s
xdotool key Alt+n
/usr/bin/vlc
xdotool key Alt+n

or a more concise writing


#!/bin/bash
#
xdotool sleep 6 key Alt+n
/usr/bin/vlc
xdotool key Alt+n

Too complicated.
You can click on a Night Color icon in a system tray to toggle On/Off.
With Oxygen icons it has no icon - simply clean space.