Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Using a number pad to control moode
#1
Hi All, 

I've written some code so that with a simple USB number pad, internet stations and functions can be called directly without the need for a screen or phone.

   


This is very much in progress work so will have issues!

Any advice on improvements would be great!

Link: https://github.com/mlake1/moode-numpad-controller


Thanks!
Reply
#2
There is no REST API command named 'shutdown'

If you want to do a moode shutdown try the code below

Code:
subprocess.call(['/var/local/www/commandw/restart.sh','poweroff'])
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(06-16-2025, 01:48 PM)Tim Curtis Wrote: There is no REST API command named 'shutdown'

If you want to do a moode shutdown try the code below

Code:
subprocess.call(['/var/local/www/commandw/restart.sh','poweroff'])

Thanks Tim, I will update and test,
Reply
#4
Nice to see someone has done more with triggerhappy that I did several years ago (buried in the FAQ and Guides subforum). Congrats.

Your github repo is very nicely documented in its README. Few take the time.


Quick comment on the README. There appears to be a formatting issue in the last part of the USB Numpad section, starting with “**To test follow these steps”

I have no interest in a keypad interface but this will be a great interface for those who do.

Looking forward to see what happens next Smile

Regards,
Kent
Reply
#5
(06-16-2025, 01:48 PM)Tim Curtis Wrote: There is no REST API command named 'shutdown'

If you want to do a moode shutdown try the code below

Code:
subprocess.call(['/var/local/www/commandw/restart.sh','poweroff'])

Thanks Tim, I've updated to:


Code:
def shutdown():
   """Shutdown the system safely"""
   print("Initiating shutdown...")
   try:
       subprocess.call(['/var/local/www/commandw/restart.sh', 'poweroff'])
       print("Shutdown command sent")
   except Exception as e:
       print(f"Shutdown failed: {e}"


I did have to update the user in /lib/systemd/system/triggerhappy.service from "Nobody" to "moode" and give moode sudo privileges. 

Now all working! thank you for your help
Reply
#6
(06-16-2025, 02:48 PM)TheOldPresbyope Wrote: Nice to see someone has done more with triggerhappy that I did several years ago (buried in the FAQ and Guides subforum). Congrats.

Your github repo is very nicely documented in its README. Few take the time.


Quick comment on the README. There appears to be a formatting issue in the last part of the USB Numpad section, starting with “**To test follow these steps”

I have no interest in a keypad interface but this will be a great interface for those who do.

Looking forward to see what happens next Smile

Regards,
Kent

Thanks! I have updated the formatting issue. I documented well, so I can remember for myself as much as anyone else! It's rather a niche project, but hopefully someone will find it useful too!
Reply
#7
(06-16-2025, 02:54 PM)numpad Wrote: I did have to update the user in /lib/systemd/system/triggerhappy.service from "Nobody" to "moode" and give moode sudo privileges. 

Now all working! thank you for your help

In a regular moOde installation, this could be the default user (who already has sudo privileges*) rather than always "moode".

Regards,
Kent

*see /etc/sudoers.d/010_pi-nopasswd
Reply
#8
(06-16-2025, 03:11 PM)TheOldPresbyope Wrote:
(06-16-2025, 02:54 PM)numpad Wrote: I did have to update the user in /lib/systemd/system/triggerhappy.service from "Nobody" to "moode" and give moode sudo privileges. 

Now all working! thank you for your help

In a regular moOde installation, this could be the default user (who already has sudo privileges*) rather than always "moode".

Regards,
Kent

*see /etc/sudoers.d/010_pi-nopasswd

Thank you for this feedback, I've edited the install.sh to auto-detect privileged user rather than assuming 'moode' user.
Reply


Forum Jump: