Compare commits

...

18 Commits

Author SHA1 Message Date
3a51bab1c8 fix: reduce size of battery icon widget 2019-01-15 21:34:21 +11:00
41c431d40f feat: fall back to beautiful.font for textclock 2019-01-15 21:34:04 +11:00
80cc22804b feat(sidebar): add task list 2019-01-15 21:34:01 +11:00
d7186976a8 feat(autostart): use some async processes 2019-01-15 21:33:14 +11:00
8f33221d1d feat: remove handling of audio keys
Leaving for pa-applet
2019-01-15 21:32:40 +11:00
1cb2eb5940 feat: set awful.util.terminal correctly 2019-01-15 21:32:06 +11:00
0ce7fe3cb4 fix: use xfce4-notifyd for dbus notifications 2019-01-15 21:31:45 +11:00
5b4584f17a fix: make systray behave as it should 2019-01-15 17:24:06 +11:00
e6fd7b5613 feat(autostart): implement in awesome itself 2019-01-15 17:21:27 +11:00
d377a56780 refactor(sidebar): split battery and pulse widgets out 2019-01-15 17:07:30 +11:00
0bde007468 feat(sidebar): add volume widget 2019-01-15 17:01:14 +11:00
04f619499d feat(sidebar): add battery icon 2019-01-15 16:34:04 +11:00
867f3434f3 feat(std): add string splitter 2019-01-15 15:57:44 +11:00
818b38bef7 feat: vendor in lain 2019-01-15 15:57:39 +11:00
7b21018a59 feat: add tint2ish tag list and clock to sidebar 2019-01-15 15:15:39 +11:00
54230c55dd feat: add init.fnl to search paths 2019-01-15 13:42:07 +11:00
da0a6ad0b9 feat: downgrade to stable release 2019-01-15 12:00:18 +11:00
5b93b8f766 refactor(sidebar): split tag/task list out 2019-01-15 11:37:47 +11:00
29 changed files with 594 additions and 95 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "lain"]
path = lain
url = gh:lcpz/lain

16
cfg.fnl
View File

@ -2,13 +2,20 @@
(local awful (require :awful)) (local awful (require :awful))
(require :awful.autofocus) (require :awful.autofocus)
(local naughty (require :naughty))
(local beautiful (require :beautiful)) (local beautiful (require :beautiful))
(beautiful.init (require :conf.theme)) ;; HACK Use xfce4-notifyd for dbus integration.
;; Purely for pa-applet until a better solution is found.
(local _dbus dbus)
(set _G.dbus nil)
(local naughty (require :naughty))
(set _G.dbus _dbus)
(beautiful.init (require :theme))
(require :module.decorate) (require :module.decorate)
(require :module.sidebar) (require :module.sidebar)
(require :module.autostart)
(require :conf.client) (require :conf.client)
(require :conf.tags) (require :conf.tags)
@ -18,6 +25,8 @@
(set naughty.config.defaults.border_width beautiful.notification_border_width) (set naughty.config.defaults.border_width beautiful.notification_border_width)
(set naughty.config.defaults.icon_size beautiful.notification_icon_size) (set naughty.config.defaults.icon_size beautiful.notification_icon_size)
(tset awful.util :terminal (. (require :conf.apps) :terminal))
;;; ;;;
;; Post-config -- wiring it all up ;; Post-config -- wiring it all up
@ -36,7 +45,4 @@
:unfocus (lambda [c] (set c.border_color beautiful.border_normal))} :unfocus (lambda [c] (set c.border_color beautiful.border_normal))}
(fun.each (fn [event callback] (client.connect_signal event callback)))) (fun.each (fn [event callback] (client.connect_signal event callback))))
(awful.spawn.with_shell "~/.config/awesome/autostart")
;; Empty return
{} {}

View File

