<commit_before>#!/usr/bin/guile \
-e main -s
!#
(use-modules (ice-9 textual-ports))
(use-modules (ice-9 popen))

(define (file->string f)
  (call-with-input-file f
    (lambda (p)
      (get-string-all p))))

(define (file->number f)
  (let ((s (file->string f)))
    (string->number (string-trim-both s))))

(define (command->string command)
  (let* ((p (open-input-pipe command))
         (s (get-string-all p)))
    (close-pipe p)
    (string-trim-both s)))

(define charge-full-f "/sys/class/power_supply/BAT0/charge_full")
(define charge-now-f "/sys/class/power_supply/BAT0/charge_now")
(define charge-status-f "/sys/class/power_supply/BAT0/status")

(define (battery?)
  (file-exists? charge-full-f))

(define (battery-status)
  (let ((s (string-trim-both (file->string charge-status-f))))
    (cond ((string= "Full" s) 'full)
          ((string= "Discharging" s) 'discharging)
          ((string= "Charging" s) 'charging)
          (else '()))))

(define (battery-percent)
  (let ((full (file->number charge-full-f))
        (curr (file->number charge-now-f)))
    (/ (* curr 100) full)))

(define (volume-percent)
  (command->string "vol get"))

(define (mute?)
  (let ((s (command->string "pamixer --get-mute")))
    (string=? s "true")))

(define (essid)
  (command->string "essid"))

(define (format-section section value)<commit_msg>Floor battery percent<commit_after>#!/usr/bin/guile \
-e main -s
!#
(use-modules (ice-9 textual-ports))
(use-modules (ice-9 popen))

(define (file->string f)
  (call-with-input-file f
    (lambda (p)
      (get-string-all p))))

(define (file->number f)
  (let ((s (file->string f)))
    (string->number (string-trim-both s))))

(define (command->string command)
  (let* ((p (open-input-pipe command))
         (s (get-string-all p)))
    (close-pipe p)
    (string-trim-both s)))

(define charge-full-f "/sys/class/power_supply/BAT0/charge_full")
(define charge-now-f "/sys/class/power_supply/BAT0/charge_now")
(define charge-status-f "/sys/class/power_supply/BAT0/status")

(define (battery?)
  (file-exists? charge-full-f))

(define (battery-status)
  (let ((s (string-trim-both (file->string charge-status-f))))
    (cond ((string= "Full" s) 'full)
          ((string= "Discharging" s) 'discharging)
          ((string= "Charging" s) 'charging)
          (else '()))))

(define (battery-percent)
  (let ((full (file->number charge-full-f))
        (curr (file->number charge-now-f)))
    (floor (/ (* curr 100) full))))

(define (volume-percent)
  (command->string "vol get"))

(define (mute?)
  (let ((s (command->string "pamixer --get-mute")))
    (string=? s "true")))

(define (essid)
  (command->string "essid"))

(define (format-section section value)
{'fraction_non_alphanumeric': 0.20546932742054694, 'fraction_numerical': 0.005912786400591279, 'mean_word_length': 3.4523026315789473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '462990', 'n_tokens_mistral': 1024, 'n_tokens_neox': 1012, 'n_words': 226}