2020-08-10 18:26:41 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								*  About PumoPM  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  The Pumo Power  Manager (PumoPM for short)  is a custom power  manager I wrote
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  for myself in order  to have a lightweight one that does  exactly what I want,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  how I  want. Basically: I  want to be  informed of a  low level of  battery (I
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  consider 25% to be low, hence the defaults), very low (again, my preference is
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  at 15%), and then at critical level (10%) I want the computer to automatically
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  sleep, and if it stays asleep for a certain duration it will be suspended.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  This project is written for a GNU/Linux operating system running with systemd.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  I have  currently no plan  on making it  available on other  platforms, except
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								  maybe one day with [[https://guix.gnu.org/ ][Guix ]] (if you don’ ’ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  an awesome operating system, much better than NixOS in my opinion).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								**  Built with 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   [[http://spacemacs.org ][file:https://cdn.rawgit.com/syl20bnr/spacemacs/442d025779da2f62fc86c2082703697714db6514/assets/spacemacs-badge.svg ]]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 18:26:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								   PumoPM  is written  in pure,  stable  Rust (at  least >=  1.45.2). Its  three
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   dependencies are the crates [[https://github.com/svartalf/rust-battery ][battery ]], [[https://clap.rs/ ][clap ]], and [[https://github.com/hoodie/notify-rust ][notify-rust ]].
							 
						 
					
						
							
								
									
										
										
										
											2020-08-10 18:26:41 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								**  What does Pumo mean? 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								   It’ ’ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 18:03:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								**  Why is the main branch called ~senpai~? 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   This is a joke that originated from [[https://www.reddit.com/r/ProgrammerAnimemes/ ][r/ProgrammerAnimemes ]] when news were about
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								   defaulting to  another name than ~master~   for git’ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   someone proposed ~senpai~   on this reddit as an alternative  to ~master~ , and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								   here we are. This is a weeb’ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-10 18:26:41 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								*  Getting started  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								  To run the project, you currently only have one option: download the project’ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  source code,  compile it, and  run it. You will  need to have  [[https://www.rust-lang.org/ ][Rust installed ]].
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  Update your  Rust installation  if needed with  ~rustup update~ .  Then, simply
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 19:01:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								  begin with a ~git  clone~ , then cd into the project’ 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-10 18:26:41 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  build the project with ~cargo~ , and even install it locally if you want to.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  #+BEGIN_SRC sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    $ git clone https://labs.phundrak.com/phundrak/pumopm
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    $ cd pumopm
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    $ cargo build --release
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    $ cargo run --release # to run the project
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 18:19:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    $ cargo install --path . # optional, to install for the user the project
							 
						 
					
						
							
								
									
										
										
										
											2020-08-10 18:26:41 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  #+END_SRC
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 19:01:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  If you are an Arch Linux user, make sure you have ~rustup~  installed, and then
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  you can install PumoPM using the ~PKGBUILD~  available in the repository. To do
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  so, simply run
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  #+BEGIN_SRC sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    $ makepkg -si
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  #+END_SRC
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  You will then have PumoPM installed as  a native package on your machine which
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  you can uninstall using Pacman.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-10 18:26:41 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								*  Usage  
						 
					
						
							
								
									
										
										
										
											2020-08-11 18:03:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  It is possible to run PumoPM with a couple of different flags. You will find
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  their description here:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  ~-h --help~  :: displays a help message
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								  -  ~-V --version~  :: displays the program’ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  ~-l --low~  :: level at which the battery is considered to be low
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  ~-L --very-low~  :: level at which the battery is considered to be very low
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  ~-c --critical~  :: level at which the battery is considered to be critical
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								  -  ~-r --refresh-rate~  :: refresh rate of the battery’ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								  -  ~-v --verbose~  :: augment the program’ 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 19:01:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  The arguments ~-l~ , ~-L~  and ~-c~  accept an integer between 5 and 95 (actually
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 18:03:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  any value that will fit in an unsigned byte, but it will be rounded up to 5 or
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 19:01:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  down to 95), while ~-r~  accepts any  integer that can fit in a ~u64~ , although
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 18:03:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								  I’ ’ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  The levels  will also see  their values ordered. If  the ~-L~  value  is higher
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  than ~-l~ , then the program will automatically set it to one percent lower, or
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  to 5% (whichever is  higher). Same goes for the value of ~-c~   if it goes over
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								  the ~-L~  value, including after the re-evaluation of the latter’ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  instance, calling the program like so
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  #+BEGIN_SRC sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    $ pumopm -l 30 -L 32 -c 30
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  #+END_SRC
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  is the same as calling it like so
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  #+BEGIN_SRC sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    $ pumopm -l 30 -L 29 -c 28
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  #+END_SRC
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								*  TODO  Roadmap [0/2]  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  [ ]  system tray
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  [ ]  close the program with the exit code ~0~ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-10 18:26:41 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								*  License  
						 
					
						
							
								
									
										
										
										
											2020-08-11 18:12:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  This project is under the GPL-3.0 or later license. You can read it [[file:LICENSE ][here ]], but
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 18:03:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  basically, the following are allowed:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  Commercial use of this program and its source code
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  Modification of the program and the source code
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  Distribution of the program and the source code
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  Patent use of the program and the source code
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  Private use of the program and the source code
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  However, this program comes  with no warranty and I am  under no liability for
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  what you do with it. The conditions of using this program are:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  Notice your users of the license and copyright
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  State any changes in the code
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  Disclose the source code
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  -  Use the same license
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  Please note that I  am no lawyer, and the only legal document  you can read is
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  the one linked above.