Add antidrift plug-in and fix terrible bug in my text widgets.
parent
698a1587f5
commit
12cc4a2ad3
|
@ -0,0 +1,43 @@
|
|||
local setmetatable = setmetatable
|
||||
local awful = require("awful")
|
||||
local gears = require("gears")
|
||||
local textbox = require("wibox.widget.textbox")
|
||||
local widget_base = require("wibox.widget.base")
|
||||
|
||||
local antidrift = { mt = {} }
|
||||
|
||||
function antidrift.new()
|
||||
local textbox = textbox()
|
||||
local self = widget_base.make_widget(textbox)
|
||||
self.textbox = textbox
|
||||
|
||||
self.timer = gears.timer {
|
||||
timeout = 3,
|
||||
call_now = true,
|
||||
autostart = true,
|
||||
callback = function()
|
||||
awful.spawn.easy_async(
|
||||
{"antidrift", "--status"},
|
||||
function(out)
|
||||
out = out:gsub("[\n\r]", "")
|
||||
out = string.format("[%s]", out)
|
||||
self.textbox:set_text(out)
|
||||
end
|
||||
)
|
||||
end
|
||||
}
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
local _instance = nil;
|
||||
|
||||
function antidrift.mt:__call(...)
|
||||
if _instance == nil then
|
||||
_instance = antidrift.new(...)
|
||||
end
|
||||
return _instance
|
||||
end
|
||||
|
||||
return setmetatable(antidrift, antidrift.mt)
|
||||
|
|
@ -1,18 +1,17 @@
|
|||
local setmetatable = setmetatable
|
||||
local awful = require("awful")
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
local textbox = require("wibox.widget.textbox")
|
||||
local widget_base = require("wibox.widget.base")
|
||||
|
||||
--- Keyboard Layout widget.
|
||||
local battery = { mt = {} }
|
||||
|
||||
function battery.new()
|
||||
local widget = wibox.widget.textbox()
|
||||
local self = widget_base.make_widget(widget)
|
||||
self.widget = widget
|
||||
local textbox = textbox()
|
||||
local self = widget_base.make_widget(textbox)
|
||||
self.textbox = textbox
|
||||
|
||||
gears.timer {
|
||||
self.timer = gears.timer {
|
||||
timeout = 15,
|
||||
call_now = true,
|
||||
autostart = true,
|
||||
|
@ -23,7 +22,7 @@ function battery.new()
|
|||
function(out)
|
||||
out = out:gsub("[\n\r]", "")
|
||||
out = string.format("[%s]", out)
|
||||
self.widget:set_text(out)
|
||||
self.textbox:set_text(out)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
@ -32,6 +31,8 @@ function battery.new()
|
|||
return self
|
||||
end
|
||||
|
||||
local _instance = nil;
|
||||
|
||||
function battery.mt:__call(...)
|
||||
if _instance == nil then
|
||||
_instance = battery.new(...)
|
||||
|
|
|
@ -20,6 +20,7 @@ local menubar = require("menubar")
|
|||
-- local freedesktop = require("freedesktop")
|
||||
|
||||
-- FelixM: widgets for my use cases.
|
||||
local antidrift = require("antidrift")
|
||||
local keyboardlayout = require("keyboardlayout")
|
||||
local battery = require("battery")
|
||||
local systraywithbutton = require("systraywithbutton")
|
||||
|
@ -78,9 +79,9 @@ awful.layout.suit.floating.name = "><>"
|
|||
|
||||
-- Table of layouts to cover with awful.layout.inc, order matters.
|
||||
awful.layout.layouts = {
|
||||
awful.layout.suit.floating,
|
||||
awful.layout.suit.max,
|
||||
awful.layout.suit.tile,
|
||||
awful.layout.suit.floating,
|
||||
-- awful.layout.suit.tile.left,
|
||||
-- awful.layout.suit.tile.bottom,
|
||||
-- awful.layout.suit.tile.top,
|
||||
|
@ -123,14 +124,17 @@ menubar.utils.terminal = terminal -- Set the terminal for applications that requ
|
|||
-- Create a textclock widget
|
||||
mytextclock = wibox.widget.textclock("[%H:%M %Y/%m/%d]")
|
||||
|
||||
-- AntiDrift status
|
||||
myantidrift = antidrift()
|
||||
|
||||
-- Battery status indicator
|
||||
mybattery = battery()
|
||||
|
||||
-- Keyboard map indicator and switcher
|
||||
mykeyboardlayout = keyboardlayout()
|
||||
os.execute("setxkbmap -layout \"us, de\" -option \"grp:alt_shift_toggle\"")
|
||||
os.execute("setxkbmap -option caps:super")
|
||||
|
||||
-- Battery status indicator
|
||||
mybattery = battery()
|
||||
|
||||
-- Systray with button to toggle it
|
||||
mysystray = systraywithbutton()
|
||||
|
||||
|
@ -244,6 +248,7 @@ awful.screen.connect_for_each_screen(function(s)
|
|||
{ -- Right widgets
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
spacing = 3,
|
||||
myantidrift,
|
||||
mykeyboardlayout,
|
||||
mybattery,
|
||||
mytextclock,
|
||||
|
|
Loading…
Reference in New Issue