Skip to content

Commit

Permalink
feat: cec-control
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed May 12, 2024
1 parent f8426cd commit a1b9229
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkgbuild/sk-chos-addon-git/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ depends=('expect'
'cage'
'wlr-randr'
'glow'
'libcec'
)
provides=(sk-chos-addon)
conflicts=(sk-chos-addon)
Expand Down
1 change: 1 addition & 0 deletions pkgbuild/sk-chos-addon/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ depends=('expect'
'cage'
'wlr-randr'
'glow'
'libcec'
)
provides=(sk-chos-addon)
conflicts=(sk-chos-addon-git)
Expand Down
23 changes: 23 additions & 0 deletions src/chimeraos-addon/bin/cec-control
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/bash
ACTION="$1"

source /etc/default/cec-control

# OVERRIDE WITH DEFAULTS IF NOT SET
CEC_TVID=${CEC_TVID:-0}
CEC_WAKE=${CEC_WAKE:-true}
CEC_SETSOURCE=${CEC_SETSOURCE:-true}
CEC_ONPOWEROFF_STANDBY=${CEC_ONPOWEROFF_STANDBY:-true}
CEC_ONSLEEP_STANDBY=${CEC_ONSLEEP_STANDBY:-false}

# Run specified actions
if [ "${ACTION}" = "onboot" ] && [ "$CEC_WAKE" = true ]; then
echo "on $CEC_TVID" | cec-client -s -d 1
if [ "CEC_SETSOURCE" = true ]; then
echo "as" | cec-client -s -d 1
fi
elif [ "${ACTION}" = "onpoweroff" ] && [ "$CEC_ONPOWEROFF_STANDBY" = true ]; then
echo "standby $CEC_TVID" | cec-client -s -d 1
elif [ "${ACTION}" = "onsleep" ] && [ "$CEC_ONSLEEP_STANDBY" = true ]; then
echo "standby $CEC_TVID" | cec-client -s -d 1
fi
5 changes: 5 additions & 0 deletions src/chimeraos-addon/etc/default/cec-control
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CEC_TVID=0
CEC_WAKE=true
CEC_SETSOURCE=true
CEC_ONPOWEROFF_STANDBY=true
CEC_ONSLEEP_STANDBY=false
2 changes: 2 additions & 0 deletions src/chimeraos-addon/lib/udev/rules.d/99-cec-bluetooth.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# from https://github.com/ublue-os/bazzite/pull/1105
ACTION=="add", SUBSYSTEM=="bluetooth", RUN+="/usr/bin/cec-control onboot"
10 changes: 10 additions & 0 deletions src/chimeraos-addon/systemd/system/cec-onboot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Run CEC actions on boot
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

[Service]
Type=oneshot
ExecStart=-/usr/bin/cec-control onboot

[Install]
WantedBy=multi-user.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
11 changes: 11 additions & 0 deletions src/chimeraos-addon/systemd/system/cec-onpoweroff.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Run CEC actions for poweroff
DefaultDependencies=no
Before=final.target

[Service]
Type=oneshot
ExecStart=-/usr/bin/cec-control onpoweroff

[Install]
WantedBy=poweroff.target
11 changes: 11 additions & 0 deletions src/chimeraos-addon/systemd/system/cec-onsleep.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Run CEC actions for sleep
DefaultDependencies=no
Before=final.target

[Service]
Type=oneshot
ExecStart=-/usr/bin/cec-control onsleep

[Install]
WantedBy=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

0 comments on commit a1b9229

Please sign in to comment.