@ -96,9 +96,9 @@
(key [] :XF86AudioPlay (playerctl :play-pause)) (key [] :XF86AudioPlay (playerctl :play-pause))
(key [] :XF86AudioNext (playerctl :next)) (key [] :XF86AudioNext (playerctl :next))
(key [] :XF86AudioPrev (playerctl :previous)) (key [] :XF86AudioPrev (playerctl :previous))
(key [] :XF86AudioRaiseVolume (amixer "5%+")) ;; (key [] :XF86AudioRaiseVolume (amixer "5%+"))
(key [] :XF86AudioLowerVolume (amixer "5%-")) ;; (key [] :XF86AudioLowerVolume (amixer "5%-"))
(key [] :XF86AudioMute (amixer "toggle")) ;; (key [] :XF86AudioMute (amixer "toggle"))
(key [] :XF86MonBrightnessUp (light :up 5)) (key [] :XF86MonBrightnessUp (light :up 5))
(key [] :XF86MonBrightnessDown (light :down 5))) (key [] :XF86MonBrightnessDown (light :down 5)))

View File

@ -3,6 +3,7 @@
;;; Code: ;;; Code:
(local awful (require :awful)) (local awful (require :awful))
(local beautiful (require :beautiful))
;;; ;;;
;; Configuration ;; Configuration
@ -12,10 +13,21 @@
(set awful.layout.layouts layouts) (set awful.layout.layouts layouts)
(awful.screen.connect_for_each_screen ;; TODO Rasterize?
(local tags [:firefox.png :code.png :code.svg])
(let [icon-path (.. (os.getenv "HOME") "/.config/awesome/theme/icons/tag/")]
(awful.screen.connect_for_each_screen
(lambda [s] (lambda [s]
(awful.tag ["1", "2", "3", "4", "5", "6", "7", "8", "9"] (each [n tag (ipairs tags)]
s (. layouts 1)))) (awful.tag.add
n {:icon (.. icon-path tag)
:icon_only true
:layout (. layouts 1)
:gap_single_client false
:gap beautiful.useless_gap
:screen s
:selected (= n 1)})))))
{} {}
;;; conf/tags.fnl ends here ;;; conf/tags.fnl ends here

View File

