75 lines
1.9 KiB
Plaintext
75 lines
1.9 KiB
Plaintext
|
;;; decorate.fnl --- Client decorations
|
||
|
|
||
|
;;; Commentary:
|
||
|
;; Comments
|
||
|
|
||
|
;;; Code:
|
||
|
|
||
|
(local awful (require :awful))
|
||
|
(local beautiful (require :beautiful))
|
||
|
(local gears (require :gears))
|
||
|
(local wibox (require :wibox))
|
||
|
|
||
|
(local std (require :lib.std))
|
||
|
|
||
|
;; TODO Properly abstract these into a library
|
||
|
|
||
|
(local fun (require :lib.fun))
|
||
|
(local modifiers
|
||
|
{:mod "Mod4"
|
||
|
:alt "Mod1"
|
||
|
:super "Mod4"
|
||
|
:shift "Shift"
|
||
|
:ctrl "Control"})
|
||
|
|
||
|
(fn map-mods [mods]
|
||
|
(->> mods
|
||
|
(fun.map (partial . modifiers))
|
||
|
(fun.totable)))
|
||
|
|
||
|
(fn button [mods bc fun]
|
||
|
(awful.button (map-mods mods) bc fun))
|
||
|
|
||
|
;;;
|
||
|
;; Functions
|
||
|
|
||
|
(fn mouse-button [c bc cmd]
|
||
|
(button [] bc (lambda []
|
||
|
(: c :emit_signal
|
||
|
:request::activate :titlebar {:raise true})
|
||
|
((. awful.mouse.client cmd) c))))
|
||
|
|
||
|
(fn make-titlebar [c side -size]
|
||
|
(let [size (or -size beautiful.titlebar_size 10)]
|
||
|
(awful.titlebar c {:size size :position side})))
|
||
|
|
||
|
(fn setup-empty-titlebar [bar buttons]
|
||
|
;; Placeholder layouts
|
||
|
(: bar :setup
|
||
|
{1 {:layout wibox.layout.fixed.vertical}
|
||
|
2 {:buttons buttons
|
||
|
:layout wibox.layout.flex.vertical}
|
||
|
3 {:layout (wibox.layout.fixed.vertical)}
|
||
|
:layout wibox.layout.align.vertical}))
|
||
|
|
||
|
(fn titlebar-hook [c]
|
||
|
(let [buttons (gears.table.join
|
||
|
(mouse-button c 1 :move)
|
||
|
(mouse-button c 3 :resize))
|
||
|
mainbar (make-titlebar c beautiful.titlebar_position)]
|
||
|
(setup-empty-titlebar mainbar buttons)
|
||
|
|
||
|
(when (and (not (std.zero? beautiful.titlebar_border_width))
|
||
|
beautiful.use_titlebars_for_borders)
|
||
|
(let [size beautiful.titlebar_border_width]
|
||
|
(each [_ side (ipairs [:top :right :bottom])]
|
||
|
(setup-empty-titlebar (make-titlebar c side size) buttons))))))
|
||
|
|
||
|
;;;
|
||
|
;; Processing
|
||
|
|
||
|
(_G.client.connect_signal :request::titlebars titlebar-hook)
|
||
|
|
||
|
{}
|
||
|
;;; decorate.fnl ends here
|