Add awesome home configs

This commit is contained in:
natemaia
2019-08-25 10:48:40 -07:00
parent 4f008a56e2
commit 950b3a8147
32447 changed files with 350162 additions and 0 deletions

View File

@ -0,0 +1,32 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
-- Configuration
local update_interval = 30 -- in seconds
local battery_text = wibox.widget.textbox()
local battery = wibox.widget {
battery_text,
layout = wibox.layout.align.horizontal,
}
local function update_widget(bat)
battery_text.markup = bat
end
local bat_script = [[
bash -c "
upower -i $(upower -e | grep BAT) | grep percentage | awk '{print $2}'
"]]
-- Update percentage
awful.widget.watch(bat_script, update_interval, function(widget, stdout)
-- local bat = stdout:match(':%s*(.*)..')
local bat = string.gsub(stdout, '^%s*(.-)%s*$', '%1')
update_widget(bat)
end)
return battery

View File

@ -0,0 +1,47 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
-- Set colors
local active_color = beautiful.battery_bar_active_color or "#5AA3CC"
local background_color = beautiful.battery_bar_background_color or "#222222"
-- Configuration
local update_interval = 30 -- in seconds
local battery_bar = wibox.widget{
max_value = 100,
value = 50,
forced_height = dpi(10),
margins = {
top = dpi(8),
bottom = dpi(8),
},
forced_width = dpi(200),
shape = gears.shape.rounded_bar,
bar_shape = gears.shape.rounded_bar,
color = active_color,
background_color = background_color,
border_width = 0,
border_color = beautiful.border_color,
widget = wibox.widget.progressbar,
}
local function update_widget(bat)
battery_bar.value = tonumber(bat)
end
local bat_script = [[
bash -c "
upower -i $(upower -e | grep BAT) | grep percentage | awk '{print $2}'
"]]
awful.widget.watch(bat_script, update_interval, function(widget, stdout)
local bat = stdout:gsub("%%", "")
update_widget(bat)
end)
return battery_bar

View File

@ -0,0 +1,64 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
-- Set colors
local active_color = beautiful.brightness_bar_active_color or "#5AA3CC"
local background_color = beautiful.brightness_bar_background_color or "#222222"
local brightness_bar = wibox.widget{
max_value = 100,
value = 50,
forced_height = dpi(10),
margins = {
top = dpi(8),
bottom = dpi(8),
},
forced_width = dpi(200),
shape = gears.shape.rounded_bar,
bar_shape = gears.shape.rounded_bar,
color = active_color,
background_color = background_color,
border_width = 0,
border_color = beautiful.border_color,
widget = wibox.widget.progressbar,
}
-- Mouse control
-- brightness_bar:buttons(gears.table.join(
-- --
-- awful.button({ }, 1, function ()
-- end),
-- --
-- awful.button({ }, 2, function ()
-- end),
-- --
-- awful.button({ }, 3, function ()
-- end),
-- --
-- awful.button({ }, 4, function ()
-- end),
-- awful.button({ }, 5, function ()
-- end)
-- ))
local function update_widget()
awful.spawn.easy_async_with_shell("xbacklight -get", function(out)
-- Remove trailing whitespaces
-- out = out:gsub('^%s*(.-)%s*$', '%1')
-- host_text.markup = helpers.colorize_text("@"..out, xcolor8)
brightness_bar.value = tonumber(out)
end)
end
-- Signals
awesome.connect_signal("brightness_changed", function ()
update_widget()
end)
update_widget()
return brightness_bar

View File

@ -0,0 +1,77 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
-- Set colors
local active_color = beautiful.cpu_bar_active_color or "#5AA3CC"
local background_color = beautiful.cpu_bar_background_color or "#222222"
-- Configuration
local update_interval = 5 -- in seconds
local cpu_bar = wibox.widget{
max_value = 100,
value = 50,
forced_height = dpi(10),
margins = {
top = dpi(8),
bottom = dpi(8),
},
forced_width = dpi(200),
shape = gears.shape.rounded_bar,
bar_shape = gears.shape.rounded_bar,
color = active_color,
background_color = background_color,
border_width = 0,
border_color = beautiful.border_color,
widget = wibox.widget.progressbar,
}
-- Mouse control
-- cpu_bar:buttons(gears.table.join(
-- --
-- awful.button({ }, 1, function ()
-- end),
-- --
-- awful.button({ }, 2, function ()
-- end),
-- --
-- awful.button({ }, 3, function ()
-- end),
-- --
-- awful.button({ }, 4, function ()
-- end),
-- awful.button({ }, 5, function ()
-- end)
-- ))
local function update_widget(cpu_idle)
-- Use this if you want to display usage percentage
-- cpu_bar.value = 100 - cpu_idle
-- Use this if you want to idle percentage
cpu_bar.value = tonumber(cpu_idle)
end
-- Signals
-- cpu_bar:connect_signal("mouse::enter", function ()
-- update_widget()
-- end)
-- update_widget()
local cpu_idle_script = [[
bash -c "
vmstat 1 2 | tail -1 | awk '{printf \"%d\", $15}'
"]]
awful.widget.watch(cpu_idle_script, update_interval, function(widget, stdout)
-- local cpu_idle = stdout:match('+(.*)%.%d...(.*)%(')
local cpu_idle = stdout
cpu_idle = string.gsub(cpu_idle, '^%s*(.-)%s*$', '%1')
update_widget(cpu_idle)
end)
return cpu_bar

View File

@ -0,0 +1,58 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
-- Configuration
local update_interval = 120 -- in seconds
local disk = wibox.widget{
text = "free disk space",
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
}
-- Mouse control
-- disk:buttons(gears.table.join(
-- --
-- awful.button({ }, 1, function ()
-- end),
-- --
-- awful.button({ }, 2, function ()
-- end),
-- --
-- awful.button({ }, 3, function ()
-- end),
-- --
-- awful.button({ }, 4, function ()
-- end),
-- awful.button({ }, 5, function ()
-- end)
-- ))
local function update_widget(disk_space)
disk.markup = disk_space .. "B free"
end
-- Signals
-- disk:connect_signal("mouse::enter", function ()
-- update_widget()
-- end)
-- update_widget()
-- Use /dev/sdXY according to your setup
local disk_script = [[
bash -c "
df -k -h /dev/sda2 | tail -1 | awk '{print $4}'
"]]
awful.widget.watch(disk_script, update_interval, function(widget, stdout)
local disk_space = stdout
-- Remove trailing white space
disk_space = string.gsub(disk_space, '^%s*(.-)%s*$', '%1')
update_widget(disk_space)
end)
return disk

View File

@ -0,0 +1,312 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
-- local naughty = require("naughty")
local keygrabber = require("awful.keygrabber")
-- Appearance
local icon_font = "Font Awesome 5 Free 90"
local text_font = "sans 25"
local poweroff_text_icon = ""
local reboot_text_icon = ""
local suspend_text_icon = ""
local exit_text_icon = ""
local lock_text_icon = ""
local icon_normal_color = beautiful.xcolor12
local icon_hover_color = beautiful.xcolor4
-- Commands
local poweroff_command = function()
awful.spawn.with_shell("poweroff")
awful.keygrabber.stop(exit_screen_grabber)
end
local reboot_command = function()
awful.spawn.with_shell("reboot")
awful.keygrabber.stop(exit_screen_grabber)
end
local suspend_command = function()
awful.spawn.with_shell("systemctl suspend")
-- awful.spawn.with_shell("i3lock & systemctl suspend")
exit_screen_hide()
end
local exit_command = function()
awesome.quit()
end
local lock_command = function()
exit_screen_hide()
awful.spawn.with_shell("i3lock-fancy")
end
local username = os.getenv("USER")
-- Capitalize username
local goodbye_widget = wibox.widget.textbox("Goodbye " .. username:sub(1,1):upper()..username:sub(2))
goodbye_widget.font = "sans 70"
local poweroff_icon = wibox.widget.textbox()
poweroff_icon.font = icon_font
poweroff_icon.markup = "<span foreground='" .. icon_normal_color .."'>" .. poweroff_text_icon .. "</span>"
local poweroff_text = wibox.widget.textbox("Poweroff")
poweroff_text.font = text_font
local poweroff = wibox.widget{
{
nil,
poweroff_icon,
forced_height = dpi(150),
expand = "none",
layout = wibox.layout.align.horizontal
},
{
nil,
poweroff_text,
expand = "none",
layout = wibox.layout.align.horizontal
},
-- forced_width = 100,
layout = wibox.layout.fixed.vertical
}
poweroff:buttons(gears.table.join(
awful.button({ }, 1, function ()
poweroff_command()
end)
))
local reboot_icon = wibox.widget.textbox()
reboot_icon.font = icon_font
reboot_icon.markup = "<span foreground='" .. icon_normal_color .."'>" .. reboot_text_icon .. "</span>"
local reboot_text = wibox.widget.textbox("Reboot")
reboot_text.font = text_font
local reboot = wibox.widget{
{
nil,
reboot_icon,
forced_height = dpi(150),
expand = "none",
layout = wibox.layout.align.horizontal
},
{
nil,
reboot_text,
expand = "none",
layout = wibox.layout.align.horizontal
},
-- forced_width = 100,
layout = wibox.layout.fixed.vertical
}
reboot:buttons(gears.table.join(
awful.button({ }, 1, function ()
reboot_command()
end)
))
local suspend_icon = wibox.widget.textbox()
suspend_icon.font = icon_font
suspend_icon.markup = "<span foreground='" .. icon_normal_color .."'>" .. suspend_text_icon .. "</span>"
local suspend_text = wibox.widget.textbox("Suspend")
suspend_text.font = text_font
local suspend = wibox.widget{
{
nil,
suspend_icon,
forced_height = dpi(150),
expand = "none",
layout = wibox.layout.align.horizontal
},
{
nil,
suspend_text,
expand = "none",
layout = wibox.layout.align.horizontal
},
-- forced_width = 100,
layout = wibox.layout.fixed.vertical
}
suspend:buttons(gears.table.join(
awful.button({ }, 1, function ()
suspend_command()
end)
))
local exit_icon = wibox.widget.textbox()
exit_icon.font = icon_font
exit_icon.markup = "<span foreground='" .. icon_normal_color .."'>" .. exit_text_icon .. "</span>"
local exit_text = wibox.widget.textbox("Exit")
exit_text.font = text_font
local exit = wibox.widget{
{
nil,
exit_icon,
forced_height = dpi(150),
expand = "none",
layout = wibox.layout.align.horizontal
},
{
nil,
exit_text,
expand = "none",
layout = wibox.layout.align.horizontal
},
-- forced_width = 100,
layout = wibox.layout.fixed.vertical
}
exit:buttons(gears.table.join(
awful.button({ }, 1, function ()
exit_command()
end)
))
local lock_icon = wibox.widget.textbox()
lock_icon.font = icon_font
lock_icon.markup = "<span foreground='" .. icon_normal_color .."'>" .. lock_text_icon .. "</span>"
local lock_text = wibox.widget.textbox("Lock")
lock_text.font = text_font
local lock = wibox.widget{
{
nil,
lock_icon,
forced_height = dpi(150),
expand = "none",
layout = wibox.layout.align.horizontal
},
{
nil,
lock_text,
expand = "none",
layout = wibox.layout.align.horizontal
},
-- forced_width = 100,
layout = wibox.layout.fixed.vertical
}
lock:buttons(gears.table.join(
awful.button({ }, 1, function ()
lock_command()
end)
))
-- Get screen geometry
local screen_width = awful.screen.focused().geometry.width
local screen_height = awful.screen.focused().geometry.height
-- Create the widget
exit_screen = wibox({x = 0, y = 0, visible = false, ontop = true, type = "dock", height = screen_height, width = screen_width})
exit_screen.bg = beautiful.wibar_bg or beautiful.xbackground.."CC" or "#111111"
exit_screen.fg = beautiful.wibar_fg or beautiful.xforeground or "#FEFEFE"
-- Create an container box
-- local exit_screen_box = wibox.container.background()
-- exit_screen_box.bg = exit_screen.bg
-- exit_screen_box.shape = gears.shape.rounded_rect
-- exit_screen_box.shape_border_radius = 20
local exit_screen_grabber
function exit_screen_hide()
awful.keygrabber.stop(exit_screen_grabber)
exit_screen.visible = false
end
function exit_screen_show()
-- naughty.notify({text = "starting the keygrabber"})
exit_screen_grabber = awful.keygrabber.run(function(_, key, event)
if event == "release" then return end
if key == 's' then
suspend_command()
-- 'e' for exit
elseif key == 'e' then
exit_command()
elseif key == 'l' then
lock_command()
elseif key == 'p' then
poweroff_command()
elseif key == 'r' then
reboot_command()
elseif key == 'Escape' or key == 'q' or key == 'x' then
-- naughty.notify({text = "Cancel"})
exit_screen_hide()
-- else awful.keygrabber.stop(exit_screen_grabber)
end
end)
exit_screen.visible = true
end
exit_screen:buttons(gears.table.join(
-- Middle click - Hide exit_screen
awful.button({ }, 2, function ()
exit_screen_hide()
end),
-- Right click - Hide exit_screen
awful.button({ }, 3, function ()
exit_screen_hide()
end)
))
-- Add clickable effect on hover
add_clickable_effect(poweroff)
add_clickable_effect(reboot)
add_clickable_effect(suspend)
add_clickable_effect(exit)
add_clickable_effect(lock)
-- Change color on hover
local function add_hover_color(w)
w:connect_signal("mouse::enter", function ()
w.markup = "<span foreground='" .. icon_hover_color .."'>" .. w.text .. "</span>"
end)
w:connect_signal("mouse::leave", function ()
w.markup = "<span foreground='" .. icon_normal_color .."'>" .. w.text .. "</span>"
end)
end
add_hover_color(poweroff_icon)
add_hover_color(reboot_icon)
add_hover_color(suspend_icon)
add_hover_color(exit_icon)
add_hover_color(lock_icon)
-- Item placement
exit_screen:setup {
nil,
{
{
nil,
goodbye_widget,
nil,
expand = "none",
layout = wibox.layout.align.horizontal
},
{
nil,
{
poweroff,
reboot,
suspend,
exit,
lock,
spacing = dpi(70),
layout = wibox.layout.fixed.horizontal
},
nil,
expand = "none",
layout = wibox.layout.align.horizontal
-- layout = wibox.layout.fixed.horizontal
},
spacing = dpi(30),
layout = wibox.layout.fixed.vertical
},
nil,
expand = "none",
layout = wibox.layout.align.vertical
}

View File

@ -0,0 +1,74 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
-- Set colors
local active_color = beautiful.ram_bar_active_color or "#5AA3CC"
local background_color = beautiful.ram_bar_background_color or "#222222"
-- Configuration
local update_interval = 20 -- in seconds
local ram_bar = wibox.widget{
max_value = 100,
value = 50,
forced_height = dpi(10),
margins = {
top = dpi(8),
bottom = dpi(8),
},
forced_width = dpi(200),
shape = gears.shape.rounded_bar,
bar_shape = gears.shape.rounded_bar,
color = active_color,
background_color = background_color,
border_width = 0,
border_color = beautiful.border_color,
widget = wibox.widget.progressbar,
}
-- Mouse control
-- ram_bar:buttons(gears.table.join(
-- --
-- awful.button({ }, 1, function ()
-- end),
-- --
-- awful.button({ }, 2, function ()
-- end),
-- --
-- awful.button({ }, 3, function ()
-- end),
-- --
-- awful.button({ }, 4, function ()
-- end),
-- awful.button({ }, 5, function ()
-- end)
-- ))
local function update_widget(used_ram_percentage)
ram_bar.value = used_ram_percentage
end
-- Signals
-- ram_bar:connect_signal("mouse::enter", function ()
-- update_widget()
-- end)
-- update_widget()
local used_ram_script = [[
bash -c "
free -m | grep 'Mem:' | awk '{printf \"%d@@%d@\", $7, $2}'
"]]
awful.widget.watch(used_ram_script, update_interval, function(widget, stdout)
local available = stdout:match('(.*)@@')
local total = stdout:match('@@(.*)@')
local used_ram_percentage = (total - available) / total * 100
update_widget(used_ram_percentage)
end)
return ram_bar

View File

@ -0,0 +1,393 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
local icons = require("icons.icons")
-- TODO replace this with spacing property
local function pad(size)
local str = ""
for i = 1, size do
str = str .. " "
end
local pad = wibox.widget.textbox(str)
return pad
end
-- Some commonly used variables
local icon_font = "Font Awesome 5 Free 22"
-- TODO clarify why width and height are reversed
local progress_bar_width = dpi(300)
local progress_bar_height = dpi(40)
-- local progress_bar_margins = dpi(9)
-- Helper function that changes the appearance of progress bars and their icons
local function format_progress_bar(bar, icon)
icon.font = icon_font
icon.align = "center"
icon.valign = "center"
bar.forced_width = progress_bar_width
bar.forced_height = progress_bar_height
bar.shape = gears.shape.rounded_bar
bar.bar_shape = gears.shape.rounded_bar
local w = wibox.widget{
{
{
bar,
widget = wibox.container.rotate,
direction = "east"
},
{
-- Force height to avoid cutting off some icons
forced_height = dpi(45),
widget = icon,
},
spacing = dpi(15),
layout = wibox.layout.fixed.vertical
},
nil,
expand = "none",
layout = wibox.layout.align.horizontal
}
return w
end
local archlabs_icon = wibox.widget.imagebox(icons.archlabs)
archlabs_icon.resize = true
archlabs_icon.forced_width = dpi(200)
archlabs_icon.forced_height = dpi(200)
local archlabs = wibox.widget {
-- Center archlabs_icon horizontally
nil,
archlabs_icon,
expand = "none",
layout = wibox.layout.align.horizontal
}
-- Item configuration
local exit_icon = wibox.widget.textbox()
exit_icon.markup = "<span foreground='" .. beautiful.xcolor4 .."'></span>"
exit_icon.font = "Font Awesome 5 Free 22"
exit_icon.align = "center"
exit_icon.valign = "center"
local exit_text = wibox.widget.textbox(" Logout")
exit_text.align = "center"
exit_text.valign = "center"
exit_text.font = "sans 16"
local exit = wibox.widget{
exit_icon,
exit_text,
-- Force height to avoid cutting off the icon
forced_height = dpi(35),
layout = wibox.layout.fixed.horizontal
}
exit:buttons(gears.table.join(
awful.button({ }, 1, function ()
exit_screen_show()
sidebar.visible = false
end)
))
add_clickable_effect(exit)
-- local weather_widget = require("archlabs-extras.weather")
-- local weather_widget_icon = weather_widget:get_all_children()[1]
-- weather_widget_icon.forced_width = icon_size
-- weather_widget_icon.forced_height = icon_size
-- local weather_widget_text = weather_widget:get_all_children()[2]
-- weather_widget_text.font = "sans 14"
-- Dummy weather_widget for testing
-- (avoid making requests with every awesome restart)
-- local weather_widget = wibox.widget.textbox("[i] bla bla bla!")
-- local weather = wibox.widget{
-- nil,
-- weather_widget,
-- nil,
-- layout = wibox.layout.align.horizontal,
-- expand = "none"
-- }
local temperature_icon = wibox.widget.textbox("")
local temperature_bar = require("archlabs-extras.temperature_bar")
local temperature = format_progress_bar(temperature_bar, temperature_icon)
local battery_icon = wibox.widget.textbox("")
awesome.connect_signal(
"charger_plugged", function(c)
battery_icon.image = beautiful.battery_charging_icon
end)
awesome.connect_signal(
"charger_unplugged", function(c)
battery_icon.image = beautiful.battery_icon
end)
local battery_bar = require("archlabs-extras.battery_bar")
local battery = format_progress_bar(battery_bar, battery_icon)
battery:buttons(
gears.table.join(
awful.button({ }, 1, function ()
local matcher = function (c)
return awful.rules.match(c, {class = 'Xfce4-power-manager-settings'})
end
awful.client.run_or_raise("xfce4-power-manager-settings", matcher)
end)
))
add_clickable_effect(battery)
local cpu_icon = wibox.widget.textbox("")
local cpu_bar = require("archlabs-extras.cpu_bar")
local cpu = format_progress_bar(cpu_bar, cpu_icon)
cpu:buttons(
gears.table.join(
awful.button({ }, 1, function ()
local matcher = function (c)
return awful.rules.match(c, {name = 'htop'})
end
awful.client.run_or_raise(terminal .." -e htop", matcher)
end),
awful.button({ }, 3, function ()
local matcher = function (c)
return awful.rules.match(c, {class = 'Lxtask'})
end
awful.client.run_or_raise("lxtask", matcher)
end)
))
local ram_icon = wibox.widget.textbox("")
local ram_bar = require("archlabs-extras.ram_bar")
local ram = format_progress_bar(ram_bar, ram_icon)
ram:buttons(
gears.table.join(
awful.button({ }, 1, function ()
local matcher = function (c)
return awful.rules.match(c, {name = 'htop'})
end
awful.client.run_or_raise(terminal .." -e htop", matcher)
end),
awful.button({ }, 3, function ()
local matcher = function (c)
return awful.rules.match(c, {class = 'Lxtask'})
end
awful.client.run_or_raise("lxtask", matcher)
end)
))
-- Time
local hours = wibox.widget.textclock("%H")
hours.font = "sans bold 55"
hours.align = "center"
hours.valign = "center"
local minutes = wibox.widget.textclock(" %M")
minutes.font = "sans 55"
minutes.align = "center"
minutes.valign = "center"
minutes.markup = "<span foreground='" .. beautiful.xcolor4 .."'>" .. minutes.text .. "</span>"
minutes:connect_signal("widget::redraw_needed", function ()
minutes.markup = "<span foreground='" .. beautiful.xcolor4 .."'>" .. minutes.text .. "</span>"
end)
local time = wibox.widget {
nil,
{
hours,
minutes,
layout = wibox.layout.fixed.horizontal
},
expand = "none",
layout = wibox.layout.align.horizontal
}
-- Date
local day_of_the_week = wibox.widget.textclock("%A")
day_of_the_week.font = "sans italic 20"
day_of_the_week.align = "center"
day_of_the_week.valign = "center"
day_of_the_week.markup = "<span foreground='" .. beautiful.xcolor4 .."'>" .. day_of_the_week.text .. "</span>"
day_of_the_week:connect_signal("widget::redraw_needed", function ()
day_of_the_week.markup = "<span foreground='" .. beautiful.xcolor4 .."'>" .. day_of_the_week.text .. "</span>"
end)
local day_of_the_month = wibox.widget.textclock(" %b %d")
day_of_the_month.font = "sans 20"
day_of_the_month.align = "center"
day_of_the_month.valign = "center"
local date = wibox.widget {
nil,
{
day_of_the_week,
day_of_the_month,
layout = wibox.layout.fixed.horizontal
},
expand = "none",
layout = wibox.layout.align.horizontal
}
local disk_space = require("archlabs-extras.disk")
disk_space.font = "sans 14"
local disk_icon = wibox.widget.imagebox(icons.archlabs)
disk_icon.resize = true
disk_icon.forced_width = icon_size
disk_icon.forced_height = icon_size
local disk = wibox.widget{
nil,
{
disk_icon,
disk_space,
layout = wibox.layout.fixed.horizontal
},
nil,
expand = "none",
layout = wibox.layout.align.horizontal
}
disk:buttons(gears.table.join(
awful.button({ }, 1, function ()
awful.spawn(file_manager, {floating = true})
end)
))
local volume_icon = wibox.widget.textbox("")
local volume_bar = require("archlabs-extras.volume_bar")
volume = format_progress_bar(volume_bar, volume_icon)
volume:buttons(gears.table.join(
-- Left click - Mute / Unmute
awful.button({ }, 1, function ()
awful.spawn.with_shell("pamixer -t")
end),
-- Right click - Run or raise pavucontrol
awful.button({ }, 3, function ()
local matcher = function (c)
return awful.rules.match(c, {class = 'Pavucontrol'})
end
awful.client.run_or_raise("pavucontrol", matcher)
end),
-- Scroll - Increase / Decrease volume
awful.button({ }, 4, function ()
awful.spawn.with_shell("pamixer -i 2")
end),
awful.button({ }, 5, function ()
awful.spawn.with_shell("pamixer -d 2")
end)
))
add_clickable_effect(volume)
-- }}}
-- Create the sidebar
sidebar = wibox({x = 0, y = 0, visible = false, ontop = true, type = "dock"})
sidebar.bg = beautiful.sidebar_bg or beautiful.wibar_bg or "#111111"
sidebar.fg = beautiful.sidebar_fg or beautiful.wibar_fg or "#FFFFFF"
sidebar.opacity = beautiful.sidebar_opacity or 1
sidebar.height = beautiful.sidebar_height or awful.screen.focused().geometry.height
sidebar.width = beautiful.sidebar_width or dpi(300)
sidebar.y = beautiful.sidebar_y or 0
if beautiful.sidebar_position == "right" then
sidebar.x = awful.screen.focused().geometry.width - sidebar.width
else
sidebar.x = beautiful.sidebar_x or 0
end
sidebar:buttons(gears.table.join(
-- Middle click - Hide sidebar
awful.button({ }, 2, function ()
sidebar.visible = false
end)
-- Right click - Hide sidebar
-- awful.button({ }, 3, function ()
-- sidebar.visible = false
-- -- mymainmenu:show()
-- end)
))
-- Hide sidebar when mouse leaves
if beautiful.sidebar_hide_on_mouse_leave then
sidebar:connect_signal("mouse::leave", function ()
sidebar.visible = false
end)
end
-- Activate sidebar by moving the mouse at the edge of the screen
if beautiful.sidebar_hide_on_mouse_leave then
local sidebar_activator = wibox({y = sidebar.y, width = 1, visible = true, ontop = false, opacity = 0, below = true})
sidebar_activator.height = sidebar.height
-- sidebar_activator.height = sidebar.height - beautiful.wibar_height
sidebar_activator:connect_signal("mouse::enter", function ()
sidebar.visible = true
end)
if beautiful.sidebar_position == "right" then
sidebar_activator.x = awful.screen.focused().geometry.width - sidebar_activator.width
else
sidebar_activator.x = 0
end
sidebar_activator:buttons(
gears.table.join(
-- awful.button({ }, 2, function ()
-- start_screen_show()
-- -- sidebar.visible = not sidebar.visible
-- end),
awful.button({ }, 4, function ()
awful.tag.viewprev()
end),
awful.button({ }, 5, function ()
awful.tag.viewnext()
end)
))
end
-- Item placement
sidebar:setup {
{ ----------- TOP GROUP -----------
pad(1),
pad(1),
archlabs,
pad(1),
time,
date,
-- pad(1),
-- weather,
pad(1),
pad(1),
layout = wibox.layout.fixed.vertical
},
{ ----------- MIDDLE GROUP -----------
pad(1),
pad(1),
{ -- Center bars horizontally
nil,
{
volume,
cpu,
temperature,
ram,
battery,
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
expand = "none",
layout = wibox.layout.align.horizontal,
},
-- disk,
layout = wibox.layout.fixed.vertical
},
{ ----------- BOTTOM GROUP -----------
{ -- Logout button
nil,
exit,
layout = wibox.layout.align.horizontal,
expand = "none"
},
pad(1),
pad(1),
layout = wibox.layout.fixed.vertical
},
layout = wibox.layout.align.vertical,
-- expand = "none"
}

View File

@ -0,0 +1,58 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
-- Configuration
local update_interval = 15 -- in seconds
local temperature = wibox.widget{
text = "?? °C",
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
}
-- Mouse control
-- temperature:buttons(gears.table.join(
-- --
-- awful.button({ }, 1, function ()
-- end),
-- --
-- awful.button({ }, 2, function ()
-- end),
-- --
-- awful.button({ }, 3, function ()
-- end),
-- --
-- awful.button({ }, 4, function ()
-- end),
-- awful.button({ }, 5, function ()
-- end)
-- ))
local function update_widget(temp)
temperature.markup = temp
-- temperature.markup = temp .. "°C"
end
-- Signals
-- temperature:connect_signal("mouse::enter", function ()
-- update_widget()
-- end)
-- update_widget()
local temp_script = [[
bash -c "
sensors | grep Package | awk '{print $4}' | cut -c 2-3,6-8
"]]
awful.widget.watch(temp_script, update_interval, function(widget, stdout)
-- local temp = stdout:match('+(.*)%.%d...(.*)%(')
local temp = stdout
temp = string.gsub(temp, '^%s*(.-)%s*$', '%1')
update_widget(temp)
end)
return temperature

View File

@ -0,0 +1,72 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
-- Set colors
local active_color = beautiful.temperature_bar_active_color or "#5AA3CC"
local background_color = beautiful.temperature_bar_background_color or "#222222"
-- Configuration
local update_interval = 15 -- in seconds
local temperature_bar = wibox.widget{
max_value = 100,
value = 50,
forced_height = dpi(10),
margins = {
top = dpi(8),
bottom = dpi(8),
},
forced_width = dpi(200),
shape = gears.shape.rounded_bar,
bar_shape = gears.shape.rounded_bar,
color = active_color,
background_color = background_color,
border_width = 0,
border_color = beautiful.border_color,
widget = wibox.widget.progressbar,
}
-- Mouse control
-- temperature_bar:buttons(gears.table.join(
-- --
-- awful.button({ }, 1, function ()
-- end),
-- --
-- awful.button({ }, 2, function ()
-- end),
-- --
-- awful.button({ }, 3, function ()
-- end),
-- --
-- awful.button({ }, 4, function ()
-- end),
-- awful.button({ }, 5, function ()
-- end)
-- ))
local function update_widget(temp)
temperature_bar.value = tonumber(temp)
end
-- Signals
-- temperature_bar:connect_signal("mouse::enter", function ()
-- update_widget()
-- end)
-- update_widget()
local temp_script = [[
bash -c "
sensors | grep Package | awk '{print $4}' | cut -c 2-3
"]]
awful.widget.watch(temp_script, update_interval, function(widget, stdout)
local temp = stdout
update_widget(temp)
end)
return temperature_bar

View File

@ -0,0 +1,72 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
-- Set colors
local active_color = beautiful.volume_bar_active_color or "#5AA3CC"
local muted_color = beautiful.volume_bar_muted_color or "#666666"
local active_background_color = beautiful.volume_bar_active_background_color or "#222222"
local muted_background_color = beautiful.volume_bar_muted_background_color or "#222222"
local volume_bar = wibox.widget{
max_value = 100,
value = 50,
forced_height = dpi(10),
margins = {
top = dpi(8),
bottom = dpi(8),
},
forced_width = dpi(200),
shape = gears.shape.rounded_bar,
bar_shape = gears.shape.rounded_bar,
color = active_color,
background_color = active_background_color,
border_width = 0,
border_color = beautiful.border_color,
widget = wibox.widget.progressbar,
}
local function update_widget()
awful.spawn.easy_async({"sh", "-c", "pactl list sinks"},
function(stdout)
local volume = stdout:match('(%d+)%% /')
local muted = stdout:match('Mute:(%s+)[yes]')
local fill_color
local bg_color
if muted ~= nil then
fill_color = muted_color
bg_color = muted_background_color
else
fill_color = active_color
bg_color = active_background_color
end
volume_bar.value = tonumber(volume)
volume_bar.color = fill_color
volume_bar.background_color = bg_color
end
)
end
update_widget()
-- Sleeps until pactl detects an event (volume up/down/toggle mute)
local volume_script = [[
bash -c '
pactl subscribe 2> /dev/null | grep --line-buffered "sink #0"
']]
-- Kill old pactl subscribe process
awful.spawn.easy_async_with_shell("ps x | grep \"pactl subscribe\" | grep -v grep | awk '{print $1}' | xargs kill", function ()
-- Update volume with each line printed
awful.spawn.with_line_callback(volume_script, {
stdout = function(line)
update_widget()
end
})
end)
return volume_bar