summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--battery-widget/battery.lua77
-rw-r--r--spotify-widget/spotify.lua10
-rw-r--r--volume-widget/volume.lua12
3 files changed, 56 insertions, 43 deletions
diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua
index 3823fba..47955c9 100644
--- a/battery-widget/battery.lua
+++ b/battery-widget/battery.lua
@@ -8,6 +8,7 @@ local watch = require("awful.widget.watch")
-- Battery 0: Charging, 53%, 00:57:43 until charged
local path_to_icons = "/usr/share/icons/Arc/status/symbolic/"
+local username = os.getenv("USER")
battery_widget = wibox.widget {
{
@@ -21,22 +22,13 @@ battery_widget = wibox.widget {
end
}
--- Popup with battery info
-battery_popup = awful.tooltip({objects = {battery_widget}})
-
--- To use colors from beautiful theme put
--- following lines in rc.lua before require("battery")
---
--- beautiful.tooltip_fg = beautiful.fg_normal
--- beautiful.tooltip_bg = beautiful.bg_normal
-
watch(
"acpi", 10,
function(widget, stdout, stderr, exitreason, exitcode)
local batteryType
local _, status, charge_str, time = string.match(stdout, '(.+): (%a+), (%d?%d%d)%%,? ?.*')
local charge = tonumber(charge_str)
- if (charge >= 0 and charge < 15) then
+ if (charge >= 0 and charge < 15) then
batteryType="battery-empty%s-symbolic"
show_battery_warning()
elseif (charge >= 15 and charge < 40) then batteryType="battery-caution%s-symbolic"
@@ -44,7 +36,7 @@ watch(
elseif (charge >= 60 and charge < 80) then batteryType="battery-good%s-symbolic"
elseif (charge >= 80 and charge <= 100) then batteryType="battery-full%s-symbolic"
end
- if status == 'Charging' then
+ if status == 'Charging' then
batteryType = string.format(batteryType,'-charging')
else
batteryType = string.format(batteryType,'')
@@ -53,36 +45,49 @@ watch(
-- Update popup text
-- TODO: Filter long lines
- battery_popup.text = string.gsub(stdout, "\n$", "")
+ -- battery_popup.text = string.gsub(stdout, "\n$", "")
end,
battery_widget
)
--- Alternative to tooltip - popup message shown by naughty library. You can compare both and choose the preferred one
---function show_battery_status()
--- awful.spawn.easy_async([[bash -c 'acpi']],
--- function(stdout, stderr, reason, exit_code)
--- naughty.notify{
--- text = stdout,
--- title = "Battery status",
--- timeout = 5, hover_timeout = 0.5,
--- width = 200,
--- }
--- end
--- )
---end
---battery_widget:connect_signal("mouse::enter", function() show_battery_status() end)
+-- Popup with battery info
+-- One way of creating a pop-up notification - naughty.notify
+local notification
+function show_battery_status()
+ awful.spawn.easy_async([[bash -c 'acpi']],
+ function(stdout, _, _, _)
+ notification = naughty.notify{
+ text = stdout,
+ title = "Battery status",
+ timeout = 5, hover_timeout = 0.5,
+ width = 200,
+ }
+ end
+ )
+end
+battery_widget:connect_signal("mouse::enter", function() show_battery_status() end)
+battery_widget:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
+
+-- Alternative to naughty.notify - tooltip. You can compare both and choose the preferred one
+
+--battery_popup = awful.tooltip({objects = {battery_widget}})
+
+-- To use colors from beautiful theme put
+-- following lines in rc.lua before require("battery"):
+-- beautiful.tooltip_fg = beautiful.fg_normal
+-- beautiful.tooltip_bg = beautiful.bg_normal
+--[[ Show warning notification ]]
function show_battery_warning()
naughty.notify{
- icon = "/home/pashik/.config/awesome/nichosi.png",
- icon_size=100,
- text = "Huston, we have a problem",
- title = "Battery is dying",
- timeout = 5, hover_timeout = 0.5,
- position = "bottom_right",
- bg = "#F06060",
- fg = "#EEE9EF",
- width = 300,
-}
+ icon = "/home/" .. username .. "/.config/awesome/nichosi.png",
+ icon_size=100,
+ text = "Huston, we have a problem",
+ title = "Battery is dying",
+ timeout = 5, hover_timeout = 0.5,
+ position = "bottom_right",
+ bg = "#F06060",
+ fg = "#EEE9EF",
+ width = 300,
+ }
end
diff --git a/spotify-widget/spotify.lua b/spotify-widget/spotify.lua
index 6420ec6..f9ffa02 100644
--- a/spotify-widget/spotify.lua
+++ b/spotify-widget/spotify.lua
@@ -21,6 +21,14 @@ watch(
spotify_widget
)
+--[[
+-- Adds mouse control to the widget:
+-- - left click - play/pause
+-- - scroll up - play next song
+-- - scroll down - play previous song ]]
spotify_widget:connect_signal("button::press", function(_,_,_,button)
- if (button == 1) then awful.spawn("sp play", false) end
+ if (button == 1) then awful.spawn("sp play", false)
+ elseif (button == 4) then awful.spawn("sp next", false)
+ elseif (button == 5) then awful.spawn("sp prev", false)
+ end
end) \ No newline at end of file
diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua
index b832bab..c10e464 100644
--- a/volume-widget/volume.lua
+++ b/volume-widget/volume.lua
@@ -9,17 +9,17 @@ local request_command = 'amixer -D pulse sget Master'
volume_widget = wibox.widget {
{
id = "icon",
- image = path_to_icons .. "audio-volume-muted-symbolic.svg",
- resize = false,
+ image = path_to_icons .. "audio-volume-muted-symbolic.svg",
+ resize = false,
widget = wibox.widget.imagebox,
},
- layout = wibox.container.margin(brightness_icon, 0, 0, 3),
+ layout = wibox.container.margin(_, _, _, 3),
set_image = function(self, path)
self.icon.image = path
end
}
-local update_graphic = function(widget, stdout, stderr, reason, exit_code)
+local update_graphic = function(widget, stdout, _, _, _)
local mute = string.match(stdout, "%[(o%D%D?)%]")
local volume = string.match(stdout, "(%d?%d?%d)%%")
volume = tonumber(string.format("% 3d", volume))
@@ -42,10 +42,10 @@ volume_widget:connect_signal("button::press", function(_,_,_,button)
elseif (button == 5) then awful.spawn("amixer -D pulse sset Master 5%-", false)
elseif (button == 1) then awful.spawn("amixer -D pulse sset Master toggle", false)
end
-
+
spawn.easy_async(request_command, function(stdout, stderr, exitreason, exitcode)
update_graphic(volume_widget, stdout, stderr, exitreason, exitcode)
end)
end)
-watch(request_command, 1, update_graphic, volume_widget)
+watch(request_command, 1, update_graphic, volume_widget) \ No newline at end of file