Auto turn on TV(no HDMI-CEC) and auto start apps with gamescope session

So this is something I been trying to get working for a while and I finally did

These scripts do the following every time I run steam game mode

  1. turn on my LG tv
  2. Switch to the input my PC is on
  3. start an openrgb server
  4. start some other GUI applications headlessly

had to create the following files
~/.config/systemd/user/gamescope-session-plus@.service.d/override.conf

[Unit]
Wants=gamescopeApps.service

[Service]
ExecStartPre=/usr/bin/bash -c '/home/zany130/Scripts/wolTV.sh'

~/.config/systemd/user/gamescopeApps.service

[Unit]
Description=headless apps to run in gamescope session
After=openrgb.service
Requires=openrgb.service

[Service]
Type=forking
ExecStart=/home/zany130/Scripts/startGamescopeAppsBazzite.sh

~/.config/systemd/user/openrgb.service

[Unit]
Description=OpenRGB control

[Service]
Type=simple
ExecStart=/home/zany130/AppImages/openrgb_8682f8.appimage --profile MyRGB --server

[Install]
WantedBy=default.target

~/Scripts/wolTV.sh

#!/bin/bash
/usr/bin/python /home/zany130/.local/bin/alga power on 
sleep 5s
/usr/bin/python /home/zany130/.local/bin/alga input set HDMI_1

~/Scripts/startGamescopeAppsBazzite.sh

#!/bin/bash
flatpak kill me.timschneeberger.jdsp4linux
killall pcloud
sleep 10s
/usr/bin/xvfb-run flatpak run me.timschneeberger.jdsp4linux --watch &
/usr/bin/xvfb-run flatpak run com.discordapp.Discord &
/usr/bin/xvfb-run /home/zany130/AppImages/pcloud_082454.appimage &
/usr/bin/xvfb-run /home/zany130/AppImages/openrgb_8682f8.appimage &
1 Like

I really like this, thanks for sharing! What would be the best way to fire off your scripts whenever the machine boots or resumes from sleep, so it more fully emulates HDMI-CEC?

I think systemd has a suspend target you can use.

so you would write your own systemd unit in ~/.config/systemd/user and then at the end add

[Install]
WantedBy=suspend.target

then enable the service with

systemctl enable yourservice
1 Like

That’s so cool. Thank you very much!

https://wiki.archlinux.org/title/Power_management#Using_a_script_and_an_udev_rule

1 Like

My linux-fu is still in diapers so ill ask to be sure, if i want only to turn on the tv and switch hdmi to the tv i only need the override and the woltv files, correct? any modification needed to any of them? (and yea, i need to correct to my own paths, i know at least that lol)

All you would need is a ~/.config/systemd/user/gamescope-session-plus@.service.d/override.conf file containing the path of the script or the command to wake up your tv for example

[Service]
ExecStartPre=/usr/bin/bash -c '/home/zany130/Scripts/wolTV.sh'

notice I don’t have a [Unit] section anymore. that’s because for this use case we don’t want to overwrite any of the unit options

in a systemd override file anything you don’t specify is assumed to be kept the same as the original.

so in this case we only want to overwrite the ExecStartPre option under [Service]

note I’m am using alga to control my tv here, this only works on certain LG TVs. So if you have another brand TV it wont work.

for just turning on the tv you can send a wol signal with etherwake for example

sudo etherwake -i INTERFACE MAC_ADDRESS_OF_YOUR_DEVICE

etherwake is preinstalled on bazzite I belive.

there is also wakeonlan which is a bit easier to use as you only need to specify the MAC ADDRES of your device where as etherwake you also need the network interface of your PC ex: eth0 for ethernet or wlan0 for wifi

as for auto switching to the right channel that’s a bit more complex. you would need some way of controlling your tv’s channel with your PC.

that’s what alga does its a pc remote control app for lg tvs

So it technically isnt an universal hdmi-cec control, im pretty sure this wont work with my samsung tv be65a-h, if you have any idea just point me in the right direction, tyvm in advance

no i don’t think there is any way to remotely control a samung tv from a PC AFAIK

You can use WOL to turn on your tv if its plugged in through ethernet. Pretty much every tv supports this, but without some app or way to set inputs on your tv, it will probably just go to the last input you were on or your home screen, depending how you have your tv configured and if its smart or not

hmm looks like it might be possible on Samsung tv using Tizen os

no idea how to use it though. but basically you would need to replace everywhere I use alga in my script with this