awesome/conf/keys.fnl

120 lines
3.3 KiB
Plaintext
Raw Permalink Normal View History

2019-01-15 11:20:10 +11:00
;;; conf/keys.fnl --- Global keys
;;; Code:
(var keys {})
(local gears (require :gears))
(local awful (require :awful))
(local apps (require :conf.apps))
(local key (. (require :lib.keys) :key))
;;;
;; Functions
(fn register [...]
(set keys (gears.table.join keys ...)))
;; Spawn lamda
(fn run [prog]
(fn [] (awful.spawn prog)))
;; Run silent
(fn run! [prog]
(fn [] (awful.spawn prog false)))
(fn playerctl [a]
(run! (.. "playerctl " a)))
(fn mpc [a]
(run! (.. "mpc " a)))
(fn amixer [args]
(run! (.. "amixer sset Master " args)))
(fn light [a v]
(let [flag (. {:up "-A" :down "-U"} a)]
(run! (.. "light " flag " " (tostring v)))))
(fn with-tag [i fun]
(lambda [] (when client.focus
(let [tag (. client.focus.screen.tags i)]
(when tag
(fun tag))))))
(fn apply-focus [i attr]
(with-tag i (lambda [t] (: client.focus attr t))))
(fn current-tag []
(. (awful.screen.focused) :selected_tag))
(fn focused-tag-by-index [i]
(. (awful.screen.focused) :tags i))
(fn with-focused-tag [i fun]
(lambda [] (let [tag (focused-tag-by-index i)]
(when tag
(fun tag)))))
(fn focus [c]
(when c
(set client.focus c)
(: c :raise)))
;;;
;; Configuration
(register
(key [:mod :ctrl :shift] :q awesome.quit)
(key [:mod :ctrl] :r awesome.restart)
(key [:mod :ctrl] :q (run "oblogout"))
(key [:mod] :equal (lambda []
(doto (current-tag)
(tset :master_width_factor 0.5)
(tset :master_count 1)
(tset :column_count 1))))
(key [:mod :ctrl] :l (lambda [] (awful.tag.incmwfact 0.05)))
(key [:mod :ctrl] :h (lambda [] (awful.tag.incmwfact -0.05)))
(key [:mod] :comma (lambda [] (awful.tag.incnmaster 1 nil true)))
(key [:mod] :period (lambda [] (awful.tag.incnmaster -1 nil true)))
(key [:mod :ctrl] :period (lambda [] (awful.tag.incncol 1 nil true)))
(key [:mod :ctrl] :comma (lambda [] (awful.tag.incncol -1 nil true)))
(key [:mod] :Return (run apps.terminal))
(key [:mod] :d (run apps.dropdown))
(key [:mod] :space (lambda [] (awful.layout.inc 1)))
(key [:mod] :r (run apps.rofi))
(key [:mod] :p (run "xfce4-display-settings"))
(key [:mod] :e (run apps.editor))
(key [:mod] :BackSpace (lambda [] (focus (awful.client.restore))))
(key [] :XF86AudioPlay (playerctl :play-pause))
(key [] :XF86AudioNext (playerctl :next))
(key [] :XF86AudioPrev (playerctl :previous))
;; (key [] :XF86AudioRaiseVolume (amixer "5%+"))
;; (key [] :XF86AudioLowerVolume (amixer "5%-"))
;; (key [] :XF86AudioMute (amixer "toggle"))
2019-01-15 11:20:10 +11:00
(key [] :XF86MonBrightnessUp (light :up 5))
(key [] :XF86MonBrightnessDown (light :down 5)))
(each [_key dir (pairs {:h :left :j :down :k :up :l :right})]
(register
(key [:mod] _key (lambda [] (awful.client.focus.bydirection dir)))
(key [:mod :shift] _key (lambda [] (awful.client.swap.bydirection dir)))))
(for [i 1 9]
(let [ksym (.. "#" (+ i 9))]
(register
(key [:mod] ksym (with-focused-tag i (lambda [t] (: t :view_only))))
(key [:mod :ctrl] ksym (with-focused-tag i (lambda [t] (awful.tag.viewtoggle t))))
(key [:mod :shift] ksym (apply-focus i :move_to_tag))
(key [:mod :ctrl :shift] ksym (apply-focus i :toggle_tag)))))
keys
;;; conf/keys.fnl ends here