Finally made real laptop detection

This commit is contained in:
Chris Cochrun 2021-02-12 05:32:47 -06:00
parent 4be501d3ef
commit 53fdeb8db0

View file

@ -1,4 +1,5 @@
;; Standard awesome library ;; -*- comment-end: ""; -*-
;; Standard awesome library|#
(local gears (require "gears")) (local gears (require "gears"))
(local awful (require "awful")) (local awful (require "awful"))
(require "awful.autofocus") (require "awful.autofocus")
@ -66,12 +67,16 @@
(local ctrl "Control") (local ctrl "Control")
(local alt "Mod1") (local alt "Mod1")
;; Set hostname so that we can utilize specific features on different machines|# ;; Set hostname so that we can utilize specific features on different machines|#|#
(var laptop false) (local hostname-handle (io.popen "hostname"))
(awful.spawn.easy_async "hostname" (fn [ stdout stderr reason exit_code ] (local hostname (hostname-handle:read "a"))
(if (= "chris-linuxlaptop\n" stdout) (hostname-handle:close)
(set laptop true) (local laptop (= hostname "chris-linuxlaptop\n"))
(set laptop true)))) ;; (local laptop false)
;; (fn set-laptop [str]
;; (set laptop str))
;; (fn get-hostname [?callback]
;; (awful.spawn.easy_async "hostname" (fn [ stdout ] stdout)))
(naughty.notify {:text (tostring laptop)}) (naughty.notify {:text (tostring laptop)})
;; (if laptop (naughty.notify {:text "laptop detected"}) (naughty.notify {:text "laptop not detected"})) ;; (if laptop (naughty.notify {:text "laptop detected"}) (naughty.notify {:text "laptop not detected"}))