suspend


Home Back Clone

Suspend

A simple utility for send command to a Gnu/Linux device.

It start a http server and you can send command with curl or other tools. Example:

  curl -X POST -d "pkey=<my passwrd encoded in md5>" http://192.168.1.8:7070/suspend/suspend_now

[] POST   /suspend/poweroff_now     
[] POST   /suspend/reboot_now       
[] POST   /suspend/play             
[] POST   /suspend/pause            
[] POST   /suspend/stop             
[] POST   /suspend/next             
[] POST   /suspend/previous  

For encode your password run from terminal

  echo -n "mysecret" |md5sum

Shutdown, suspend and reboot

Please create file /etc/sudoers.d/suspend with this content:

  %users  ALL = NOPASSWD: /usr/bin/systemctl suspend
  %users  ALL = NOPASSWD: /usr/bin/systemctl poweroff
  %users  ALL = NOPASSWD: /usr/bin/systemctl reboot

Then add your user to group "users".

Control mpris applications

Install playerctl package and run at start suspend with suspend.desktop inside your desktop environment. Edit suspend.desktop according to your needs.

Run server from commandline

  key=<my password encoded in md5sum> ./suspend

Run from systemd

Copy the unit file (suspend.service) in /etc/systemd/system. Copy suspend binary in /usr/local/bin/. The run:

  sudo systemctl enable --now suspend

In this case only suspend,poweroff and reboot works. If you wants control still mpris player you have to use suspend.desktop file for autostart your X session.


Powered by Code, a simple repository browser by Fabio Di Matteo