@ -1,35 +0,0 @@
;; Have to use underscores for `beautiful' compat.
;; Non-beautiful variables are commented with an asterisk.
{
:font "Sarasa Mono J"
:variable_font "Sarasa UI J"
:sidebar_position :left ;; *
:sidebar_width 36 ;; *
:sidebar_bg "#1a1e24" ;; *
:sidebar_subbox "#252b33" ;; *
:bg_focus "#252b33"
:bg_normal "#1a1e24"
:fg_focus "#cfcfcf"
:fg_normal "#cfcfcf"
:useless_gap 0
:border_width 0
:border_focus "#5bb3b4"
:border_normal "#1a1e24"
:use_titlebars_for_borders nil ;; *
:titlebar_border_width 1 ;; *
:titlebar_position :left ;; *
:titlebar_size 15 ;; *
:titlebar_bg_focus "#926b3e"
:titlebar_bg_normal "#252b33"
:titlebar_fg_focus "#1a1e24"
:titlebar_fg_normal "#cfcfcf"
:icon_theme "Vertex Maia"
:notification_icon_size 48
:notification_border_width 0
:notification_bg "#252b33"
}

1
lain Submodule

@ -0,0 +1 @@
Subproject commit 93b31ef0e9851f593984657c0215ba2ed6488b2a

View File

@ -13,5 +13,20 @@
(fn std.zero? [n] (fn std.zero? [n]
(= 0 n)) (= 0 n))
(fn std.fn? [f]
(= (type f) :function))
(fn std.s-empty? [s]
(or (= nil s)
(= "" s)))
(fn std.s-split [s sep]
(var t {})
(let [sep (or sep "%s")
re (.. "([^" sep "]+)")]
(each [str (string.gmatch s re)]
(table.insert t str))
t))
std std
;;; std.fnl ends here ;;; std.fnl ends here

52
module/autostart.fnl Normal file
View File

@ -0,0 +1,52 @@
;;; module/auto-start.fnl --- Auto-start utilities
;;; Commentary:
;; Largely copied from
;; https://github.com/PapyElGringo/material-awesome/blob/master/module/auto-start.lua
;;; Code:
(local awful (require :awful))
(local beautiful (require :beautiful))
(local naughty (require :naughty))
(local spawn awful.spawn.with_shell)
(local async awful.spawn.easy_async_with_shell)
;;;
;; Functions
(fn cb [prog]
(lambda [stdout stderr exitreason exitcode]
(when (not (= 0 exitcode))
(naughty.notify
{:title (.. "async startup handler: " prog)
:text stderr}))))
(fn run-once [cmds]
(each [_ cmd (ipairs cmds)]
(let [first-space (: cmd :find " ")
findme (if first-space
(: cmd :sub 0 (- first-space 1))
cmd)]
(spawn
(string.format "pgrep -u $USER -x %s >/dev/null || (%s)" findme cmd)))))
;; Keyboard
(async "tpset \"Natural Scrolling\" 1" (cb "tpset"))
(async "tpset \"Tapping\" 1" (cb "tpset"))
(spawn "setxkbmap -option caps:ctrl_modifier")
(async (.. "feh --bg-fill " beautiful.wallpaper) (cb "feh"))
(run-once
["nm-applet" ;; WiFi
"pa-applet" ;; Sound manager
"blueman-applet" ;; Bluetooth
"compton -b" ;; Compositor
"libinput-gestures"
"fcitx-autostart" ;; Keyboard
])
{}
;;; module/auto-start.fnl ends here

View File

@ -4,71 +4,71 @@
(local awful (require :awful)) (local awful (require :awful))
(local beautiful (require :beautiful)) (local beautiful (require :beautiful))
(local lain (require :lain))
(local wibox (require :wibox)) (local wibox (require :wibox))
(local sb-clock (wibox.widget.textclock "%H\n%M")) (local std (require :lib.std))
(local sb-systray (doto (wibox.widget.systray)
(: :set_base_size 24)))
(local fill-width (doto (wibox.layout.fixed.horizontal)
(: :fill_space true)
(: :set_spacing 10)))
(local bounding (wibox.container.margin (local tag-list (require :widget.tag-list))
(wibox.container.place (local task-list (require :widget.task-list))
(wibox.container.margin (local textclock (require :widget.textclock))
nil
10 10 10 10 beautiful.sidebar_subbox)) (local markup lain.util.markup)
1 1 1 1 beautiful.sidebar_bg))
;;; ;;;
;; Functions ;; Functions
(fn draw-sidebar [s] (fn border [t margin]
(set s.sb-tag (awful.widget.taglist (let [side (or margin 2)
{:screen s end (+ side 1)]
:filter awful.widget.taglist.filter.selected {1 t
:style {:font (.. beautiful.font " Bold 10")} :bottom end
;; :widget_template :left side
;; {1 :right side
;; {:id "index_role" :top end
;; :widget wibox.widget.textbox} :widget wibox.container.margin} ))
;; :widget wibox.container.margin
;; :margins 5
;; :create_callback
;; (lambda [self, c3, index, objects])}
:layout wibox.layout.fixed.vertical
}
))
(set s.sb-tasks (awful.widget.tasklist
{:screen s
:filter awful.widget.tasklist.filter.currenttags
:style {:disable_task_name true}
}))
(fn center [t]
{1 t
:align "center"
:widget wibox.container.place})
(local clock (textclock "%H\n%M"))
(local systray (doto (wibox.widget.systray)
(: :set_base_size 24)
(: :set_horizontal false)))
(local battery (require :widget.bat))
(local pulse (require :widget.pulse))
(fn draw-sidebar [s]
(set s.sb (awful.wibar {:position beautiful.sidebar_position (set s.sb (awful.wibar {:position beautiful.sidebar_position
:width beautiful.sidebar_width :width beautiful.sidebar_width
:screen s})) :screen s}))
(: s.sb :setup (: s.sb :setup
{:layout wibox.layout.align.vertical {:layout wibox.layout.align.vertical
1 {:layout wibox.layout.fixed.vertical 1 {1 (border (tag-list s))
1 {1 s.sb-tag :layout wibox.layout.fixed.vertical}
:halign "center" 2 {1 (border (center (task-list s)) 4)
:layout (wibox.container.margin nil 10 10 10 10)} :layout wibox.layout.flex.vertical}
2 s.sb-tasks} 3 {1 (center systray)
2 {:layout wibox.layout.fixed.vertical} 2 (center battery.widget)
3 {:layout wibox.layout.fixed.vertical 3 {1 (border
1 sb-systray {1 {1 (center clock)
2 {1 sb-clock :top 2
:valign "center" :bottom 2
:halign "center" :widget wibox.container.margin}
:layout bounding}}})) :widget wibox.container.background
:bg beautiful.sidebar_bg_info})
:layout wibox.layout.fixed.vertical}
:layout wibox.layout.fixed.vertical}}))
;;; ;;;
;; Configuration ;; Configuration
;; (awful.screen.connect_for_each_screen (awful.screen.connect_for_each_screen
;; draw-sidebar) draw-sidebar)
{} {}
;;; module/sidebar.fnl ends here ;;; module/sidebar.fnl ends here

2
rc.lua
View File

@ -1,4 +1,4 @@
local fennel = require("lib.fennel") local fennel = require("lib.fennel")
fennel.path = fennel.path .. ";.config/awesome/?.fnl" fennel.path = fennel.path .. ";.config/awesome/?.fnl;.config/awesome/?/init.fnl"
table.insert(package.loaders or package.searchers, fennel.searcher) table.insert(package.loaders or package.searchers, fennel.searcher)
require("cfg") -- .config/awesome/cfg.fnl require("cfg") -- .config/awesome/cfg.fnl

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

BIN
theme/icons/tag/code.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

1
theme/icons/tag/code.svg Normal file
View File

@ -0,0 +1 @@
<svg aria-hidden="true" data-prefix="fas" data-icon="code" class="svg-inline--fa fa-code fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z"></path></svg>

After

Width:  |  Height:  |  Size: 750 B

BIN
theme/icons/tag/firefox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1 @@
<svg aria-hidden="true" data-prefix="fab" data-icon="firefox" class="svg-inline--fa fa-firefox fa-w-15" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 480 512"><path fill="currentColor" d="M478.1 235.3c-.7-4.5-1.4-7.1-1.4-7.1s-1.8 2-4.7 5.9c-.9-10.7-2.8-21.2-5.8-31.6-3.7-12.9-8.5-25.4-14.5-37.4-3.8-8-8.2-15.6-13.3-22.8-1.8-2.7-3.7-5.4-5.6-7.9-8.8-14.4-19-23.3-30.7-40-7.6-12.8-12.9-26.9-15.4-41.6-3.2 8.9-5.7 18-7.4 27.3-12.1-12.2-22.5-20.8-28.9-26.7C319.4 24.2 323 9.1 323 9.1S264.7 74.2 289.9 142c8.7 23 23.8 43.1 43.4 57.9 24.4 20.2 50.8 36 64.7 76.6-11.2-21.3-28.1-39.2-48.8-51.5 6.2 14.7 9.4 30.6 9.3 46.5 0 61-49.6 110.5-110.6 110.4-8.3 0-16.5-.9-24.5-2.8-9.5-1.8-18.7-4.9-27.4-9.3-12.9-7.8-24-18.1-32.8-30.3l-.2-.3 2 .7c4.6 1.6 9.2 2.8 14 3.7 18.7 4 38.3 1.7 55.6-6.6 17.5-9.7 28-16.9 36.6-14h.2c8.4 2.7 15-5.5 9-14-10.4-13.4-27.4-20-44.2-17-17.5 2.5-33.5 15-56.4 2.9-1.5-.8-2.9-1.6-4.3-2.5-1.6-.9 4.9 1.3 3.4.3-5-2.5-9.8-5.4-14.4-8.6-.3-.3 3.5 1.1 3.1.8-5.9-4-11-9.2-15-15.2-4.1-7.4-4.5-16.4-1-24.1 2.1-3.8 5.4-6.9 9.3-8.7 3 1.5 4.8 2.6 4.8 2.6s-1.3-2.5-2.1-3.8c.3-.1.5 0 .8-.2 2.6 1.1 8.3 4 11.4 5.8 2.1 1.1 3.8 2.7 5.2 4.7 0 0 1-.5.3-2.7-1.1-2.7-2.9-5-5.4-6.6h.2c2.3 1.2 4.5 2.6 6.6 4.1 1.9-4.4 2.8-9.2 2.6-14 .2-2.6-.2-5.3-1.1-7.8-.8-1.6.5-2.2 1.9-.5-.2-1.3-.7-2.5-1.2-3.7v-.1s.8-1.1 1.2-1.5c1-1 2.1-1.9 3.4-2.7 7.2-4.5 14.8-8.4 22.7-11.6 6.4-2.8 11.7-4.9 12.8-5.6 1.6-1 3.1-2.2 4.5-3.5 5.3-4.5 9-10.8 10.2-17.7.1-.9.2-1.8.3-2.8v-1.5c-.9-3.5-6.9-6.1-38.4-9.1-11.1-1.8-20-10.1-22.5-21.1v.1c-.4 1.1-.9 2.3-1.3 3.5.4-1.2.8-2.3 1.3-3.5v-.2c6-15.7 16.8-29.1 30.8-38.3.8-.7-3.2.2-2.4-.5 2.7-1.3 5.4-2.5 8.2-3.5 1.4-.6-6-3.4-12.6-2.7-4 .2-8 1.2-11.7 2.8 1.6-1.3 6.2-3.1 5.1-3.1-8.4 1.6-16.5 4.7-23.9 9 0-.8.1-1.5.5-2.2-5.9 2.5-11 6.5-15 11.5.1-.9.2-1.8.2-2.7-2.7 2-5.2 4.3-7.3 6.9l-.1.1c-17.4-6.7-36.3-8.3-54.6-4.7l-.2-.1h.2c-3.8-3.1-7.1-6.7-9.7-10.9l-.2.1-.4-.2c-1.2-1.8-2.4-3.8-3.7-6-.9-1.6-1.8-3.4-2.7-5.2 0-.1-.1-.2-.2-.2-.4 0-.6 1.7-.9 1.3v-.1c-3.2-8.3-4.7-17.2-4.4-26.2l-.2.1c-5.1 3.5-9 8.6-11.1 14.5-.9 2.1-1.6 3.3-2.2 4.5v-.5c.1-1.1.6-3.3.5-3.1-.1.2-.2.3-.3.4-1.5 1.7-2.9 3.7-3.9 5.8-.9 1.9-1.7 3.9-2.3 5.9-.1.3 0-.3 0-1s.1-2 0-1.7l-.3.7c-6.7 14.9-10.9 30.8-12.4 47.1-.4 2.8-.6 5.6-.5 8.3v.2c-4.8 5.2-9 11-12.7 17.1-12.1 20.4-21.1 42.5-26.8 65.6 4-8.8 8.8-17.2 14.3-25.1C5.5 228.5 0 257.4 0 286.6c1.8-8.6 4.2-17 7-25.3-1.7 34.5 4.9 68.9 19.4 100.3 19.4 43.5 51.6 80 92.3 104.7 16.6 11.2 34.7 19.9 53.8 25.8 2.5.9 5.1 1.8 7.7 2.7-.8-.3-1.6-.7-2.4-1 22.6 6.8 46.2 10.3 69.8 10.3 83.7 0 111.3-31.9 113.8-35 4.1-3.7 7.5-8.2 9.9-13.3 1.6-.7 3.2-1.4 4.9-2.1l1-.5 1.9-.9c12.6-5.9 24.5-13.4 35.3-22.1 16.3-11.7 27.9-28.7 32.9-48.1 3-7.1 3.1-15 .4-22.2.9-1.4 1.7-2.8 2.7-4.3 18-28.9 28.2-61.9 29.6-95.9v-2.8c0-7.3-.6-14.5-1.9-21.6z"></path></svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

42
theme/init.fnl Normal file
View File

@ -0,0 +1,42 @@
;; Have to use underscores for `beautiful' compat.
;; Non-beautiful variables are commented with an asterisk.
(let [theme-dir (.. (os.getenv "HOME") "/.config/awesome/theme")
icon-dir (.. theme-dir "/icons/")]
{
:font "Sarasa Mono J"
:variable_font "Sarasa UI J"
:textclock_font "Sarasa UI J"
:sidebar_position :left ;; *
:sidebar_width 36 ;; *
:sidebar_bg_info "#252b33" ;; *
:bg_focus "#252b33"
:bg_normal "#1a1e24"
:fg_focus "#cfcfcf"
:fg_normal "#cfcfcf"
:useless_gap 0
:border_width 0
:border_focus "#5bb3b4"
:border_normal "#1a1e24"
:use_titlebars_for_borders nil ;; *
:titlebar_border_width 1 ;; *
:titlebar_position :left ;; *
:titlebar_size 15 ;; *
:titlebar_bg_focus "#926b3e"
:titlebar_bg_normal "#252b33"
:titlebar_fg_focus "#1a1e24"
:titlebar_fg_normal "#cfcfcf"
:icon_theme "Vertex Maia"
:notification_icon_size 48
:notification_border_width 0
:notification_bg "#252b33"
:taglist_bg_empty (.. "png:" icon-dir "tag-list/unselected.png")
:taglist_bg_focus (.. "png:" icon-dir "tag-list/selected.png")
:taglist_bg_occupied (.. "png:" icon-dir "tag-list/occupied.png")
:taglist_bg_urgent (.. "png:" icon-dir "tag-list/urgent.png")
})

