net/mpd widget resize fix; #248

This commit is contained in:
copycat-killer 2017-01-03 12:21:50 +01:00
parent 301faf5370
commit cf2c442499
9 changed files with 54 additions and 42 deletions

View File

@ -16,6 +16,8 @@ local io = { open = io.open,
local rawget = rawget local rawget = rawget
local table = { sort = table.sort } local table = { sort = table.sort }
local wibox = require("wibox")
-- Lain helper functions for internal use -- Lain helper functions for internal use
-- lain.helpers -- lain.helpers
local helpers = {} local helpers = {}
@ -140,7 +142,9 @@ end
-- }}} -- }}}
--{{{ Iterate over table of records sorted by keys -- {{{ Misc
-- iterate over table of records sorted by keys
function helpers.spairs(t) function helpers.spairs(t)
-- collect the keys -- collect the keys
local keys = {} local keys = {}
@ -157,7 +161,15 @@ function helpers.spairs(t)
end end
end end
end end
--}}}
-- 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
-- }}}
return helpers return helpers

View File

@ -9,8 +9,6 @@
--]] --]]
package.loaded.lain = nil
local lain = local lain =
{ {
layout = require("lain.layout"), layout = require("lain.layout"),

View File

@ -162,29 +162,30 @@ end
-- {{{ Dynamic tagging -- {{{ Dynamic tagging
-- --
-- Add a new tag -- Add a new tag
function util.add_tag(mypromptbox) function util.add_tag()
awful.prompt.run({prompt="New tag name: "}, mypromptbox[mouse.screen].widget, awful.prompt.run {
function(text) prompt = "New tag name: ",
if text:len() > 0 then textbox = awful.screen.focused().mypromptbox.widget,
props = { selected = true } exe_callback = function(name)
tag = awful.tag.add(new_name, props) if not name or #name == 0 then return end
tag.name = text awful.tag.add(name, { screen = awful.screen.focused() }):view_only()
tag:emit_signal("property::name")
end end
end) }
end end
-- Rename current tag -- Rename current tag
-- @author: minism function util.rename_tag()
function util.rename_tag(mypromptbox) awful.prompt.run {
local tag = awful.tag.selected(mouse.screen) prompt = "Rename tag: ",
awful.prompt.run({prompt="Rename tag: "}, mypromptbox[mouse.screen].widget, textbox = awful.screen.focused().mypromptbox.widget,
function(text) exe_callback = function(new_name)
if text:len() > 0 then if not new_name or #new_name == 0 then return end
tag.name = text local t = awful.screen.focused().selected_tag
tag:emit_signal("property::name") if t then
t.name = new_name
end
end end
end) }
end end
-- Move current tag -- Move current tag
@ -199,14 +200,13 @@ function util.move_tag(pos)
end end
end end
-- Remove current tag (if empty) -- Delete current tag
-- Any rule set on the tag shall be broken -- Any rule set on the tag shall be broken
function util.remove_tag() function util.delete_tag()
local tag = awful.tag.selected(mouse.screen) local t = awful.screen.focused().selected_tag
local prevtag = awful.tag.gettags(mouse.screen)[awful.tag.getidx(tag) - 1] if not t then return end
awful.tag.delete(tag, prevtag) t:delete()
end end
--
-- }}} -- }}}
-- On the fly useless gaps change -- On the fly useless gaps change

View File

@ -11,6 +11,7 @@ local capi = { client = client,
mouse = mouse, mouse = mouse,
screen = screen, screen = screen,
timer = timer } timer = timer }
local math = { floor = math.floor }
local string = string local string = string
local pairs = pairs local pairs = pairs
@ -61,7 +62,7 @@ function quake:display()
-- Resize -- Resize
awful.client.floating.set(client, true) awful.client.floating.set(client, true)
client.border_width = self.border --client.border_width = self.border
client.size_hints_honor = false client.size_hints_honor = false
if self.notexist then if self.notexist then
client:geometry(self.geometry) client:geometry(self.geometry)
@ -113,8 +114,8 @@ function quake:new(config)
-- Compute size -- Compute size
local geom = capi.screen[conf.screen].workarea local geom = capi.screen[conf.screen].workarea
if width <= 1 then width = geom.width * width end if width <= 1 then width = math.floor(geom.width * width) end
if height <= 1 then height = geom.height * height end if height <= 1 then height = math.floor(geom.height * height) end
local x, y local x, y
if horiz == "left" then x = geom.x if horiz == "left" then x = geom.x
elseif horiz == "right" then x = geom.width + geom.x - width elseif horiz == "right" then x = geom.width + geom.x - width

View File

@ -13,6 +13,7 @@ local read_pipe = require("lain.helpers").read_pipe
local awful = require("awful") local awful = require("awful")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local naughty = require("naughty") local naughty = require("naughty")
local wibox = require("wibox")
local math = { modf = math.modf } local math = { modf = math.modf }
local mouse = mouse local mouse = mouse
@ -110,7 +111,7 @@ local function worker(args)
alsabar.notifications = args.notifications or alsabar.notifications alsabar.notifications = args.notifications or alsabar.notifications
alsabar.followmouse = args.followmouse or false 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_background_color(alsabar.colors.background)
alsabar.bar:set_color(alsabar.colors.unmute) alsabar.bar:set_color(alsabar.colors.unmute)

View File

@ -26,7 +26,7 @@ local setmetatable = setmetatable
-- MPD infos -- MPD infos
-- lain.widgets.mpd -- lain.widgets.mpd
local mpd = {} local mpd = helpers.make_widget_textbox()
local function worker(args) local function worker(args)
local args = args or {} local args = args or {}
@ -46,8 +46,6 @@ local function worker(args)
local mpdh = "telnet://" .. host .. ":" .. port local mpdh = "telnet://" .. host .. ":" .. port
local echo = echo_cmd .. " 'password " .. password .. "\nstatus\ncurrentsong\nclose'" local echo = echo_cmd .. " 'password " .. password .. "\nstatus\ncurrentsong\nclose'"
mpd.widget = wibox.widget.textbox('')
mpd_notification_preset = { mpd_notification_preset = {
title = "Now playing", title = "Now playing",
timeout = 6 timeout = 6
@ -139,7 +137,7 @@ local function worker(args)
helpers.newtimer("mpd", timeout, mpd.update) helpers.newtimer("mpd", timeout, mpd.update)
return setmetatable(mpd, { __index = mpd.widget }) return mpd
end end
return setmetatable(mpd, { __call = function(_, ...) return worker(...) end }) return setmetatable(mpd, { __call = function(_, ...) return worker(...) end })

View File

@ -21,7 +21,10 @@ local setmetatable = setmetatable
-- lain.widgets.net -- lain.widgets.net
local function worker(args) 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() function net.get_first_device()
local ws = helpers.read_pipe("ip link show | cut -d' ' -f2,9") local ws = helpers.read_pipe("ip link show | cut -d' ' -f2,9")
@ -38,8 +41,6 @@ local function worker(args)
local settings = args.settings or function() end local settings = args.settings or function() end
local iface = args.iface or net.get_first_device() 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 -- Compatibility with old API where iface was a string corresponding to 1 interface
if type(iface) == "string" then if type(iface) == "string" then
iftable = {iface} iftable = {iface}
@ -138,7 +139,7 @@ local function worker(args)
helpers.newtimer(iface, timeout, update) helpers.newtimer(iface, timeout, update)
return setmetatable(net, { __index = net.widget }) return net
end end
return setmetatable({}, { __call = function(_, ...) return worker(...) end }) return setmetatable({}, { __call = function(_, ...) return worker(...) end })

View File

@ -13,6 +13,7 @@ local read_pipe = require("lain.helpers").read_pipe
local awful = require("awful") local awful = require("awful")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local naughty = require("naughty") local naughty = require("naughty")
local wibox = require("wibox")
local math = { modf = math.modf } local math = { modf = math.modf }
local mouse = mouse local mouse = mouse
@ -109,7 +110,7 @@ local function worker(args)
pulsebar.step = args.step or pulsebar.step pulsebar.step = args.step or pulsebar.step
pulsebar.followmouse = args.followmouse or false 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_background_color(pulsebar.colors.background)
pulsebar.bar:set_color(pulsebar.colors.unmute) pulsebar.bar:set_color(pulsebar.colors.unmute)

2
wiki

@ -1 +1 @@
Subproject commit 42fd0d64ad66a66a062eb422fb5f26e63fd5de58 Subproject commit f6270edc9e9d8ba83971fac3dbaca301c4792f34