Compare commits

..

10 Commits

Author SHA1 Message Date
don philipe 1404159cc4 Add pacman widget 2026-04-22 22:32:06 +02:00
don philipe 5ee82345ed Fix wifi tooltip when not connected 2026-04-13 00:29:18 +02:00
don philipe 04541118c8 Add wifi info tooltip 2026-04-12 11:33:27 +02:00
don philipe 4c4dbb0efd Add slash separator 2026-04-12 11:32:53 +02:00
don philipe 6f33155f3c Additional icon for bluetooth connected 2024-06-01 18:27:12 +02:00
don philipe d427081284 Add wireguard interface detection 2024-03-29 14:09:40 +01:00
don philipe a7b10c63fa Fix string to number conversion 2023-12-17 21:08:03 +01:00
don philipe 4fa74ea78c Mark active audio sink 2023-10-15 17:48:34 +02:00
don philipe 4f112a6726 Switch to pipewire, add sink tooltip 2023-10-15 17:32:57 +02:00
don philipe e5d68db691 Add vpn type information as tooltip 2023-09-05 10:33:18 +02:00
5 changed files with 239 additions and 5 deletions
+113
View File
@@ -1,10 +1,18 @@
-- requires pulseaudio-ctl and lua53-dkjson installed
local awful = require("awful")
local vicious = require("vicious")
local wibox = require("wibox")
local naughty = require("naughty")
local beautiful = require("beautiful")
local json = require("dkjson") --require("knorke.json")
local icon_mute
local icon_low
local icon_medium
local icon_high
local mute_state
local vol_id
-- Create layout with widgets
@@ -37,6 +45,23 @@ vicious.register(widget.text, vicious.widgets.volume,
return " " .. args[1] .. "%"
end, 1, "Master")
local function change_volume(amount)
if (amount < 0) then
awful.util.spawn("amixer -qD pipewire sset Master " .. math.abs(amount) .. "%-")
else
awful.util.spawn("amixer -qD pipewire sset Master " .. math.abs(amount) .. "%+")
end
local f = io.popen("amixer -D pipewire get Master")
local vol = 0
for line in f:lines() do
for word in string.gmatch(line, "(%d%d?%d?)%%") do
vol = word
end
end
-- add changed amount as the current value is not yet changed when calling io.popen
return tonumber(vol) + amount
end
-- Widget function that is available from the outside.
function widget.set_icons(mute, low, medium, high)
icon_mute = mute
@@ -45,4 +70,92 @@ function widget.set_icons(mute, low, medium, high)
icon_high = high
end
function widget.notify_mute()
-- evaluate old state as util.spawn is too slow and io.popen will be evaluated before
local old_state = io.popen("pulseaudio-ctl full-status")
for line in old_state:lines() do
for val in string.gmatch(line, "%d%d?%d?%s(%w%w%w?)") do
mute_state = val
end
end
local notify_icon = beautiful.icons.vol_mute
if mute_state == "yes" then
notify_icon = beautiful.icons.vol_high
end
awful.util.spawn("amixer -qD pipewire sset Master toggle")
vol_id = naughty.notify({
icon = notify_icon,
position = "top_middle",
border_width = 0,
icon_size = 128,
replaces_id = vol_id }).id
end
function widget.notify_volume(delta)
local volume = change_volume(delta)
if (volume > 50) then
notify_icon = beautiful.icons.vol_high
elseif (volume == 0) then
notify_icon = beautiful.icons.vol_mute
else
notify_icon = beautiful.icons.vol_low
end
local notify_icon_vol = naughty.notify({
position = "top_middle",
border_width = 0,
icon = notify_icon,
replaces_id = vol_id })
vol_id = notify_icon_vol.id
local notify_width = notify_icon_vol.width
local bar = wibox.widget.progressbar()
bar:set_value(volume)
bar:set_max_value(100)
bar:set_color(beautiful.archcolor)
bar:set_background_color(beautiful.archcolor_bg)
wibox.widget.draw_to_svg_file(bar, "/tmp/vol-bar.svg", 128, 10)
vol_id_1 = naughty.notify({
position = "top_middle",
border_width = 0,
icon = "/tmp/vol-bar.svg",
width = notify_width,
replaces_id = vol_id_1 }).id
end
-- Show audio sinks in tooltip
awful.tooltip(
{
objects = { widget },
mode = "outside",
align = "right",
fg = "white",
margin_leftright = 10,
margin_topbottom = 10,
timeout = 5,
timer_function = function()
local handle = io.popen("pw-dump -N", "r")
local json_string = ""
local results = {}
for line in handle:lines() do
json_string = json_string .. line
end
local json_obj, pos, err = json.decode(json_string)
if not err then
for i = 1, #json_obj do
if json_obj[i].info and json_obj[i].info.props["media.class"] == "Audio/Sink" then
local active = ""
if json_obj[i].info.state == "running" then
active = " *"
end
table.insert(results, tostring(json_obj[i].info.props["node.description"]) .. active)
end
end
end
handle:close()
return table.concat(results, "\n")
end,
preferred_positions = {"right", "left", "top", "bottom"}
}
)
return widget
+4 -1
View File
@@ -10,6 +10,7 @@ local gears = require("gears")
local is_on
local icon_dis
local icon_enab
local icon_conn
local widget = wibox.widget {
{
@@ -33,9 +34,10 @@ widget:buttons(awful.util.table.join(
-- Add icons vor various BT states.
-- These icons should come as beautiful.icons
function widget.set_icons(disabled, enabled)
function widget.set_icons(disabled, enabled, connected)
icon_dis = disabled
icon_enab = enabled
icon_conn = connected
end
awful.tooltip(
@@ -59,6 +61,7 @@ watch("bluetoothctl show", 5,
function(_, stdout)
-- Check if there bluetooth
local checker = stdout:match("Powered: yes") -- If 'Powered: yes' string is detected on stdout
-- TODO check for connection and set connected icon
local widget_icon_nme
if (checker ~= nil) then
is_on = true
+60
View File
@@ -0,0 +1,60 @@
local awful = require("awful")
local beautiful = require("beautiful")
local gears = require("gears")
local vicious = require("vicious")
local wibox = require("wibox")
local color = beautiful.bg_focus
local widget = wibox.widget {
{
id = "sep",
widget = wibox.widget.separator,
shape = gears.shape["parallelogram"],
color = color,
forced_width = 8
},
{
id = "icon",
widget = wibox.widget.imagebox,
resize = true
},
{
id = "text",
widget = wibox.widget.textbox,
resize = true,
forced_width = 30,
align = "right"
},
layout = wibox.layout.align.horizontal
}
local container = wibox.container.margin(wibox.container.margin(widget, 3), 3)
local pkgs = ""
vicious.register(widget.text, vicious.widgets.pkg,
function (w, args)
pkgs = args[2]
return args[1]
end, 5, "Arch")
-- These icons should come as beautiful.icons
function container.set_icons(pacman)
widget.icon:set_image(pacman)
end
awful.tooltip(
{
objects = { widget },
mode = "outside",
align = "right",
fg = "white",
margin_leftright = 10,
margin_topbottom = 10,
timer_function = function()
return "Installable packages: \n" .. pkgs
end,
preferred_positions = {"right", "left", "top", "bottom"}
}
)
return container
+23 -1
View File
@@ -20,7 +20,7 @@ gears.timer {
timeout = 10,
autostart = true,
callback = function ()
awful.spawn.easy_async_with_shell("ifconfig | grep \"tun.*:\"",
awful.spawn.easy_async_with_shell("ifconfig | grep \"tun.*:\\|wg.*:\"",
function (stdout, _, _, _)
if (stdout == "") then
widget.icon:set_image(icon_vpn_noconn)
@@ -37,4 +37,26 @@ function widget.set_icons(vpn_noconn, vpn_conn)
icon_vpn_conn = vpn_conn
end
awful.tooltip(
{
objects = { widget },
mode = "outside",
align = "right",
fg = "white",
margin_leftright = 10,
margin_topbottom = 10,
preferred_positions = { "right", "left", "top", "bottom" },
timer_function = function()
local num_vpnc_proc = awful.spawn.with_shell("ps aux | grep vpnc | wc -l")
if (tonumber(num_vpnc_proc) > 1) then
return "VPNC"
end
local num_openconnect_proc = awful.spawn.with_shell("ps aux | grep openconnect | wc -l")
if (tonumber(num_openconnect_proc) > 1) then
return "OPENCONNECT"
end
end
}
)
return widget
+39 -3
View File
@@ -1,3 +1,6 @@
local awful = require("awful")
local beautiful = require("beautiful")
local gears = require("gears")
local vicious = require("vicious")
local wibox = require("wibox")
@@ -6,10 +9,19 @@ local icon_excellent
local icon_good
local icon_ok
local icon_none
local color = beautiful.bg_focus
local info = {}
-- Create layout with widgets
local widget = wibox.widget {
{
id = "sep",
widget = wibox.widget.separator,
shape = gears.shape["parallelogram"],
color = color,
forced_width = 8
},
{
id = "icon",
widget = wibox.widget.imagebox,
@@ -22,6 +34,8 @@ local widget = wibox.widget {
},
layout = wibox.layout.align.horizontal
}
local container = wibox.container.margin(wibox.container.margin(widget, 3), 3)
vicious.register(widget.text, vicious.widgets.wifi,
function (w, args)
if args["{ssid}"] ~= "N/A" then
@@ -34,14 +48,15 @@ vicious.register(widget.text, vicious.widgets.wifi,
else
widget.icon:set_image(icon_none)
end
info = args
else
widget.icon:set_image(icon_wifi)
widget.icon:set_image(icon_none)
end
return " " .. args["{ssid}"]
end, 2, "wlp64s0")
-- Widget function that is available from the outside.
function widget.set_icons(wifi, excellent, good, ok, none)
function container.set_icons(wifi, excellent, good, ok, none)
icon_wifi = wifi
icon_excellent = excellent
icon_good = good
@@ -49,4 +64,25 @@ function widget.set_icons(wifi, excellent, good, ok, none)
icon_none = none
end
return widget
awful.tooltip(
{
objects = { widget },
mode = "outside",
align = "right",
fg = "white",
margin_leftright = 10,
margin_topbottom = 10,
timer_function = function()
if info["{ssid}"] ~= nil then
return info["{ssid}"] .. "\n Channel: " .. info["{chan}"] .. "\n Rate: " .. info["{rate}"] .. "Mb/s\n Frequency: " .. info["{freq}"] .. "MHz"
else
return "N/A"
end
end,
preferred_positions = {"right", "left", "top", "bottom"}
}
)
return container
-- scan networks via `sudo iw dev wlp64s0 scan | grep SSID:`