59 lines
1.6 KiB
Fennel
59 lines
1.6 KiB
Fennel
;;; decorate.fnl --- Client decorations
|
|
|
|
;;; Commentary:
|
|
;; Comments
|
|
|
|
;;; Code:
|
|
|
|
(local awful (require :awful))
|
|
(local beautiful (require :beautiful))
|
|
(local gears (require :gears))
|
|
(local wibox (require :wibox))
|
|
|
|
(local fun (require :lib.fun))
|
|
(local std (require :lib.std))
|
|
(local button (. (require :lib.keys) :button))
|
|
|
|
;;;
|
|
;; 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
|