From 4bf7b29e2f12179bca9022c1f60a3d0137b8bd6b Mon Sep 17 00:00:00 2001 From: Sam Hadow Date: Fri, 15 Mar 2024 15:50:22 +0100 Subject: [PATCH] battery + volume indicator --- .gitignore | 1 + rc.lua | 76 ++++++++++++++++++++++++++++++---------- themes/default/theme.lua | 9 +++++ 3 files changed, 68 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 88cc107..a6efc54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.jpg *.png +*.svg diff --git a/rc.lua b/rc.lua index 958f0f7..018239a 100644 --- a/rc.lua +++ b/rc.lua @@ -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, '$2% ', 30, "BAT1" ) + + +----{{--| Volume / volume icon |---------- +volume = wibox.widget.textbox() +vicious.register(volume, vicious.widgets.volume, +' $1% ', 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) -- }}} diff --git a/themes/default/theme.lua b/themes/default/theme.lua index e489ba8..6fd7f7d 100644 --- a/themes/default/theme.lua +++ b/themes/default/theme.lua @@ -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