- add awesome-{memwidget,batterystat,fswidget}
- fix layout for tag buttons - stack tag number on top of tag remove button - replace clock to be clearer
This commit is contained in:
parent
9e6879ca96
commit
edda6d4508
62
init.lua
62
init.lua
@ -3,6 +3,9 @@ local wibox = require("wibox")
|
|||||||
local gears = require("gears")
|
local gears = require("gears")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local longpress = require("awesome-longpress")
|
local longpress = require("awesome-longpress")
|
||||||
|
local batterystat = require("awesome-batterystat")
|
||||||
|
local memstat = require("awesome-memwidget")
|
||||||
|
local fswidget = require("awesome-fswidget")
|
||||||
local switcherpopup = {
|
local switcherpopup = {
|
||||||
iconSize = 128,
|
iconSize = 128,
|
||||||
systraySize = 64,
|
systraySize = 64,
|
||||||
@ -10,7 +13,6 @@ local switcherpopup = {
|
|||||||
spacing = 5,
|
spacing = 5,
|
||||||
defaultLayout = awful.layout.suit.max,
|
defaultLayout = awful.layout.suit.max,
|
||||||
iconPath = gears.filesystem.get_configuration_dir() .. "/awesome-switcherpopup/",
|
iconPath = gears.filesystem.get_configuration_dir() .. "/awesome-switcherpopup/",
|
||||||
batteryPath = "/sys/class/power_supply/pad-battery/"
|
|
||||||
}
|
}
|
||||||
function switcherpopup.nextTagName(s)
|
function switcherpopup.nextTagName(s)
|
||||||
print(#s.tags, #s.tags+1)
|
print(#s.tags, #s.tags+1)
|
||||||
@ -24,16 +26,38 @@ function switcherpopup.new(s)
|
|||||||
screen = s,
|
screen = s,
|
||||||
layout = wibox.layout.grid.vertical(math.floor(s.geometry.width / (switcherpopup.iconSize + switcherpopup.spacing)))
|
layout = wibox.layout.grid.vertical(math.floor(s.geometry.width / (switcherpopup.iconSize + switcherpopup.spacing)))
|
||||||
}
|
}
|
||||||
local clock = wibox.container.place(wibox.widget.textclock("%H:%M %Y-%m-%d"), "center", "center")
|
local clock = wibox.container.place(wibox.widget{
|
||||||
local tagindex = wibox.widget({widget = wibox.widget.textbox, align = "center"})
|
layout = wibox.layout.fixed.vertical,
|
||||||
|
wibox.widget{
|
||||||
|
widget = wibox.widget.textbox,
|
||||||
|
align = "center",
|
||||||
|
text = "time"
|
||||||
|
},
|
||||||
|
wibox.widget{
|
||||||
|
widget = wibox.widget.textbox,
|
||||||
|
align = "center",
|
||||||
|
text = "date"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
function clock.update(self)
|
||||||
|
local naughty = require("naughty")
|
||||||
|
for k,v in ipairs(self.widget.children[1]) do
|
||||||
|
naughty.notify({text=tostring(k)..": "..tostring(v.text)})
|
||||||
|
end
|
||||||
|
self.widget.children[1].markup = string.format('<span size="xx-large">%s</span>',os.date("%H:%M"))
|
||||||
|
self.widget.children[2].markup = os.date("%Y-%m-%d")
|
||||||
|
end
|
||||||
|
local tagindex = wibox.widget({widget = wibox.widget.textbox, align = "center", valign = "center"})
|
||||||
|
local indicators = wibox.widget({layout=wibox.layout.grid.horizontal, spacing=5, mem, battery})
|
||||||
|
local unpack = unpack or table.unpack -- in Lua 5.1, table.unpack was just called 'unpack'
|
||||||
|
for k,v in ipairs({memstat, batterystat, fswidget}) do
|
||||||
|
indicators:add(unpack(v.all()))
|
||||||
|
end
|
||||||
local function updateSwitcherpopup()
|
local function updateSwitcherpopup()
|
||||||
tagindex.text = "Tag: "..tostring(awful.screen.focused().selected_tag.name)
|
clock:update()
|
||||||
local fp, fs = io.open(switcherpopup.batteryPath .. "/capacity","rb"), io.open(switcherpopup.batteryPath .. "/status","rb")
|
tagindex.markup = '<span size="xx-large" color="'..tostring(beautiful.bg_normal)..'">'..tostring(awful.screen.focused().selected_tag.name)..'</span>'
|
||||||
if fp and fs then
|
for k,v in ipairs(indicators) do
|
||||||
local status = fs:read()
|
pcall(v.update, v)
|
||||||
tagindex.text = string.format("Battery: %s%%%s\n%s", fp:read(), status == "Charging" and "+" or "-", tagindex.text)
|
|
||||||
fp:close()
|
|
||||||
fs:close()
|
|
||||||
end
|
end
|
||||||
tasklistWidget:reset()
|
tasklistWidget:reset()
|
||||||
for k,v in pairs(awful.screen.focused().selected_tag:clients()) do
|
for k,v in pairs(awful.screen.focused().selected_tag:clients()) do
|
||||||
@ -63,16 +87,14 @@ function switcherpopup.new(s)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
screen.connect_signal("arrange",updateSwitcherpopup)
|
screen.connect_signal("arrange",updateSwitcherpopup)
|
||||||
local function pictureButton(icon)
|
local function pictureButton(icon,text,fn,lfn)
|
||||||
local rc = wibox.container.place(wibox.container.constraint(wibox.widget({
|
local rc = wibox.container.constraint(wibox.widget({
|
||||||
widget=wibox.widget.imagebox,
|
widget=wibox.widget.imagebox,
|
||||||
forced_width = switcherpopup.buttonSize,
|
forced_width = switcherpopup.buttonSize,
|
||||||
forced_height = switcherpopup.buttonSize,
|
forced_height = switcherpopup.buttonSize,
|
||||||
image = switcherpopup.iconPath .. "/" .. icon
|
image = switcherpopup.iconPath .. "/" .. icon
|
||||||
}),nil,switcherpopup.buttonSize,switcherpopup.buttonSize), "center", "top")
|
}),nil,switcherpopup.buttonSize,switcherpopup.buttonSize)
|
||||||
rc.content_fill_vertical = true
|
return wibox.container.place(rc)
|
||||||
rc.content_fill_horizontal = true
|
|
||||||
return rc
|
|
||||||
end
|
end
|
||||||
local close_button = pictureButton("window-close.svg")
|
local close_button = pictureButton("window-close.svg")
|
||||||
close_button:buttons(gears.table.join(
|
close_button:buttons(gears.table.join(
|
||||||
@ -95,7 +117,7 @@ function switcherpopup.new(s)
|
|||||||
popup.visible = false
|
popup.visible = false
|
||||||
end)
|
end)
|
||||||
))
|
))
|
||||||
local destroy_tag_button = pictureButton("tag-destroy.svg")
|
local destroy_tag_button = pictureButton("tag-destroy.svg",s.selected_tag.name)
|
||||||
destroy_tag_button:buttons(gears.table.join(
|
destroy_tag_button:buttons(gears.table.join(
|
||||||
destroy_tag_button:buttons(),
|
destroy_tag_button:buttons(),
|
||||||
awful.button({}, 1, nil, function()
|
awful.button({}, 1, nil, function()
|
||||||
@ -130,15 +152,13 @@ function switcherpopup.new(s)
|
|||||||
if nextTag > #s.tags then nextTag = 1 end
|
if nextTag > #s.tags then nextTag = 1 end
|
||||||
s.clients[1]:move_to_tag(s.tags[nextTag])
|
s.clients[1]:move_to_tag(s.tags[nextTag])
|
||||||
popup.visible = false
|
popup.visible = false
|
||||||
error("move attempted")
|
|
||||||
end
|
end
|
||||||
error("move failed?")
|
|
||||||
end)
|
end)
|
||||||
local tagbuttons = wibox.widget({layout = wibox.layout.ratio.horizontal, spacing=0, prev_tag_button,create_tag_button,destroy_tag_button,next_tag_button,close_button})
|
local tagbuttons = wibox.widget({layout = wibox.layout.ratio.horizontal, prev_tag_button,create_tag_button,wibox.widget{layout=wibox.layout.stack, destroy_tag_button, tagindex},next_tag_button,close_button})
|
||||||
systray:set_screen(s)
|
systray:set_screen(s)
|
||||||
systray:set_horizontal(true)
|
systray:set_horizontal(true)
|
||||||
popup = awful.popup {
|
popup = awful.popup {
|
||||||
widget = {layout = wibox.layout.fixed.vertical, clock, tagindex, systray, tasklistWidget, wibox.container.constraint(tagbuttons, min, switcherpopup.buttonSize*5, switcherpopup.buttonSize)},
|
widget = {layout = wibox.layout.fixed.vertical, clock, wibox.container.place(indicators), wibox.container.place(systray), tasklistWidget, tagbuttons},
|
||||||
border_color = beautiful.border_focus,
|
border_color = beautiful.border_focus,
|
||||||
border_width = 2,
|
border_width = 2,
|
||||||
ontop = true,
|
ontop = true,
|
||||||
|
Loading…
Reference in New Issue
Block a user