Move v4 compatible widget in this repo
This commit is contained in:
parent
130813a6e2
commit
2d2684587d
|
@ -0,0 +1,59 @@
|
||||||
|
local wibox = require("wibox")
|
||||||
|
local awful = require("awful")
|
||||||
|
local naughty = require("naughty")
|
||||||
|
|
||||||
|
|
||||||
|
batteryIcon = wibox.widget {
|
||||||
|
widget = wibox.widget.imagebox
|
||||||
|
}
|
||||||
|
|
||||||
|
function refresh_icon()
|
||||||
|
awful.spawn.easy_async([[bash -c 'acpi | cut -d, -f 2 | egrep -o "[0-9]{1,3}"']],
|
||||||
|
function(stdout, stderr, reason, exit_code)
|
||||||
|
local batteryType
|
||||||
|
local charge = tonumber(stdout)
|
||||||
|
if (charge >= 0 and charge < 20) then
|
||||||
|
batteryType="battery-empty"
|
||||||
|
show_battery_warning()
|
||||||
|
elseif (charge >= 20 and charge < 40) then batteryType="battery-caution"
|
||||||
|
elseif (charge >= 40 and charge < 60) then batteryType="battery-low"
|
||||||
|
elseif (charge >= 60 and charge < 80) then batteryType="battery-good"
|
||||||
|
elseif (charge >= 80 and charge <= 100) then batteryType="battery-full"
|
||||||
|
end
|
||||||
|
batteryIcon.image = "/usr/share/icons/Arc-Icons/panel/22/" .. batteryType .. ".svg"
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function show_battery_status()
|
||||||
|
awful.spawn.easy_async([[bash -c 'acpi | cut -d, -f 2,3']],
|
||||||
|
function(stdout, stderr, reason, exit_code)
|
||||||
|
naughty.notify{
|
||||||
|
text = stdout,
|
||||||
|
title = "Battery status",
|
||||||
|
timeout = 5, hover_timeout = 0.5,
|
||||||
|
width = 200,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function show_battery_warning()
|
||||||
|
naughty.notify{
|
||||||
|
text = "Huston, we have a problem",
|
||||||
|
title = "Battery is dying",
|
||||||
|
timeout = 5, hover_timeout = 0.5,
|
||||||
|
position = "bottom_right",
|
||||||
|
bg = "#F06060",
|
||||||
|
fg = "#EEE9EF",
|
||||||
|
width = 200,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- timer to refresh icon
|
||||||
|
local batteryWidgetTimer = timer({ timeout = 60 })
|
||||||
|
batteryWidgetTimer:connect_signal("timeout", function() refresh_icon() end)
|
||||||
|
batteryWidgetTimer:start()
|
||||||
|
batteryWidgetTimer:emit_signal("timeout")
|
||||||
|
|
||||||
|
-- popup with battery info
|
||||||
|
batteryIcon:connect_signal("mouse::enter", function() show_battery_status() end)
|
|
@ -0,0 +1,18 @@
|
||||||
|
local wibox = require("wibox")
|
||||||
|
local awful = require("awful")
|
||||||
|
|
||||||
|
spotify_widget = wibox.widget.textbox()
|
||||||
|
spotify_widget:set_font('Play 9')
|
||||||
|
|
||||||
|
function updateSpotifyWidget(widget)
|
||||||
|
awful.spawn.easy_async([[bash -c 'sp current-oneline']],
|
||||||
|
function(stdout, stderr, reason, exit_code)
|
||||||
|
widget:set_text(stdout)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
spotify_timer = timer ({timeout = 10})
|
||||||
|
spotify_timer:connect_signal ("timeout", function() updateSpotifyWidget(spotify_widget) end)
|
||||||
|
spotify_timer:start()
|
||||||
|
|
||||||
|
spotify_timer:emit_signal("timeout")
|
|
@ -0,0 +1,26 @@
|
||||||
|
local wibox = require("wibox")
|
||||||
|
local awful = require("awful")
|
||||||
|
|
||||||
|
function update_volume()
|
||||||
|
awful.spawn.easy_async([[bash -c 'amixer -D pulse sget Master']],
|
||||||
|
function(stdout, stderr, reason, exit_code)
|
||||||
|
local volume = string.match(stdout, "(%d?%d?%d)%%")
|
||||||
|
volume = tonumber(string.format("% 3d", volume))
|
||||||
|
local volume_icon_name
|
||||||
|
|
||||||
|
if (volume >= 0 and volume < 20) then volume_icon_name="audio-volume-none-panel"
|
||||||
|
elseif (volume >= 20 and volume < 40) then volume_icon_name="audio-volume-zero-panel"
|
||||||
|
elseif (volume >= 40 and volume < 60) then volume_icon_name="audio-volume-low-panel"
|
||||||
|
elseif (volume >= 60 and volume < 80) then volume_icon_name="audio-volume-medium-panel"
|
||||||
|
elseif (volume >= 80 and volume <= 100) then volume_icon_name="audio-volume-high-panel"
|
||||||
|
end
|
||||||
|
volume_icon:set_image("/usr/share/icons/Arc-Icons/panel/22/" .. volume_icon_name .. ".svg")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
volume_icon = wibox.widget.imagebox()
|
||||||
|
|
||||||
|
mytimer = timer({ timeout = 0.2 })
|
||||||
|
mytimer:connect_signal("timeout", function () update_volume() end)
|
||||||
|
mytimer:start()
|
Loading…
Reference in New Issue