Couch Commander - a custom HTPC set-top box using LiveCode

A place for you to show off what you have made with LiveCode

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
speedbump1981
Posts: 14
Joined: Fri Aug 08, 2014 7:24 am

Couch Commander - a custom HTPC set-top box using LiveCode

Post by speedbump1981 » Wed Jan 31, 2024 1:38 am

I just wanted to share a video overview of a side project I started in June of 2023:

Couch Commander
https://www.youtube.com/watch?v=aV-qYv6UW4A

Here are some of the fine points:
  • UI navigation is done with a common Universal TV Remote, but you can use other input devices too.
  • PolyList and PolyGrid widgets do most of the heavy lifting.
  • Uses VLC and MPV for DVD playback. Blu-ray too, if you have the necessary files ;)
  • Uses Firefox in Kiosk mode + xdotool to enable a more seemless PeerTube playback experience (since the browser widget doesn't work on Linux).
  • Runs on Pop_OS and Linux Mint, currently deployed on 1x 4K UHD and 2x HD Televisions.
  • Background slideshow is customizable via JSON configuration within ~/.config/CouchCommander/ (for future automated deployments)
  • No ads or surveillance within Couch Commander (can't speak to the apps being launched, but I'm not spying on myself, that's for sure!).
  • Has been working like a champ for over 6 months now, and my spouse loves it!
So, am I going to release it to the public? Probably not.

I'm at a point where I've witnessed a variety of companies releasing set-top boxes with custom home screens (in the United States). Many of these boxes are Android TV-based, while others are proprietary, but all are very affordable. What makes releasing this project difficult is that I don't foresee any opportunity to cover my costs. I've thought about selling accessories for HTPC enthusiasts, but I've worked in online retail before and I just don't feel like I have the energy to compete with Amazon over $15 USB Infrared dongles.

If I imagined what I would do if I received a grant or was gifted a giant pile of money: I'd make a deal to buy enterprise computers destined for recycling, load 'em up with a custom Linux distro, and build ready-made "Couch Commander" boxes. They'd come with everything you'd need, and the software/hardware would be configured and tested before shipment. There would be no advertising, no analytics, no surveillance, etc. Just a fully customizable HTPC "home screen" that the consumer controls. That would certainly be fun, but without a huge investment in the beginning, I struggle to see how I'd break into the market.

Finally, I didn't get the impression that LiveCode Ltd. is all that interested in Linux now that they're pretty deep into a browser-based solution. I didn't see Linux appear in any of the LiveCode Create advertisements, so I'm going to take a page from Annie Duke and bet that LCC is not destined for Linux desktops. (I'm happy to be wrong. In fact, I'd be ecstatic to be wrong!)

Features still on my "wish list":
  • Chrome-cast support sounds possible, likely with VLC or MPV doing the heavy lifting again.
  • NOAA Emergency Weather Alerts (I've actually got this working pretty well, just need to add it to CC)
  • A secondary display for always-on captioning so I can watch movies without closed captioning obscuring my view (Got this working too, though the Local LLM I'm using needs some work).
That's about it. I'm happy to answer questions. Thanks for checking out my side project :-)
Derek Bump | Oshkosh, WI

Dreamscape Software (Closed)
JPEGCompress, "Side-scrolling Game Test"

Factory Direct Shippers, LLC (Retired)
Online Shopping Cart & Customer Information Manager

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9793
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Couch Commander - a custom HTPC set-top box using LiveCode

Post by FourthWorld » Wed Jan 31, 2024 2:50 am

Well done, Derek!
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3948
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Couch Commander - a custom HTPC set-top box using LiveCode

Post by bn » Wed Jan 31, 2024 10:00 am

Thanks Derek,

That looks amazing.
(unfortunately I hardly watch any TV...)
I especially liked the "Devo" part. I saw them once live in Berlin 1978. I still like them.

Kind regards
Bernd

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: Couch Commander - a custom HTPC set-top box using LiveCode

Post by jiml » Wed Jan 31, 2024 10:21 pm

Nifty!!! 👍🏻👍🏻👍🏻

stam
Posts: 2550
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Couch Commander - a custom HTPC set-top box using LiveCode

Post by stam » Thu Feb 01, 2024 2:17 am

Impressive - Looks very polished in the video, kudos!

speedbump1981
Posts: 14
Joined: Fri Aug 08, 2014 7:24 am

Re: Couch Commander - a custom HTPC set-top box using LiveCode

Post by speedbump1981 » Thu Feb 01, 2024 9:21 pm

Thanks for the positive feedback and kind words, folks.
bn wrote:
Wed Jan 31, 2024 10:00 am
I especially liked the "Devo" part. I saw them once live in Berlin 1978. I still like them.
Felt like an apt choice, due to my dis-satisfaction with Roku. Caught 'em live in California in 2018 after discovering many of my favourite artists were heavily influenced by their body of work. Didn't take much more than a greatest hits CD for me to become a big fan. Happy you enjoyed it.
Derek Bump | Oshkosh, WI

Dreamscape Software (Closed)
JPEGCompress, "Side-scrolling Game Test"

Factory Direct Shippers, LLC (Retired)
Online Shopping Cart & Customer Information Manager

trevix
Posts: 946
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Couch Commander - a custom HTPC set-top box using LiveCode

Post by trevix » Sat Feb 10, 2024 4:23 pm

Nice job.

If I understand, you were able to catch, in Livecode, the infrared signal from your remote, in order to navigate the UI.
If this the case, can you explain how you did it?
Trevix
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

speedbump1981
Posts: 14
Joined: Fri Aug 08, 2014 7:24 am

Re: Couch Commander - a custom HTPC set-top box using LiveCode

Post by speedbump1981 » Sat Feb 10, 2024 9:24 pm

trevix wrote:
Sat Feb 10, 2024 4:23 pm
Nice job.

If I understand, you were able to catch, in Livecode, the infrared signal from your remote, in order to navigate the UI.
If this the case, can you explain how you did it?
Trevix
Thank you! That's a good guess, but I'm actually using a slightly different approach. I'm relying on Linux Mint's support for converting some IR signals into keyboard input. Here's the LiveCode scripting responsible for handling my infrared remote control:

Code: Select all

on rawKeyDown pRawCode
   local tNumColumns
   
   -- Skip if this doesn't apply
   if the currentCard of stack "CouchCommander" is not the short name of this card then
      pass rawKeyDown
   end if
   
   -- Don't bother if we're in the background
   if sPollInput is false then pass rawKeyDown
   
   -- Used for calculating Up and Down
   put the numberOfColumns of widget "uiOptions" of card "ccMain" into tNumColumns
   
   uiHideCursor
   
   -- Determine which remote control button is being pressed
   switch pRawCode
      case "65361" -- Left Arrow
         doMoveMainSelection "-1"
         break
         
      case "65362" -- Up Arrow
         doMoveMainSelection ("-" & tNumColumns)
         break
         
      case "65363" -- Right Arrow
         doMoveMainSelection "1"
         break
         
      case "65364" -- Down Arrow
         doMoveMainSelection tNumColumns
         break
         
      case "65293" -- Numpad Enter
         doChooseSelection
         break
   end switch
   
   pass rawKeyDown
end rawKeyDown
Once you know the raw key code you can support all kinds of input devices. However, Plex and MPV both required adjustments to their respective input mapping configuration in order to support my preferred infrared remote controls:

MPV: Windows MCE IR Remote bindings
~/.config/mpv/input.conf

Code: Select all

DEL quit
CANCEL quit
0x21ff56 quit
ENTER cycle pause
Plex: Windows MCE IR Remote bindings
~/.var/app/tv.plex.PlexHTPC/data/plex/inputmaps/keyboard.json

Code: Select all

{
  "name": "Generic Keyboard",
  "idmatcher": "Keyboard.*",
  "mapping": {
    "Left": "left",
    "Right": "right",
    "Up": "up",
    "Down": "down",
    "Return|Enter": {
      "short": "enter",
      "long": "menu"
    },
    "Back|Esc|Backspace|Close|Del": {
      "short": "back",
      "long": "home"
    },
    "Pause": "play_pause",

    // Standard text entry. There's no distinction between upper and lower case
    // letters. The optional Shift key is only a flexibility convenience.
    "(?:Shift\\+)?([A-Z0-9.])": "%1",

    // Use Shift+letter to jump to the associated letter in supporting lists.
    "Shift\\+([A-Z])": "jump+%1",

    // Application shortcuts.
    "Space": ["space", "play_pause"],
    "P": "play_pause",
    "Ctrl\\+P": "pause",
    "X": "stop",
    "B": "back",
    "H": "home",
    "M": "menu",
    "A": "cycle_audio",
    "L": "cycle_subtitles",
    "S": "toggle_subtitles",
    "Alt\\+A": "increase_audio_delay",
    "Alt\\+Shift\\+A": "decrease_audio_delay",
    "Alt\\+S": "increase_subtitles_delay",
    "Alt\\+Shift\\+S": "decrease_subtitles_delay",
    "PgUp": ["page_up", "seek_forward"],
    "PgDown": ["page_down", "seek_backward"],
    "Home": "step_backward",
    "End": "step_forward",
    "Ctrl\\+F": "search",
    "\\[": "previous_pivot_tab",
    "\\]": "next_pivot_tab",
    "=": "increase_volume",
    "(Shift\\+)?\\+": "increase_volume",
    "\\-": "decrease_volume",
    "I": "info",
    "W": "toggle_watched",
    "Z": "cycle_aspect_ratio",
    "Ctrl\\+Shift\\+D": "debug",

    // Media keys (when not caught by an OS service)
    "Home Page": "home",
    "Media Play": "play_pause",
    "Media Previous": "skip_previous",
    "Media Next": "skip_next",

    // Application window handling.
    "Alt\\+(Return|Enter)": "toggle_fullscreen",
    "F11": "toggle_fullscreen",
    "\\\\": "toggle_fullscreen",
    "E": "exit",

    // The `|<< <<` and `>> >>|` button on a Harmony Hub remote sends different
    // keys based on the Harmony device configuration. A long press action to
    // send `skip_previous` or `skip_next` must be configured in the Harmony
    // app. The default configuration sends no keyboard events to Plex.
    //
    // - "Media Rewind" and "Media Fast Forward" are sent when the device is
    //   configured as a Windows computer.
    // - "R" and "F" are sent when the device is configured as a Microsoft Plex
    //   entertainment device..
    "(Media Fast Forward)|F": "seek_forward",
    "(Media Rewind)|R": "seek_backward"
  }
}
I hope that answers your question, but I'm happy to discuss more if requested. Thanks for the kind feedback :-)
Derek Bump | Oshkosh, WI

Dreamscape Software (Closed)
JPEGCompress, "Side-scrolling Game Test"

Factory Direct Shippers, LLC (Retired)
Online Shopping Cart & Customer Information Manager

trevix
Posts: 946
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Couch Commander - a custom HTPC set-top box using LiveCode

Post by trevix » Sun Feb 11, 2024 12:11 am

Mmmmh...No Linux here: I was hoping to catch the infrared input in an Android 11 TvBox (that has an infrared receiver off course ) LC standalone.
I already tried the "rawkeydown" but it doesn't work: nothing.

The only things that seems to react to the remote, albeit sometime losing the focus, are the answer/ask LC dialog buttons (I think sombody told be that they are written in C) and the native Android button widget.
Too bad. LC standalone runs very well, if not fast, on those little cheap boxes.
Thanks
Trevix
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

speedbump1981
Posts: 14
Joined: Fri Aug 08, 2014 7:24 am

Re: Couch Commander - a custom HTPC set-top box using LiveCode

Post by speedbump1981 » Sun Feb 11, 2024 12:34 am

I wish I could be of more help when it comes to Android, but I'm totally unfamiliar with that platform. However, I'll keep my eyes peeled if I happen upon something that'll help you out. Good luck :-)
Derek Bump | Oshkosh, WI

Dreamscape Software (Closed)
JPEGCompress, "Side-scrolling Game Test"

Factory Direct Shippers, LLC (Retired)
Online Shopping Cart & Customer Information Manager

Post Reply

Return to “Made With LiveCode”