Don't judge me to hard added by YumYumYum on Sat Mar 19 14:24:53 2016
(require-extension extras utils) (load "terminal-illness.scm") ; note to self: don't use this macro for anything serious. Not thread safe. Not pretty. (define-syntax define-command (syntax-rules () ((_ MACRO-command-name MACRO-run) (define (MACRO-command-name) (define oldport (current-output-port)) (define nowhere (make-output-port void void)) (current-output-port nowhere) (define retval (system MACRO-run)) (current-output-port oldport) retval)))) (define-command check-openvpn "systemctl is-active --quiet openvpn@mullvad") (define-command check-transmission "systemctl is-active --quiet transmission") (define (get-temp) (substring (read-all "/sys/devices/virtual/thermal/thermal_zone0/temp") 0 2)) (define TTY1 (open-output-file "/dev/tty1")) (current-output-port TTY1) (set-buffering-mode! TTY1 #:none) (define (main) (display-clear) (display (string-append (blue "Welcome to Kato") "\nSystem Services:" "\n> OpenVPN: " (if (check-openvpn) (green "OK!") (red "Failed")) "\n> Transmission: " (if (check-transmission) (green "OK!") (red "Failed")) "\nCPU Temperature: " (let* ([temp-str (get-temp)] [temp (string->number temp-str)]) (cond [(< temp 55) (blue temp-str)] [(< temp 70) temp-str] [else (red temp-str)])) "°C\n"))) (main)