51
widget/bat.fnl Normal file
View File

@ -0,0 +1,51 @@
;;; widget/bat.fnl --- Battery widget
;;; Code:
(local std (require :lib.std))
(local lain (require :lain))
(local markup lain.util.markup)
(fn bat-hm []
(let [[h m] (std.s-split _G.bat_now.time ":")
baticon "\u{f241}"]
(: _G.widget :set_markup
(.. baticon "\n" h "\n" m))))
(fn bat-icon []
;; FA
;; (let [full "\u{f240}"
;; x75 "\u{f241}"
;; x50 "\u{f242}"
;; x25 "\u{f243}"
;; empty "\u{f244}"
(let [full "\u{e02b}"
x75 "\u{e02c}"
x50 "\u{e02d}"
x25 "\u{e02e}"
empty "\u{e136}"
charging "\u{e02a}"
status _G.bat_now.status
level _G.bat_now.perc
icon (if (= status "Full") full
(= status "Charging") charging
(> level 75) x75
(> level 50) x50
(> level 25) x25
empty)]
(: _G.widget :set_markup (markup.font "Typicons 24" icon))))
(fn bat-markup []
(bat-icon))
;; TODO Plug/unplug notifications
(local battery
(lain.widget.bat
{:battery "BAT1"
:ac "ACAD"
:notify "on"
:n_perc [10 20]
:settings bat-markup}))
battery
;;; widget/bat.fnl ends here

View File

@ -0,0 +1,52 @@
;;; widget/clickable-container.fnl --- Clickable container
;;; Commentary:
;; From https://github.com/PapyElGringo/material-awesome/blob/57116136a904560e8626b673370d2130b40dc62a/widgets/clickable-container.lua
;;; Code:
(local wibox (require :wibox))
(local naughty (require :naughty))
(local awful (require :awful))
;;;
;; Functions
(fn build [widget]
(let [container (wibox.container.background widget)]
(var old-cursor {})
(var old-wibox {})
(: container :connect_signal
:mouse::enter
(lambda []
(let [cw _G.mouse.current_wibox]
(tset container :bg "#ffffff11")
;; Hm, no idea how to get the wibox from this signal's arguments...
(when cw
(set old-cursor cw.cursor)
(set old-wibox cw)
(tset cw :cursor :hand1)))))
(: container :connect_signal
:mouse::leave
(lambda []
(tset container :bg "#ffffff00")
(when old-wibox
(tset old-wibox :cursor old-cursor)
(set old-wibox nil))))
(: container :connect_signal
:button::press
(lambda []
(tset container :bg "#ffffff22")))
(: container :connect_signal
:button::release
(lambda []
(tset container :bg "#ffffff11")))
container))
build
;;; widget/clickable-container.fnl ends here

80
widget/list_update.lua Normal file
View File

@ -0,0 +1,80 @@
local common = require("awful.widget.common")
local dpi = require("beautiful").xresources.apply_dpi
local wibox = require("wibox")
local clickable_container = require("widget.clickable-container")
function list_update(w, buttons, label, data, objects)
-- update the widgets, creating them if needed
w:reset()
for i, o in ipairs(objects) do
local cache = data[o]
local ib, tb, bgb, tbm, ibm, l
if cache then
ib = cache.ib
tb = cache.tb
bgb = cache.bgb
tbm = cache.tbm
ibm = cache.ibm
else
ib = wibox.widget.imagebox()
tb = wibox.widget.textbox()
bgb = wibox.container.background()
tbm = wibox.container.margin(tb, dpi(4), dpi(4))
ibm = wibox.container.margin(ib, dpi(10), dpi(8), dpi(8), dpi(8))
-- ibm = wibox.container.margin(ib, dpi(4))
l = wibox.layout.fixed.horizontal()
bg_clickable = clickable_container()
-- All of this is added in a fixed widget
l:fill_space(true)
l:add(ibm)
-- l:add(tbm)
bg_clickable:set_widget(l)
-- And all of this gets a background
-- bgb:set_widget(l)
bgb:set_widget(bg_clickable)
bgb:buttons(common.create_buttons(buttons, o))
data[o] = {
ib = ib,
tb = tb,
bgb = bgb,
tbm = tbm,
ibm = ibm,
}
end
local text, bg, bg_image, icon, args = label(o, tb)
args = args or {}
-- The text might be invalid, so use pcall.
if text == nil or text == "" then
tbm:set_margins(0)
else
if not tb:set_markup_silently(text) then
tb:set_markup("<i>&lt;Invalid text&gt;</i>")
end
end
bgb:set_bg(bg)
if type(bg_image) == "function" then
-- TODO: Why does this pass nil as an argument?
bg_image = bg_image(tb,o,nil,objects,i)
end
bgb:set_bgimage(bg_image)
if icon then
ib:set_image(icon)
else
ibm:set_margins(0)
end
bgb.shape = args.shape
bgb.shape_border_width = args.shape_border_width
bgb.shape_border_color = args.shape_border_color
w:add(bgb)
end
end
return list_update

45
widget/pulse.fnl Normal file
View File

@ -0,0 +1,45 @@
;;; widget/pulse.fnl --- Pulseaudio widget
;;; Code:
(local lain (require :lain))
(local markup lain.util.markup)
(fn pulse-icon []
(let [icon {:muted "\u{e133}"
:low "\u{e135}"
:med "\u{e132}"
:high "\u{e134}"}
muted (= _G.volume_now.muted "yes")
vol (tonumber _G.volume_now.left)
icon (if muted icon.muted
(> vol 35) icon.high
(> vol 5) icon.med
icon.low)]
(: _G.widget :set_markup (markup.font "Typicons 24" icon))))
(fn pulse-icon+text []
(let [icon {:muted "\u{e133}"
:low "\u{e135}"
:med "\u{e132}"
:high "\u{e134}"}
muted (= _G.volume_now.muted "yes")
vol (tonumber _G.volume_now.left)
icon (if muted icon.muted
(> vol 35) icon.high
(> vol 5) icon.med
icon.low)
s (if muted ""
(.. "\n" (tostring vol) "%"))]
(: _G.widget :set_markup
(.. (markup.font "Typicons 24" icon)
s))))
(fn pulse-markup []
(pulse-icon))
(local pulse (lain.widget.pulse
{:settings pulse-markup}))
pulse
;;; widget/pulse.fnl ends here

107
widget/tag-list.fnl Normal file
View File

@ -0,0 +1,107 @@
;;; widget/tag-list.fnl --- Pop-out tag list widget
;;; Code:
(local awful (require :awful))
(local beautiful (require :beautiful))
(local wibox (require :wibox))
(local common (require :awful.widget.common))
(local dpi (. (require :beautiful) :xresources :apply_dpi))
(local std (require :lib.std))
;;;
;; Functions
(fn update-tag-list [w buttons label data objects]
(: w :reset)
(each [i o (ipairs objects)]
(let [cache (. data o)]
(var ib nil)
(var tb nil)
(var bgb nil)
(var tbm nil)
(var ibm nil)
(var l nil)
(if cache
(do
(set ib cache.ib)
(set tb cache.tb)
(set bgb cache.bgb)
(set tbm cache.tbm)
(set ibm cache.ibm))
(do
(set ib (wibox.widget.imagebox))
(set tb (wibox.widget.textbox))
(set bgb (wibox.container.background))
(set tbm (wibox.container.margin tb (dpi 4) (dpi 4)))
;; (set ibm (wibox.container.margin ib (dpi 12) (dpi 12) (dpi 12) (dpi 12)))
(set ibm (wibox.container.margin ib (dpi 4)))
(set l (wibox.layout.fixed.horizontal))
;; All of this is added in a fixed widget
(doto l
(: :fill_space true)
(: :add ibm)
(: :add tbm))
;; And all of this gets a background
(: bgb :set_widget l)
(: bgb :buttons (common.create_buttons buttons o))
(tset data o {:ib ib :tb tb :bgb bgb :tbm tbm :ibm ibm})))
(let [[text bg bg-image icon args] (label o tb)]
;; The text might be invalid, so use pcall.
(if (std.s-empty? text)
(: tbm :set_margins 0)
(when (not (: tb :set_markup_silently text))
(: tb :set_markup "<i>&lt;Invalid text&gt;</i>")))
(: bgb :set_bg bg)
(: bgb :set_bgimage (if (std.fn? bg-image)
;; TODO: Why does this pass nil as an argument?
(bg-image tb o nil objects i)
bg-image))
(if icon
(: ib :set_image icon)
(: ibm :set_margins 0))
(let [args (or args {})]
(doto bgb
(tset :shape args.shape)
(tset :shape_border_width args.shape_border_width)
(tset :shape_border_color args.shape_border_color)))
(: w :add bgb)))))
(fn container []
(let [l (wibox.layout.fixed.vertical)]
;; Wishlist: let*
(local innerm (wibox.container.margin nil 10 10))
(local bg (wibox.container.background innerm "#faa"))
(local outerm (wibox.container.margin bg 4 4))
(: l :fill_space true)
(: l :add outerm)
l))
(fn tag-list [s]
(awful.widget.taglist
s
awful.widget.taglist.filter.all
{}
{:font (.. beautiful.font " Bold 10")
:spacing 2}
;; update-tag-list
(require :widget.list_update)
;; awful.widget.common.list_update
;; (container)
(wibox.layout.fixed.vertical)
))
tag-list
;;; widget/tag-list.fnl ends here

23
widget/task-list.fnl Normal file
View File

@ -0,0 +1,23 @@
;;; widget/task-list.fnl --- Vertical task list
;;; Code:
(local awful (require :awful))
(local wibox (require :wibox))
;;;
;; Functions
(fn task-list [s]
(awful.widget.tasklist
s
awful.widget.tasklist.filter.minimizedcurrenttags
{}
{:disable_task_name true}
awful.widget.common.list_update
(wibox.layout.fixed.vertical)
))
task-list
;;; widget/task-list.fnl ends here

43
widget/textclock.fnl Normal file
View File

@ -0,0 +1,43 @@
;;; widget/textclock.fnl --- Configurable text clock widget
;;; Commentary:
;; More modular than the standard library
;;; Code:
(local beautiful (require :beautiful))
(local gears (require :gears))
(local glib (. (require :lgi) :GLib))
(local wibox (require :wibox))
(local DateTime glib.DateTime)
(local TimeZone glib.TimeZone)
;;;
;; Functions
(fn calc-timeout [real-timeout]
(% (- real-timeout (os.time)) real-timeout))
(fn textclock [format timeout timezone font]
(let [format (or format " %a %b %d, %H:%M ")
timeout (or timeout 60)
timezone (or (and timezone (TimeZone.new timezone))
(TimeZone.new_local))
font (or font beautiful.textclock_font beautiful.font)
w (wibox.widget.textbox)]
(var t nil)
(tset w :font font)
(fn w._private.textclock_update_cb []
(: w :set_markup (: (DateTime.new_now timezone) :format format))
(tset t :timeout (calc-timeout timeout))
(: t :again)
true)
(set t (gears.timer.weak_start_new timeout w._private.textclock_update_cb))
(: t :emit_signal :timeout)
w))
textclock
;;; widget/textclock.fnl ends here