updates
This commit is contained in:
		
							parent
							
								
									6e1c5a007c
								
							
						
					
					
						commit
						2701cba99e
					
				
					 5 changed files with 33 additions and 15 deletions
				
			
		| 
						 | 
				
			
			@ -40,5 +40,5 @@
 | 
			
		|||
	         :min 0))
 | 
			
		||||
            (button
 | 
			
		||||
             :class "close-icon"
 | 
			
		||||
             :onclick "eww close battery"
 | 
			
		||||
             :onclick "echo \"killed\" > /tmp/ewwbattery && eww close battery"
 | 
			
		||||
             "")))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										8
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							| 
						 | 
				
			
			@ -425,16 +425,16 @@
 | 
			
		|||
    },
 | 
			
		||||
    "nixpkgs-stable_2": {
 | 
			
		||||
      "locked": {
 | 
			
		||||
        "lastModified": 1688392541,
 | 
			
		||||
        "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=",
 | 
			
		||||
        "lastModified": 1701952659,
 | 
			
		||||
        "narHash": "sha256-TJv2srXt6fYPUjxgLAL0cy4nuf1OZD4KuA1TrCiQqg0=",
 | 
			
		||||
        "owner": "nixos",
 | 
			
		||||
        "repo": "nixpkgs",
 | 
			
		||||
        "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b",
 | 
			
		||||
        "rev": "b4372c4924d9182034066c823df76d6eaf1f4ec4",
 | 
			
		||||
        "type": "github"
 | 
			
		||||
      },
 | 
			
		||||
      "original": {
 | 
			
		||||
        "owner": "nixos",
 | 
			
		||||
        "ref": "nixos-22.11",
 | 
			
		||||
        "ref": "nixos-23.11",
 | 
			
		||||
        "repo": "nixpkgs",
 | 
			
		||||
        "type": "github"
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,7 @@
 | 
			
		|||
    dutree
 | 
			
		||||
    cachix
 | 
			
		||||
    unzip
 | 
			
		||||
    ollama
 | 
			
		||||
    # unrar
 | 
			
		||||
    p7zip
 | 
			
		||||
    zip
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,6 @@ with lib;
 | 
			
		|||
    ungoogled-chromium
 | 
			
		||||
    qutebrowser
 | 
			
		||||
    brave
 | 
			
		||||
    ollama
 | 
			
		||||
    ttyper
 | 
			
		||||
    kget
 | 
			
		||||
    audacity
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,8 @@
 | 
			
		|||
#!/usr/bin/env -S sbcl --script
 | 
			
		||||
(require "uiop")
 | 
			
		||||
(load "/home/chris/.sbclrc")
 | 
			
		||||
(ql:quickload :clingon)
 | 
			
		||||
(ql:quickload :serapeum)
 | 
			
		||||
 | 
			
		||||
(defun get-value (file)
 | 
			
		||||
  "Read a file and get it's value as a list of lines"
 | 
			
		||||
  (with-open-file (in file)
 | 
			
		||||
| 
						 | 
				
			
			@ -9,14 +10,31 @@
 | 
			
		|||
          while line
 | 
			
		||||
          collect line)))
 | 
			
		||||
 | 
			
		||||
(setf capacity (parse-integer (car (get-value "/sys/class/sound/card0/number"))))
 | 
			
		||||
(setf status (parse-integer (car (get-value "/sys/class/sound/card1/number"))))
 | 
			
		||||
(defun close-eww ()
 | 
			
		||||
  (uiop:run-program "eww close battery" :ignore-error-status t))
 | 
			
		||||
(defun open-eww ()
 | 
			
		||||
  (uiop:run-program "eww open battery" :ignore-error-status t))
 | 
			
		||||
 | 
			
		||||
(loop for i from 0
 | 
			
		||||
      while (< i 10)
 | 
			
		||||
      do (uiop:println i))
 | 
			
		||||
(defun clear-file (file)
 | 
			
		||||
  (with-open-file (out file :direction :output :if-exists :overwrite :if-does-not-exist :create)
 | 
			
		||||
    (write-sequence "      " out))
 | 
			
		||||
  (uiop:println "Clearing killed"))
 | 
			
		||||
 | 
			
		||||
(if (<= capacity 30)
 | 
			
		||||
    (uiop:run-program (uiop:strcat "/run/current-system/sw/bin/eww " "open " "battery"))
 | 
			
		||||
    (uiop:run-program (uiop:strcat "/run/current-system/sw/bin/eww " "close " "battery")))
 | 
			
		||||
(setf capacity (parse-integer (car (get-value "/sys/class/power_supply/BAT1/capacity"))))
 | 
			
		||||
(setf status (car (get-value "/sys/class/power_supply/BAT1/status")))
 | 
			
		||||
 | 
			
		||||
(loop do (progn
 | 
			
		||||
           (sleep 10)
 | 
			
		||||
           (format t "~&Charge: ~a, Status: ~a" capacity status)
 | 
			
		||||
           (if (string= "Charging" status)
 | 
			
		||||
               (progn (format t "~&Charging, closing EWW") (close-eww))
 | 
			
		||||
               (if (<= capacity 30)
 | 
			
		||||
                   (progn (setf killed (serapeum:trim-whitespace (car (get-value "/tmp/ewwbattery"))))
 | 
			
		||||
                          (if killed
 | 
			
		||||
                              (progn (format t "~&EWW has been killed, waiting 3 minutes")
 | 
			
		||||
                                     (clear-file #p"/tmp/ewwbattery")
 | 
			
		||||
                                     (sleep 360)))
 | 
			
		||||
                          (format t "~&Opening EWW")
 | 
			
		||||
                          (open-eww))
 | 
			
		||||
                   (progn (format t "~&Charged more than 30%, Closing EWW")
 | 
			
		||||
                          (close-eww))))))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue