Package: cecdaemon
cecdaemon - CEC Daemon for linux media centerscecdaemonis for managing theConsumer Electronics Control (CEC)capabilities of your linux media center. Some embedded systems (like Raspberry Pi) have native support for CEC. Many video cards do not have CEC capabilities, so you may need an adapter like theone offered by PulseEightto use CEC with your computer.Currently it is able to translate remote buttons to computer input, run shell commands, and set the device name, and run shell scripts on standby and wake.Requirements:python-cecpython-uinputInstallation:Installation should be done as root to allow installing commands to/usr/bin/Install from PIP# pip3 install cecdaemonInstall using setuptools# python3 setup.py installConfigurationcecdaemonlooks for a configuration file at /etc/cecdaemon.conf. The configuration file is a simple .ini style file. There are currently three main sections that can be configured:The[tv]section allows you to set the name that will be displayed on the tv for your device. It is truncated to the 14 character max.[tv]
name = HTPCThe[keymap]section allows you to map CEC user command codes to uinput events. The remote codes can be determined using thececusercodescommand. The command will output the CEC User Command name, and the code in both hex and decimal. The hex code matches the CEC Specification, the decimal code is what is used in the config for readability.# /usr/bin/cecusercodes
Initializing CEC, please wait...
If this takes too long ensure the device is not already in use
CEC device initialized, press remote keys or hit ^C to quit
Select pressed (hex: 0x0, dec: 0)
Up pressed (hex: 0x1, dec: 1)
Down pressed (hex: 0x2, dec: 2)
Left pressed (hex: 0x3, dec: 3)
Right pressed (hex: 0x4, dec: 4)
F1 (Blue) pressed (hex: 0x71, dec: 113)
F2 (Red) pressed (hex: 0x72, dec: 114)
F3 (Green) pressed (hex: 0x73, dec: 115)
F4 (Yellow) pressed (hex: 0x74, dec: 116)
^CKeypresses can be found inpython-uinput ev.py file. The format for assigning a key to a cec code looks like this:[keymap]
0 = KEY_ENTER
1 = KEY_UP
#STOP
69 = KEY_X
70 = KEY_PAUSE
113 = KEY_BLUEThe CEC Specification states that only Select, Directions, Exit, Numbers and Function Keys get forwarded to devices, but the actual implementation varies between vendors. Thececdaemon.conf-examplefile comes with a good baseline that works well with Kodi and Steam.The[cmd_name]sections can be used to run shell commands when a button is pressed or held down. For a simple press set the holdtime to 1. Use a separate section for each command. Remember to use the absolute path for the command if you are unsure what the PATH environment variable will be for the daemon. A command hook currently overrides any uinput keypresses.[cmd_reboot]
# Reboots when holding the red button for 400ms
key = 114
holdtime = 4000
command = /usr/bin/systemctl reboot

[cmd_switcher]
# Open the task switcher
key = 115
holdtime = 1
command =/usr/local/scripts/switcherThe[triggers]section can be used to run shell commands when the daemon receives events such as standby or wake.[triggers]
standby = /usr/bin/systemctl stop hyperiond
wake = /usr/bin/systemctl start hyperiondUsageRunning from the command line# cecdaemon --help
usage: cecdaemon [-h] [-d] [-v] [-c FILE]

optional arguments:
  -h, --help            show this help message and exit
  -d, --debug           Print debug messages
  -v, --verbose         Print verbose messages
  -c FILE, --config FILE
                        Configuration file
#Using the included systemd serviceCopy the script to the systemd directory:# cp examples/cecdaemon.service-example /etc/systemd/system/cecdaemon.serviceReload the daemons and start the service:# systemctl daemon-reload# systemctl start cecdaemonAnd to enable the service use:# systemctl enable cecdaemonViewing the stderr and stdout for troubleshooting:# journalctl -f -u cecdaemonUsing in another python script>>> from cecdaemon import cecdaemon
>>> cecdaemon.run()Changelog1.0.0 - Initial beta release