]>
git.madduck.net Git - etc/awesome.git/commitdiff
madduck's git repository
Every one of the projects in this repository is available at the canonical
URL git://git.madduck.net/madduck/pub/<projectpath> — see
each project's metadata for the exact URL.
All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@ git. madduck. net .
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
SSH access, as well as push access can be individually
arranged .
If you use my repositories frequently, consider adding the following
snippet to ~/.gitconfig and using the third clone URL listed for each
project:
[url "git://git.madduck.net/madduck/"]
insteadOf = madduck:
summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (parent:
301faf5 )
local rawget = rawget
local table = { sort = table.sort }
local rawget = rawget
local table = { sort = table.sort }
+local wibox = require("wibox")
+
-- Lain helper functions for internal use
-- lain.helpers
local helpers = {}
-- Lain helper functions for internal use
-- lain.helpers
local helpers = {}
---{{{ Iterate over table of records sorted by keys
+-- {{{ Misc
+
+-- iterate over table of records sorted by keys
function helpers.spairs(t)
-- collect the keys
local keys = {}
function helpers.spairs(t)
-- collect the keys
local keys = {}
+-- create a lain textbox widget
+function helpers.make_widget_textbox()
+ local w = wibox.widget.textbox('')
+ local t = wibox.widget.base.make_widget(w)
+ t.widget = w
+ return t
+end
+
+-- }}}
-package.loaded.lain = nil
-
local lain =
{
layout = require("lain.layout"),
local lain =
{
layout = require("lain.layout"),
-- {{{ Dynamic tagging
--
-- Add a new tag
-- {{{ Dynamic tagging
--
-- Add a new tag
-function util.add_tag(mypromptbox)
- awful.prompt.run({prompt="New tag name: "}, mypromptbox[mouse.screen].widget,
- function(text)
- if text:len() > 0 then
- props = { selected = true }
- tag = awful.tag.add(new_name, props)
- tag.name = text
- tag:emit_signal("property::name")
+function util.add_tag()
+ awful.prompt.run {
+ prompt = "New tag name: ",
+ textbox = awful.screen.focused().mypromptbox.widget,
+ exe_callback = function(name)
+ if not name or #name == 0 then return end
+ awful.tag.add(name, { screen = awful.screen.focused() }):view_only()
end
-- Rename current tag
end
-- Rename current tag
--- @author: minism
-function util.rename_tag(mypromptbox)
- local tag = awful.tag.selected(mouse.screen)
- awful.prompt.run({prompt="Rename tag: "}, mypromptbox[mouse.screen].widget,
- function(text)
- if text:len() > 0 then
- tag.name = text
- tag:emit_signal("property::name")
+function util.rename_tag()
+ awful.prompt.run {
+ prompt = "Rename tag: ",
+ textbox = awful.screen.focused().mypromptbox.widget,
+ exe_callback = function(new_name)
+ if not new_name or #new_name == 0 then return end
+ local t = awful.screen.focused().selected_tag
+ if t then
+ t.name = new_name
+ end
--- Remove current tag (if empty)
-- Any rule set on the tag shall be broken
-- Any rule set on the tag shall be broken
-function util.remov e_tag()
- local tag = awful.tag.selected(mouse.screen)
- local prevtag = awful.tag.gettags(mouse.screen)[awful.tag.getidx(tag) - 1]
- awful.tag.delete(tag, prevtag )
+function util.delet e_tag()
+ local t = awful.screen.focused().selected_tag
+ if not t then return end
+ t:delete( )
-- }}}
-- On the fly useless gaps change
-- }}}
-- On the fly useless gaps change
mouse = mouse,
screen = screen,
timer = timer }
mouse = mouse,
screen = screen,
timer = timer }
+local math = { floor = math.floor }
local string = string
local pairs = pairs
local string = string
local pairs = pairs
-- Resize
awful.client.floating.set(client, true)
-- Resize
awful.client.floating.set(client, true)
- client.border_width = self.border
+ -- client.border_width = self.border
client.size_hints_honor = false
if self.notexist then
client:geometry(self.geometry)
client.size_hints_honor = false
if self.notexist then
client:geometry(self.geometry)
-- Compute size
local geom = capi.screen[conf.screen].workarea
-- Compute size
local geom = capi.screen[conf.screen].workarea
- if width <= 1 then width = geom.width * width end
- if height <= 1 then height = geom.height * height end
+ if width <= 1 then width = math.floor(geom.width * width) end
+ if height <= 1 then height = math.floor(geom.height * height) end
local x, y
if horiz == "left" then x = geom.x
elseif horiz == "right" then x = geom.width + geom.x - width
local x, y
if horiz == "left" then x = geom.x
elseif horiz == "right" then x = geom.width + geom.x - width
local awful = require("awful")
local beautiful = require("beautiful")
local naughty = require("naughty")
local awful = require("awful")
local beautiful = require("beautiful")
local naughty = require("naughty")
+local wibox = require("wibox")
local math = { modf = math.modf }
local mouse = mouse
local math = { modf = math.modf }
local mouse = mouse
alsabar.notifications = args.notifications or alsabar.notifications
alsabar.followmouse = args.followmouse or false
alsabar.notifications = args.notifications or alsabar.notifications
alsabar.followmouse = args.followmouse or false
- alsabar.bar = awful .widget.progressbar()
+ alsabar.bar = wibox .widget.progressbar()
alsabar.bar:set_background_color(alsabar.colors.background)
alsabar.bar:set_color(alsabar.colors.unmute)
alsabar.bar:set_background_color(alsabar.colors.background)
alsabar.bar:set_color(alsabar.colors.unmute)
-- MPD infos
-- lain.widgets.mpd
-- MPD infos
-- lain.widgets.mpd
+local mpd = helpers.make_widget_textbox()
local function worker(args)
local args = args or {}
local function worker(args)
local args = args or {}
local mpdh = "telnet://" .. host .. ":" .. port
local echo = echo_cmd .. " 'password " .. password .. "\nstatus\ncurrentsong\nclose'"
local mpdh = "telnet://" .. host .. ":" .. port
local echo = echo_cmd .. " 'password " .. password .. "\nstatus\ncurrentsong\nclose'"
- mpd.widget = wibox.widget.textbox('')
-
mpd_notification_preset = {
title = "Now playing",
timeout = 6
mpd_notification_preset = {
title = "Now playing",
timeout = 6
helpers.newtimer("mpd", timeout, mpd.update)
helpers.newtimer("mpd", timeout, mpd.update)
- return setmetatable(mpd, { __index = mpd.widget })
end
return setmetatable(mpd, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(mpd, { __call = function(_, ...) return worker(...) end })
-- lain.widgets.net
local function worker(args)
-- lain.widgets.net
local function worker(args)
- local net = { last_t = 0, last_r = 0, devices = {} }
+ local net = helpers.make_widget_textbox()
+ net.last_t = 0
+ net.last_r = 0
+ net.devices = {}
function net.get_first_device()
local ws = helpers.read_pipe("ip link show | cut -d' ' -f2,9")
function net.get_first_device()
local ws = helpers.read_pipe("ip link show | cut -d' ' -f2,9")
local settings = args.settings or function() end
local iface = args.iface or net.get_first_device()
local settings = args.settings or function() end
local iface = args.iface or net.get_first_device()
- net.widget = wibox.widget.textbox('')
-
-- Compatibility with old API where iface was a string corresponding to 1 interface
if type(iface) == "string" then
iftable = {iface}
-- Compatibility with old API where iface was a string corresponding to 1 interface
if type(iface) == "string" then
iftable = {iface}
helpers.newtimer(iface, timeout, update)
helpers.newtimer(iface, timeout, update)
- return setmetatable(net, { __index = net.widget })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
local awful = require("awful")
local beautiful = require("beautiful")
local naughty = require("naughty")
local awful = require("awful")
local beautiful = require("beautiful")
local naughty = require("naughty")
+local wibox = require("wibox")
local math = { modf = math.modf }
local mouse = mouse
local math = { modf = math.modf }
local mouse = mouse
pulsebar.step = args.step or pulsebar.step
pulsebar.followmouse = args.followmouse or false
pulsebar.step = args.step or pulsebar.step
pulsebar.followmouse = args.followmouse or false
- pulsebar.bar = awful .widget.progressbar()
+ pulsebar.bar = wibox .widget.progressbar()
pulsebar.bar:set_background_color(pulsebar.colors.background)
pulsebar.bar:set_color(pulsebar.colors.unmute)
pulsebar.bar:set_background_color(pulsebar.colors.background)
pulsebar.bar:set_color(pulsebar.colors.unmute)
-Subproject commit 42fd0d64ad66a66a062eb422fb5f26e63fd5de58
+Subproject commit f6270edc9e9d8ba83971fac3dbaca301c4792f34