#!/usr/bin/env bb (ns inhibit-sleep (:require [clojure.java.shell :refer [sh]])) (defn has-lock? [] (->> (sh "systemd-inhibit") :out (clojure.string/split-lines) (filter #(re-find #"inhibit-sleep" %)) seq)) (case (some->> *command-line-args* first) "get" (if (boolean (has-lock?)) "inhibited" "normal") "toggle" (if (has-lock?) nil (apply sh (clojure.string/split "systemd-inhibit \ --what=handle-lid-switch:sleep \ --why=':inhibit-sleep' \ --mode=block cat" #"\s+"))))