pulsebar: corrected colors typo; closes #251

This commit is contained in:
copycat-killer 2017-01-06 11:21:19 +01:00
parent 1bd178f687
commit bcd37ae4ae
14 changed files with 113 additions and 172 deletions

View File

@ -211,13 +211,7 @@ end
-- On the fly useless gaps change
function util.useless_gaps_resize(thatmuch)
beautiful.useless_gap_width = tonumber(beautiful.useless_gap_width) + thatmuch
awful.layout.arrange(mouse.screen)
end
-- On the fly global border change
function util.global_border_resize(thatmuch)
beautiful.global_border_width = tonumber(beautiful.global_border_width) + thatmuch
beautiful.useless_gap = tonumber(beautiful.useless_gap) + thatmuch
awful.layout.arrange(mouse.screen)
end

View File

@ -6,15 +6,14 @@
--]]
local awful = require("awful")
local capi = { client = client,
mouse = mouse,
screen = screen,
timer = timer or require("gears.timer") }
local math = { floor = math.floor }
local string = string
local awful = require("awful")
local capi = { client = client,
timer = require("gears.timer") }
local math = { floor = math.floor }
local string = string
local pairs = pairs
local screen = screen
local setmetatable = setmetatable
local tostring = tostring
@ -65,21 +64,22 @@ function quake:display()
client.border_width = self.border
client.size_hints_honor = false
if self.notexist then
self:compute_size()
client:geometry(self.geometry)
self.notexist = false
end
-- Not sticky and on top
client.sticky = false
client.ontop = true
client.above = true
client.skip_taskbar = true
client.sticky = false
-- Toggle display
if self.visible then
client.hidden = false
client:raise()
self.last_tag = tostring(awful.tag.selected(self.screen))
self.last_tag = awful.tag.selected(self.screen)
client:tags({awful.tag.selected(self.screen)})
capi.client.focus = client
else
@ -94,36 +94,38 @@ function quake:display()
return client
end
function quake:compute_size()
local geom = screen[self.screen].workarea
local width, height
if self.width <= 1 then width = math.floor(geom.width * self.width) end
if self.height <= 1 then height = math.floor(geom.height * self.height) end
local x, y
if self.horiz == "left" then x = geom.x
elseif self.horiz == "right" then x = geom.width + geom.x - self.width
else x = geom.x + (geom.width - self.width)/2 end
if self.vert == "top" then y = geom.y
elseif self.vert == "bottom" then y = geom.height + geom.y - self.height
else y = geom.y + (geom.height - self.height)/2 end
self.geometry = { x = x, y = y, width = width, height = height }
end
function quake:new(config)
local conf = config or {}
conf.app = conf.app or "xterm" -- application to spawn
conf.name = conf.name or "QuakeDD" -- window name
conf.argname = conf.argname or "-name %s" -- how to specify window name
conf.extra = conf.extra or "" -- extra arguments
conf.visible = conf.visible or false -- initially not visible
conf.screen = conf.screen or capi.mouse.screen
conf.border = conf.border or 1
conf.app = conf.app or "xterm" -- application to spawn
conf.name = conf.name or "QuakeDD" -- window name
conf.argname = conf.argname or "-name %s" -- how to specify window name
conf.extra = conf.extra or "" -- extra arguments
conf.visible = conf.visible or false -- initially not visible
conf.border = conf.border or 1 -- client border width
conf.followtag = conf.followtag or false -- spawn on currently focused screen
conf.screen = conf.screen or awful.screen.focused()
-- If width or height <= 1 this is a proportion of the workspace
wibox_height = conf.wibox_height or 18 -- statusbar weight
height = conf.height or 0.25 -- height
width = conf.width or 1 -- width
vert = conf.vert or "top" -- top, bottom or center
horiz = conf.horiz or "center" -- left, right or center
-- Compute size
local geom = capi.screen[conf.screen].workarea
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
else x = geom.x + (geom.width - width)/2 end
if vert == "top" then y = geom.y
elseif vert == "bottom" then y = geom.height + geom.y - height
else y = geom.y + (geom.height - height)/2 end
conf.geometry = { x = x, y = y + wibox_height, width = width, height = height }
conf.height = conf.height or 0.25 -- height
conf.width = conf.width or 1 -- width
conf.vert = conf.vert or "top" -- top, bottom or center
conf.horiz = conf.horiz or "center" -- left, right or center
local console = setmetatable(conf, { __index = quake })
capi.client.connect_signal("manage", function(c)
@ -140,6 +142,9 @@ function quake:new(config)
-- "Reattach" currently running quake application. This is in case awesome is restarted.
local reattach = capi.timer { timeout = 0 }
reattach:connect_signal("timeout", function()
if self.followtag then
self.screen = awful.screen.focused()
end
reattach:stop()
console:display()
end)
@ -149,8 +154,11 @@ function quake:new(config)
end
function quake:toggle()
current_tag = awful.tag.selected(self.screen)
if self.last_tag ~= tostring(current_tag) and self.visible then
if self.followtag then
self.screen = awful.screen.focused()
end
local current_tag = awful.tag.selected(self.screen)
if self.last_tag ~= current_tag and self.visible then
awful.client.movetotag(current_tag, self:display())
else
self.visible = not self.visible

View File

@ -15,7 +15,7 @@ local gears = require("gears")
-- lain.util.separators
local separators = {}
local height = beautiful.awful_widget_height or 0
local height = beautiful.separators_height or 0
local width = beautiful.separators_width or 9
-- [[ Arrow

View File

@ -16,7 +16,6 @@ local naughty = require("naughty")
local wibox = require("wibox")
local math = { modf = math.modf }
local mouse = mouse
local string = { format = string.format,
match = string.match,
rep = string.rep }
@ -43,7 +42,6 @@ local alsabar = {
font = beautiful.font:sub(beautiful.font:find(""), beautiful.font:find(" ")),
font_size = "11",
color = beautiful.fg_normal,
bar_size = 18,
screen = 1
},
@ -71,12 +69,12 @@ function alsabar.notify()
preset.title = string.format("%s - %s%%", alsabar.channel, alsabar._current_level)
end
int = math.modf((alsabar._current_level / 100) * alsabar.notifications.bar_size)
int = math.modf((alsabar._current_level / 100) * awful.screen.focused().mywibox.height)
preset.text = string.format("[%s%s]", string.rep("|", int),
string.rep(" ", alsabar.notifications.bar_size - int))
string.rep(" ", awful.screen.focused().mywibox.height - int))
if alsabar.followmouse then
preset.screen = mouse.screen
if alsabar.followtag then
preset.screen = awful.screen.focused()
end
if alsabar._notify ~= nil then
@ -107,7 +105,7 @@ local function worker(args)
alsabar.step = args.step or alsabar.step
alsabar.colors = args.colors or alsabar.colors
alsabar.notifications = args.notifications or alsabar.notifications
alsabar.followmouse = args.followmouse or false
alsabar.followtag = args.followtag or false
alsabar.bar = wibox.widget {
forced_height = height,

View File

@ -1,58 +0,0 @@
--[[
Licensed under GNU General Public License v2
* (c) 2013, Luke Bonham
* (c) 2010-2012, Peter Hofmann
--]]
local wibox = require("awful.wibox")
local setmetatable = setmetatable
-- Creates a thin wibox at a position relative to another wibox
-- lain.widgets.borderbox
local borderbox = {}
local function worker(relbox, s, args)
local where = args.position or 'top'
local color = args.color or '#FFFFFF'
local size = args.size or 1
local box = nil
local wiboxarg = { position = nil, bg = color }
if where == 'top'
then
wiboxarg.width = relbox.width
wiboxarg.height = size
box = wibox(wiboxarg)
box.x = relbox.x
box.y = relbox.y - size
elseif where == 'bottom'
then
wiboxarg.width = relbox.width
wiboxarg.height = size
box = wibox(wiboxarg)
box.x = relbox.x
box.y = relbox.y + relbox.height
elseif where == 'left'
then
wiboxarg.width = size
wiboxarg.height = relbox.height
box = wibox(wiboxarg)
box.x = relbox.x - size
box.y = relbox.y
elseif where == 'right'
then
wiboxarg.width = size
wiboxarg.height = relbox.height
box = wibox(wiboxarg)
box.x = relbox.x + relbox.width
box.y = relbox.y
end
box.screen = s
return box
end
return setmetatable(borderbox, { __call = function(_, ...) return worker(...) end })

View File

@ -14,7 +14,6 @@ local naughty = require("naughty")
local io = { popen = io.popen }
local os = { date = os.date }
local mouse = mouse
local string = { format = string.format,
sub = string.sub,
gsub = string.gsub }
@ -47,13 +46,13 @@ function calendar.show(t_out, inc_offset, scr)
if offs == 0 or calendar.offset == 0
then -- current month showing, today highlighted
calendar.offset = 0
calendar.notify_icon = calendar.icons .. today .. ".png"
calendar.notify_icon = string.format("%s%s.png", calendar.icons, today)
-- bg and fg inverted to highlight today
f = io.popen(calendar.cal_format(today))
else -- no current month showing, no day to highlight
local month = tonumber(os.date('%m'))
local year = tonumber(os.date('%Y'))
local year = tonumber(os.date('%Y'))
month = month + calendar.offset
@ -79,8 +78,8 @@ function calendar.show(t_out, inc_offset, scr)
.. "</span></tt>"
f:close()
if calendar.followmouse then
scrp = mouse.screen
if calendar.followtag then
scrp = awful.screen.focused()
else
scrp = scr or calendar.scr_pos
end
@ -111,7 +110,7 @@ function calendar.attach(widget, args)
calendar.bg = args.bg or beautiful.bg_normal or "#000000"
calendar.position = args.position or "top_right"
calendar.scr_pos = args.scr_pos or 1
calendar.followmouse = args.followmouse or false
calendar.followtag = args.followtag or false
calendar.offset = 0
calendar.notify_icon = nil

View File

@ -6,15 +6,18 @@
--]]
local helpers = require("lain.helpers")
local json = require("lain.util.dkjson")
local pread = require("awful.util").pread
local naughty = require("naughty")
local wibox = require("wibox")
local mouse = mouse
local os = { getenv = os.getenv }
local helpers = require("lain.helpers")
local json = require("lain.util.dkjson")
local focused = require("awful.screen").focused
local pread = require("awful.util").pread
local naughty = require("naughty")
local wibox = require("wibox")
local next = next
local os = { getenv = os.getenv }
local setmetatable = setmetatable
local table = table
-- Google Play Music Desktop infos
-- lain.widget.contrib.gpmdp
@ -24,7 +27,7 @@ local function worker(args)
local args = args or {}
local timeout = args.timeout or 2
local notify = args.notify or "off"
local followmouse = args.followmouse or false
local followtag = args.followtag or false
local file_location = args.file_location or
os.getenv("HOME") .. "/.config/Google Play Music Desktop Player/json_store/playback.json"
local settings = args.settings or function() end
@ -39,14 +42,14 @@ local function worker(args)
helpers.set_map("gpmdp_current", nil)
function gpmdp.update()
file, err = io.open(file_location, "r")
if not file
local filelines = helpers.lines_from(file_location)
if not next(filelines)
then
gpm_now = { running = false, playing = false }
local gpm_now = { running = false, playing = false }
else
dict, pos, err = json.decode(file:read "*a", 1, nil)
file:close()
gpm_now = {}
dict, pos, err = json.decode(table.concat(filelines), 1, nil)
local gpm_now = {}
gpm_now.artist = dict.song.artist
gpm_now.album = dict.song.album
gpm_now.title = dict.song.title
@ -54,7 +57,7 @@ local function worker(args)
gpm_now.playing = dict.playing
end
if (pread("pidof 'Google Play Music Desktop Player'") ~= '') then
if pread("pidof 'Google Play Music Desktop Player'") ~= '' then
gpm_now.running = true
else
gpm_now.running = false
@ -69,10 +72,10 @@ local function worker(args)
if notify == "on" and gpm_now.title ~= helpers.get_map("gpmdp_current")
then
helpers.set_map("gpmdp_current", gpm_now.title)
os.execute("curl " .. gpm_now.cover_url .. " -o /tmp/gpmcover.png")
os.execute(string.format("curl %d -o /tmp/gpmcover.png", gpm_now.cover_url))
if followmouse then
gpmdp_notification_preset.screen = mouse.screen
if followtag then
gpmdp_notification_preset.screen = focused()
end
gpmdp.id = naughty.notify({

View File

@ -6,18 +6,19 @@
--]]
local helpers = require("lain.helpers")
local async = require("lain.asyncshell")
local helpers = require("lain.helpers")
local async = require("lain.asyncshell")
local focused = require("awful.screen").focused
local escape_f = require("awful.util").escape
local naughty = require("naughty")
local wibox = require("wibox")
local io = { popen = io.popen }
local os = { execute = os.execute,
getenv = os.getenv }
local string = { format = string.format,
gmatch = string.gmatch }
local io = { popen = io.popen }
local os = { execute = os.execute,
getenv = os.getenv }
local string = { format = string.format,
gmatch = string.gmatch }
local setmetatable = setmetatable
@ -31,7 +32,7 @@ local function worker(args)
local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"
local cover_size = args.cover_size or 100
local default_art = args.default_art or ""
local followmouse = args.followmouse or false
local followtag = args.followtag or false
local settings = args.settings or function() end
local mpdcover = helpers.scripts_dir .. "mpdcover"
@ -85,8 +86,8 @@ local function worker(args)
os.execute(string.format("%s %q %q %d %q", mpdcover, "",
moc_now.file, cover_size, default_art))
if followmouse then
moc_notification_preset.screen = mouse.screen
if followtag then
moc_notification_preset.screen = focused()
end
moc.id = naughty.notify({

View File

@ -42,8 +42,8 @@ function task.show(scr_pos)
local f, c_text, scrp
if task.followmouse then
scrp = mouse.screen
if task.followtag then
scrp = awful.screen.focused()
else
scrp = scr_pos or task.scr_pos
end
@ -69,7 +69,7 @@ end
function task.prompt_add()
awful.prompt.run({ prompt = "Add task: " },
mypromptbox[mouse.screen].widget,
mypromptbox[awful.screen.focused()].widget,
function (...)
local f = io.popen("task add " .. ...)
c_text = "\n<span font='"
@ -94,7 +94,7 @@ end
function task.prompt_search()
awful.prompt.run({ prompt = "Search task: " },
mypromptbox[mouse.screen].widget,
mypromptbox[awful.screen.focused()].widget,
function (...)
local f = io.popen("task " .. ...)
c_text = f:read("*all"):gsub(" \n*$", "")
@ -119,7 +119,7 @@ function task.prompt_search()
fg = task.fg,
bg = task.bg,
timeout = task.timeout,
screen = mouse.screen
screen = awful.screen.focused()
})
end,
nil,
@ -137,7 +137,7 @@ function task.attach(widget, args)
task.position = args.position or "top_right"
task.timeout = args.timeout or 7
task.scr_pos = args.scr_pos or 1
task.followmouse = args.followmouse or false
task.followtag = args.followtag or false
task.cmdline = args.cmdline or "next"
task.notify_icon = icons_dir .. "/taskwarrior/task.png"

View File

@ -12,7 +12,6 @@ local async = require("lain.asyncshell")
local naughty = require("naughty")
local wibox = require("wibox")
local mouse = mouse
local string = { format = string.format,
gsub = string.gsub }
local tonumber = tonumber
@ -33,7 +32,7 @@ local function worker(args)
local port = args.port or 993
local timeout = args.timeout or 60
local is_plain = args.is_plain or false
local followmouse = args.followmouse or false
local followtag = args.followtag or false
local settings = args.settings or function() end
local head_command = "curl --connect-timeout 3 -fsm 3"
@ -53,8 +52,8 @@ local function worker(args)
position = "top_left"
}
if followmouse then
mail_notification_preset.screen = mouse.screen
if followtag then
mail_notification_preset.screen = awful.screen.focused()
end
curl = string.format("%s --url imaps://%s:%s/INBOX -u %s:%q %s -k",

View File

@ -17,7 +17,6 @@ local wibox = require("wibox")
local os = { execute = os.execute,
getenv = os.getenv }
local math = { floor = math.floor }
local mouse = mouse
local string = { format = string.format,
match = string.match,
gmatch = string.gmatch }
@ -38,7 +37,7 @@ local function worker(args)
local cover_size = args.cover_size or 100
local default_art = args.default_art or ""
local notify = args.notify or "on"
local followmouse = args.followmouse or false
local followtag = args.followtag or false
local echo_cmd = args.echo_cmd or "echo"
local settings = args.settings or function() end
@ -118,8 +117,8 @@ local function worker(args)
current_icon = default_art
end
if followmouse then
mpd_notification_preset.screen = mouse.screen
if followtag then
mpd_notification_preset.screen = awful.screen.focused()
end
mpd.id = naughty.notify({

View File

@ -41,9 +41,7 @@ local pulsebar = {
notifications = {
font = beautiful.font:sub(beautiful.font:find(""), beautiful.font:find(" ")),
font_size = "11",
color = beautiful.fg_normal,
bar_size = 18,
screen = 1
color = beautiful.fg_normal
},
_current_level = 0,
@ -57,7 +55,6 @@ function pulsebar.notify()
title = "",
text = "",
timeout = 5,
screen = pulsebar.notifications.screen,
font = string.format("%s %s", alsabar.notifications.font,
alsabar.notifications.font_size),
fg = pulsebar.notifications.color
@ -70,12 +67,12 @@ function pulsebar.notify()
preset.title = string.format("%s - %s%%", pulsebar.sink, pulsebar._current_level)
end
int = math.modf((pulsebar._current_level / 100) * pulsebar.notifications.bar_size)
int = math.modf((pulsebar._current_level / 100) * awful.screen.focused().mywibox.height)
preset.text = string.format("[%s%s]", string.rep("|", int),
string.rep(" ", pulsebar.notifications.bar_size - int))
string.rep(" ", awful.screen.focused().mywibox.height - int))
if pulsebar.followmouse then
preset.screen = mouse.screen
if pulsebar.followtag then
preset.screen = awful.screen.focused()
end
if pulsebar._notify ~= nil then
@ -106,7 +103,7 @@ local function worker(args)
pulsebar.notifications = args.notifications or pulsebar.notifications
pulsebar.sink = args.sink or 0
pulsebar.step = args.step or pulsebar.step
pulsebar.followmouse = args.followmouse or false
pulsebar.followtag = args.followtag or false
pulsebar.bar = wibox.widget {
forced_height = height,
@ -143,11 +140,11 @@ local function worker(args)
then
pulsebar._muted = true
pulsebar.tooltip:set_text ("[Muted]")
pulsebar.bar.color(pulsebar.colors.mute)
pulsebar.bar.color = pulsebar.colors.mute
else
pulsebar._muted = false
pulsebar.tooltip:set_text(string.format("%s: %s", pulsebar.sink, volu))
pulsebar.bar.color(pulsebar.colors.unmute)
pulsebar.bar.color = pulsebar.colors.unmute
end
settings()
end

View File

@ -13,6 +13,7 @@ local async = require("lain.asyncshell")
local json = require("lain.util").dkjson
local lain_icons = require("lain.helpers").icons_dir
local focused = require("awful.screen").focused
local naughty = require("naughty")
local wibox = require("wibox")
@ -60,7 +61,7 @@ local function worker(args)
return string.format("<b>%s</b>: %s, %d - %d ", day, desc, tmin, tmax)
end
local weather_na_markup = args.weather_na_markup or " N/A "
local followmouse = args.followmouse or false
local followtag = args.followtag or false
local settings = args.settings or function() end
weather.widget = wibox.widget.textbox(weather_na_markup)
@ -70,8 +71,8 @@ local function worker(args)
function weather.show(t_out)
weather.hide()
if followmouse then
notification_preset.screen = mouse.screen
if followtag then
notification_preset.screen = focused()
end
if not weather.notification_text then

2
wiki

@ -1 +1 @@
Subproject commit bc5582fb3d3d7bf54f2848e9b58aa01c9c33d79e
Subproject commit 6e439e9a28174909c4ab0dd23eaf93785cc170e7