battery + volume indicator

This commit is contained in:
Sam Hadow 2024-03-15 15:50:22 +01:00
parent 6b7c87f237
commit 4bf7b29e2f
3 changed files with 68 additions and 18 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.jpg
*.png
*.svg

76
rc.lua
View File

@ -8,6 +8,8 @@ local awful = require("awful")
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
-- more widgets
local vicious = require("vicious")
-- Theme handling library
local beautiful = require("beautiful")
-- Notification library
@ -151,6 +153,38 @@ local tasklist_buttons = gears.table.join(
awful.client.focus.byidx(-1)
end))
--{{ Battery Widget }} --
baticon = wibox.widget.imagebox()
baticon:set_image(beautiful.baticon)
batwidget = wibox.widget.textbox()
vicious.register( batwidget, vicious.widgets.bat, '<span background="#92B0A0" font="sans 11"><span font="Overpass 13.2" color="#FFFFFF" background="#92B0A0">$2% </span></span>', 30, "BAT1" )
----{{--| Volume / volume icon |----------
volume = wibox.widget.textbox()
vicious.register(volume, vicious.widgets.volume,
'<span background="#4B3B51" font="sans 11"><span font="sans 11" color="#EEEEEE"> $1% </span></span>', 1, "Master")
volumeicon = wibox.widget.imagebox()
vicious.register(volumeicon, vicious.widgets.volume, function(widget, args)
local paraone = tonumber(args[1])
if args[2] == "" or paraone == 0 then
volumeicon:set_image(beautiful.mute)
elseif paraone >= 67 and paraone <= 100 then
volumeicon:set_image(beautiful.volhi)
elseif paraone >= 33 and paraone <= 66 then
volumeicon:set_image(beautiful.volmed)
else
volumeicon:set_image(beautiful.vollow)
end
end, 1, "Master")
--
local function set_wallpaper(s)
-- Wallpaper
if beautiful.wallpaper then
@ -200,24 +234,30 @@ awful.screen.connect_for_each_screen(function(s)
-- Create the wibox
s.mywibox = awful.wibar({ position = "top", screen = s })
-- Add widgets to the wibox
s.mywibox:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
mylauncher,
s.mytaglist,
s.mypromptbox,
},
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
mykeyboardlayout,
wibox.widget.systray(),
mytextclock,
s.mylayoutbox,
},
}
-- left widgets
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(mylauncher)
left_layout:add(s.mytaglist)
left_layout:add(s.mypromptbox)
-- right widgets
local right_layout = wibox.layout.fixed.horizontal()
right_layout:add(wibox.widget.systray())
right_layout:add(mykeyboardlayout)
right_layout:add(baticon)
right_layout:add(batwidget)
right_layout:add(volumeicon)
right_layout:add(mytextclock)
right_layout:add(s.mylayoutbox)
-- taskbar
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_middle(s.mytasklist)
layout:set_right(right_layout)
s.mywibox:set_widget(layout)
end)
-- }}}

View File

@ -126,6 +126,15 @@ theme.awesome_icon = theme_assets.awesome_icon(
-- from /usr/share/icons and /usr/share/icons/hicolor will be used.
theme.icon_theme = nil
-- battery icon
theme.baticon = themes_path.."default/icons/battery.png"
-- volume icon
theme.mute = themes_path.."default/icons/audio-volume-muted.svg"
theme.vollow = themes_path.."default/icons/audio-volume-low.svg"
theme.volmed = themes_path.."default/icons/audio-volume-medium.svg"
theme.volhi = themes_path.."default/icons/audio-volume-high.svg"
return theme
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80