Using KDE Plasma like a Smart TV with KDE Connect

Intro

skip if you like

I got a cheap “smart-TV” and as everyone should know, these run some insecure version of Android or other closed OS.

They also constantly spy on you and greatly restrict your freedom to watch whatever you like (filesystems, encrypted drives, software, …).

Hardware

I use the TV as a monitor, plug in my laptop via HDMI.

HDMI also carries sound, but I (currently, unlike the display configuration “switch to external display”) need to switch to it manually.

Software

It is controlled via KDE Connect from my GrapheneOS phone.

When using a VPN, I need to exclude the app. Maybe “allow local network usage” could also work.

On Linux, with mullvad-vpn, this means

  1. Copy the kde-connect desktop entries from /usr/share/applications/ to ~/.local/share/applications/
  2. Do a sed -i 's/Exec=/Exec=mullvad-exclude /g' ENTRYNAME.desktop (put a “mullvad-exclude” to the front of the Exec= line)

Now the app will launch bypassing the VPN, this can also be used when autostarting it.

KDE Connect setup

KDE Connect can manipulate videoplayers, if they expose a d-bus interface. Not all do that, for example my preferred player “Celluloid”.

But that media control is limited, so my favourite feature is the “command input”. It allows to execute whatever you want on the Linux Laptop, if you have a trusted connection, and the Laptop sends a message “I accept these commands” to the phone (security).

Commands

Here are some commands that I have setup!

Dolphin

# open dolphin somewhere
dolphin /path/to/folder

# scale dolphin 2x and open a folder
QT_SCALE_FACTOR=2 dolphin /path/to/folder

launch a website

For example for a common streaming service, or the frontend of your selfhosted Jellyfin, Nextcloud etc.

In this example combined with bubblejail (setup to sandbox Firefox inside a bubblewrap container) and mullvad-exclude to bypass my VPN and make the streaming service not block me

mullvad-exclude bubblejail run -- Firefox /usr/bin/firefox -profile TV https://someservice.com

Keyboard layout

Switch between keyboard layouts. this is a needed bypass if you have a different language software keyboard on Android, as it will otherwise send the wrong keys to the laptop. Setup the languages in systemsettings

qdbus-qt6 org.kde.keyboard /Layouts org.kde.KeyboardLayouts.switchToNextLayout

(The Qt6 qdbus seems to be called differently between distros)

Dark/Light mode

I found no toggle yet, and the tool doesn’t output an error when the colorscheme is already set, so 2 buttons

plasma-apply-colorscheme BreezeDark

plasma-apply-colorscheme BreezeLight

Brightness

(thanks to @ben2talk for the commands here)

Save this script somewhere, like in /usr/local/bin/brctl and make it executable with run0 chmod +x /usr/local/bin/brctl.

#!/bin/bash
qdbus-qt6 org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement/Actions/BrightnessControl org.kde.Solid.PowerManagement.Actions.BrightnessControl.setBrightness "$(($(qdbus-qt6 org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement/Actions/BrightnessControl org.kde.Solid.PowerManagement.Actions.BrightnessControl.brightness) + $(($1 * 100))))"

Now you can setup the commands brctl 5 and brctl -5 in KDE Connect, to increase and decrease the brightness.

Change system power profiles

To silence your fan, you can switch between them.

Fedora uses tuneD which has the following profiles

  • accelerator-performance
  • balanced-battery
  • intel-sst
  • network-throughput
  • throughput
  • performance
  • aws
  • desktop
  • latency-performance
  • optimize-serial-console
  • virtual-guest
  • balanced
  • hpc-compute
  • network
  • latency
  • powersave
  • virtual-host
tuned-adm profile powersave

With the traditional you would use power-profiles-daemon with different commands.

Off, Reboot, suspend

shutdown now
init 0

systemctl reboot

systemctl suspend

# lock screen
loginctl lock-session

Toggle bluetooth

Enable and disable bluetooth, for real. Needs a password, maybe switching that to a user systemd service could work. Oh, and needs systemd.

if [[ $(systemctl is-active bluetooth) == "active" ]]; then run0 sh -c "systemctl disable --now bluetooth && systemctl mask bluetooth"; else run0 sh -c "systemctl unmask bluetooth && systemctl enable --now bluetooth"; fi

updates

If you have an alias in your favourite shell, you can execute it like this:

fish -c 'update'

# or
bash -c 'update'

Additional Commands

Still looking for a brightness command, improved theme switching and better media control on other players.

Btw, why are there unicode emojis for everything except basic computer symbols like wifi, on/off, bluetooth?

7 Likes

This is a great use case scenario!

Thanks for sharing :slight_smile:

I rarely use other players than mpv (which is fully keyboard shortcut driven) but I would assume that several others implement D-Bus interfaces, e.g. org.mpris.MediaPlayer2

1 Like

Updated it to be actually informative :wink:

1 Like