├── .gitignore ├── kodi-openbox ├── usr │ ├── bin │ │ ├── kodi-openbox-runprogram │ │ ├── kodi-openbox-runprogram.real │ │ └── kodi-openbox-session │ └── share │ │ └── xsessions │ │ └── kodi-openbox.desktop └── DEBIAN │ └── control └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.deb 2 | *.save -------------------------------------------------------------------------------- /kodi-openbox/usr/bin/kodi-openbox-runprogram: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | kodi-openbox-runprogram.real "$@" & 3 | disown 4 | -------------------------------------------------------------------------------- /kodi-openbox/usr/share/xsessions/kodi-openbox.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Kodi Openbox 3 | Comment=This session will start Kodi media center on top of an Openbox session 4 | Exec=/usr/bin/kodi-openbox-session 5 | Type=Application 6 | -------------------------------------------------------------------------------- /kodi-openbox/DEBIAN/control: -------------------------------------------------------------------------------- 1 | Package: kodi-openbox 2 | Version: 1.0.5 3 | Section: base 4 | Priority: optional 5 | Architecture: all 6 | Depends: bash, openbox, kodi 7 | Maintainer: Luis Finke 8 | Description: An xsession that runs Kodi Media Center on top of an Openbox session 9 | 10 | -------------------------------------------------------------------------------- /kodi-openbox/usr/bin/kodi-openbox-runprogram.real: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p ~/.kodi-openbox 3 | mkdir -p ~/.kodi-openbox/tmp 4 | display=$(echo "${DISPLAY}" | tr ':' '_') 5 | echo $$ > ~/.kodi-openbox/tmp/program-running.$display 6 | kpid=$(cat ~/.kodi-openbox/tmp/session-pid.$display) 7 | if [ -n "$kpid" ] 8 | then 9 | echo "closing kodi" 10 | kill -9 $kpid 11 | fi 12 | echo "running program" 13 | eval "$@" 14 | eval_result=$? 15 | echo "finished running program" 16 | exit $eval_result 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kodi-openbox 2 | An xsession that runs Kodi media center on top of an Openbox session 3 | 4 | ## Install 5 | 6 | **Debian/Ubuntu distros** 7 | 8 | ```bash 9 | ./build.sh 10 | sudo dpkg -i kodi-openbox.deb 11 | ``` 12 | 13 | **Arch distros** 14 | 15 | ```bash 16 | sudo pacman -S fakeroot dpkg debtap 17 | ./build.sh 18 | debtap kodi-openbox.deb 19 | ``` 20 | 21 | This will return an Arch package that can be installed with your favorite package manager, (Pacman, Octopi, Pamac, etc). 22 | 23 | 24 | **Other Linux distros** 25 | 26 | Note, this command manually copies all files to their intended places in the filesystem, meaning they will need to be uninstalled manually. 27 | 28 | ```bash 29 | sudo cp -r -t /usr kodi-openbox/usr/**/* 30 | ``` 31 | 32 | ## Usage 33 | 34 | On most systems, you should be able to choose your X session at the login screen. Choose "Kodi Openbox" and log in to start the session. 35 | 36 | ### Commands 37 | 38 | * **kodi-openbox-session** - runs a kodi-openbox session 39 | * **kodi-openbox-runprogram** - closes kodi and runs a command. Kodi will reopen when the command completes. Arguments are the command to run 40 | 41 | ### Openbox background 42 | To set the background color of your openbox session, add the following command to *~/.config/openbox/autostart.sh* 43 | ``` bash 44 | xsetroot -solid '#000000' 45 | ``` 46 | This will set the openbox background color to black, but you can change the hex value to be any color. 47 | 48 | ### Launching external programs from kodi 49 | There are various kodi addons for launching external programs, but the one I tend to use is [Advanced Launcher](http://kodi.wiki/view/Add-on:Advanced_Launcher). If you want kodi to close when launching an external program, use the **kodi-openbox-runprogram** command as your program, and the command you want to run as its arguments. 50 | 51 | ### Preventing display sleep in external programs 52 | If your display keeps going to sleep outside of kodi, it may be caused by a number of different programs. 53 | 54 | To prevent gnome desktop from putting your display to sleep, run the following commands in a terminal while logged in as your kodi user: 55 | ``` bash 56 | # Prevent display from going to sleep 57 | gsettings set org.gnome.desktop.session idle-delay 0 58 | # Prevent session from locking if the display does go to sleep 59 | gsettings set org.gnome.desktop.screensaver lock-enabled false 60 | ``` 61 | To prevent X11 from putting your display to sleep, add the following commands to *~/.config/openbox/autostart.sh* 62 | ``` bash 63 | # Disable screen saver 64 | xset s off 65 | # Disable screen blanking 66 | xset s noblank 67 | # Disable "Display Power Management Signaling" 68 | xset -dpms 69 | ``` 70 | -------------------------------------------------------------------------------- /kodi-openbox/usr/bin/kodi-openbox-session: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p ~/.kodi-openbox 4 | mkdir -p ~/.kodi-openbox/tmp 5 | 6 | display=$(echo "${DISPLAY}" | tr ':' '_') 7 | 8 | ending=false 9 | 10 | function onquit 11 | { 12 | if $ending 13 | then 14 | return; 15 | fi 16 | ending=true 17 | echo "Caught signal $1" 18 | if [ -a ~/.kodi-openbox/onkill ] 19 | then 20 | echo "running onkill script" 21 | ~/.kodi-openbox/onkill "$1" 22 | fi 23 | if [ -n "$kpid" ] 24 | then 25 | rm -f ~/.kodi-openbox/tmp/session-pid.$display 26 | fi 27 | exit 0 28 | } 29 | 30 | if [ ! -f ~/.kodi-openbox/onstart ] 31 | then 32 | cat > ~/.kodi-openbox/onstart << EOF 33 | #!/bin/bash 34 | # Put some code here to run when a kodi-openbox session successfully starts 35 | EOF 36 | chmod +x ~/.kodi-openbox/onstart 37 | fi 38 | 39 | if [ ! -f ~/.kodi-openbox/onfinish ] 40 | then 41 | cat > ~/.kodi-openbox/onfinish << EOF 42 | #!/bin/bash 43 | # Put some code here to run when a kodi-openbox session ends 44 | EOF 45 | chmod +x ~/.kodi-openbox/onfinish 46 | fi 47 | 48 | if [ ! -f ~/.kodi-openbox/onkill ] 49 | then 50 | cat > ~/.kodi-openbox/onkill << EOF 51 | #!/bin/bash 52 | # Put some code here to run when a kodi-openbox session is sent a SIGINT, SIGTERM, or SIGQUIT 53 | EOF 54 | chmod +x ~/.kodi-openbox/onkill 55 | fi 56 | 57 | ( 58 | flock -x -n 200 || (echo "only one session of kodi-openbox can be run at a time on a given display" && exit -2) 59 | 60 | set -m 61 | 62 | trap 'onquit "SIGINT"' SIGINT 63 | trap 'onquit "SIGTERM"' SIGTERM 64 | trap 'onquit "SIGQUIT"' SIGQUIT 65 | 66 | openbox-session & 67 | oppid=$! 68 | rm -f ~/.kodi-openbox/tmp/program-running.$display 69 | if [ -f ~/.kodi-openbox/onstart ] 70 | then 71 | ~/.kodi-openbox/onstart 72 | fi 73 | while ps -p $oppid > /dev/null 74 | do 75 | if command -v flatpak > /dev/null 2>&1 && flatpak info tv.kodi.Kodi > /dev/null 2>&1 76 | then 77 | flatpak run tv.kodi.Kodi & 78 | kpid=$! 79 | elif [ -f /usr/lib/kodi/kodi.bin ] 80 | then 81 | /usr/lib/kodi/kodi.bin & 82 | kpid=$! 83 | elif [ -f /usr/lib/x86_64-linux-gnu/kodi/kodi.bin ] 84 | then 85 | /usr/lib/x86_64-linux-gnu/kodi/kodi.bin & 86 | kpid=$! 87 | elif [ -f /usr/lib/i386-linux-gnu/kodi/kodi.bin ] 88 | then 89 | /usr/lib/i386-linux-gnu/kodi/kodi.bin & 90 | kpid=$! 91 | elif [ -f /usr/lib/arm-linux-gnueabihf/kodi/kodi.bin ] 92 | then 93 | /usr/lib/arm-linux-gnueabihf/kodi/kodi.bin & 94 | kpid=$! 95 | elif [ -f /usr/lib/x86_64-linux-gnu/kodi/kodi-x11 ] 96 | then 97 | /usr/lib/x86_64-linux-gnu/kodi/kodi-x11 & 98 | kpid=$! 99 | else 100 | kodi & 101 | kpid=$! 102 | fi 103 | echo "$kpid" > ~/.kodi-openbox/tmp/session-pid.$display 104 | fg 105 | rm -f ~/.kodi-openbox/tmp/session-pid.$display 106 | 107 | if [ -f ~/.kodi-openbox/tmp/program-running.$display ] 108 | then 109 | lpid=$(cat ~/.kodi-openbox/tmp/program-running.$display) 110 | rm -f ~/.kodi-openbox/tmp/program-running.$display 111 | if [ -n "$lpid" ] 112 | then 113 | while [ -e /proc/$lpid ]; do 114 | sleep 1 115 | done 116 | else 117 | break 118 | fi 119 | else 120 | break 121 | fi 122 | done 123 | ending=true 124 | openbox --exit 125 | wait $oppid 126 | ) 200>~/.kodi-openbox/tmp/displaylock.$display 127 | 128 | rm -f ~/.kodi-openbox/tmp/program-running.$display 129 | rm -f ~/.kodi-openbox/tmp/displaylock.$display 130 | 131 | if [ -f ~/.kodi-openbox/onfinish ] 132 | then 133 | ~/.kodi-openbox/onfinish 134 | fi 135 | 136 | --------------------------------------------------------------------------------