Add config files for awesomewm, alacritty, picom and rofi

This commit is contained in:
crylia
2021-09-12 22:59:41 +02:00
commit b380e753b1
94 changed files with 4445 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
-------------------------------------------------------------
-- This is a button widget to add a new tag to the taglist --
-------------------------------------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- User Libs
local color = require("theme.crylia.colors")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "theme/crylia/assets/icons/addtag/"
-- Returns the add tag button widget
return function ()
-- This is the widget that gets dispayed
local add_tag_button = wibox.widget{
{
{
image = gears.color.recolor_image(icondir .. "plus.svg", color.color["White"]),
widget = wibox.widget.imagebox,
resize = false
},
margins = dpi(4),
widget = wibox.container.margin
},
bg = color.color["Grey900"],
shape = function (cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.container.background
}
-- Keybindings and Mouse click bindings
add_tag_button:buttons(
gears.table.join(
-- Add a new tag
awful.button(
{ },
1,
nil,
function ()
awful.tag.add()
end
)
)
)
-- Signals
local old_wibox, old_cursor, old_bg
add_tag_button:connect_signal(
"mouse::enter",
function ()
old_bg = add_tag_button.bg
add_tag_button.bg = "#ffffff" .. "12"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
add_tag_button:connect_signal(
"button::press",
function ()
add_tag_button.bg = "#ffffff" .. "24"
end
)
add_tag_button:connect_signal(
"button::release",
function ()
add_tag_button.bg = "#ffffff" .. "12"
end
)
add_tag_button:connect_signal(
"mouse::leave",
function ()
add_tag_button.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
return add_tag_button
end

View File

@@ -0,0 +1,156 @@
------------------------------
-- This is the audio widget --
------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("theme.crylia.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "theme/crylia/assets/icons/audio/"
-- Returns the audio widget
return function ()
local audio_widget = wibox.widget{
{
{
{
{
{
id = "icon",
widget = wibox.widget.imagebox,
resize = false
},
id = "icon_layout",
widget = wibox.container.place
},
top = dpi(2),
widget = wibox.container.margin,
id = "icon_margin"
},
spacing = dpi(6),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "audio_layout",
layout = wibox.layout.fixed.horizontal
},
id = "container",
left = dpi(5),
right = dpi(10),
widget = wibox.container.margin
},
bg = color.color["Yellow200"],
fg = color.color["Grey900"],
shape = function (cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.widget.background
}
local get_volume = function ()
awful.spawn.easy_async_with_shell(
[[ awk -F"[][]" '/dB/ { print $2 }' <(amixer sget Master) ]],
function (stdout)
local icon = icondir .. "volume"
stdout = stdout:gsub("%%", "")
local volume = tonumber(stdout) or 0
audio_widget.container.audio_layout.spacing = dpi(5)
audio_widget.container.audio_layout.label.visible = true
if volume < 1 then
icon = icon .. "-mute"
audio_widget.container.audio_layout.spacing = dpi(0)
audio_widget.container.audio_layout.label.visible = false
elseif volume >= 1 and volume < 34 then
icon = icon .. "-low"
elseif volume >= 34 and volume < 67 then
icon = icon .. "-medium"
elseif volume >= 67 then
icon = icon .. "-high"
end
audio_widget.container.audio_layout.label:set_text(volume .. "%")
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icon .. ".svg", color.color["Grey900"]))
end
)
end
local check_muted = function ()
awful.spawn.easy_async_with_shell(
[[ awk -F"[][]" '/dB/ { print $6 }' <(amixer sget Master) ]],
function (stdout)
if stdout:match("off") then
audio_widget.container.audio_layout.label.visible = false
audio_widget.container:set_right(0)
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. "volume-mute" .. ".svg", color.color["Grey900"]))
else
audio_widget.container:set_right(10)
get_volume()
end
end
)
end
-- Signals
local old_wibox, old_cursor, old_bg
audio_widget:connect_signal(
"mouse::enter",
function ()
old_bg = audio_widget.bg
audio_widget.bg = color.color["Yellow200"] .. "dd"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
audio_widget:connect_signal(
"button::press",
function ()
audio_widget.bg = color.color["Yellow200"] .. "bb"
end
)
audio_widget:connect_signal(
"button::release",
function ()
audio_widget.bg = color.color["Yellow200"] .. "dd"
end
)
audio_widget:connect_signal(
"mouse::leave",
function ()
audio_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
audio_widget:connect_signal(
"button::press",
function ()
awesome.emit_signal("module::volume_osd:show", true)
end
)
awesome.connect_signal(
"widget::volume",
function (c)
check_muted()
end
)
check_muted()
return audio_widget
end

View File

@@ -0,0 +1,238 @@
--------------------------------
-- This is the battery widget --
--------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("theme.crylia.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local naughty = require("naughty")
local watch = awful.widget.watch
local wibox = require("wibox")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "theme/crylia/assets/icons/battery/"
-- Returns the battery widget
return function ()
local battery_widget = wibox.widget{
{
{
{
{
{
id = "icon",
image = gears.color.recolor_image(icondir .. "battery-unknown.svg", "#212121"),
widget = wibox.widget.imagebox,
resize = false
},
id = "icon_layout",
widget = wibox.container.place
},
id = "icon_margin",
top = dpi(2),
widget = wibox.container.margin
},
spacing = dpi(8),
{
visible = false,
align = 'center',
valign = 'center',
id = "label",
widget = wibox.widget.textbox
},
id = "battery_layout",
layout = wibox.layout.fixed.horizontal
},
id = "container",
left = dpi(5),
right = dpi(10),
widget = wibox.container.margin
},
bg = color.color["Purple200"],
fg = color.color["Grey900"],
shape = function (cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.widget.background
}
local battery_tooltip = awful.tooltip{
objects = {battery_widget},
text = "",
mode = "inside",
align = "right",
margins = dpi(10)
}
local get_battery_info = function ()
awful.spawn.easy_async_with_shell(
[[ upower -i $(upower -e | grep BAT) | grep "time to " ]],
function (stdout)
if stdout == nil or stdout == '' then
battery_tooltip:set_text('No Battery Found')
return
end
local rem_time = ""
if stdout:match("hour") then
rem_time = "Hours"
else
rem_time = "Minutes"
end
if stdout:match("empty") then
battery_tooltip:set_text("Remaining battery time: " .. stdout:match("%d+,%d") .. " " .. rem_time)
elseif stdout:match("time to full") then
battery_tooltip:set_text("Battery fully charged in: " .. stdout:match("%d+,%d") .. " " .. rem_time)
end
end
)
end
get_battery_info()
local last_battery_check = os.time()
local notify_critical_battery = true
local battery_warning = function ()
naughty.notify({
icon = gears.color.recolor_image(icondir .. "battery-alert.svg", color.color["White"]),
app_name = "System notification",
title = "Battery is low",
message = "Battery is almost battery_labelempty",
urgency = "critical"
})
end
local update_battery = function (status)
awful.spawn.easy_async_with_shell(
[[sh -c "upower -i $(upower -e | grep BAT) | grep percentage | awk '{print \$2}' |tr -d '\n%'"]],
function (stdout)
local battery_percentage = tonumber(stdout)
if not battery_percentage then
return
end
battery_widget.container.battery_layout.spacing = dpi(5)
battery_widget.container.battery_layout.label.visible = true
battery_widget.container.battery_layout.label:set_text(battery_percentage .. '%')
local icon = 'battery'
if status == 'fully-charged' or status == 'charging' and battery_percentage == 100 then
icon = icon .. '-' .. 'charging'
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121")))
return
end
if battery_percentage > 0 and battery_percentage < 10 and status == 'discharging' then
icon = icon .. '-' .. 'alert'
if(os.difftime(os.time(), last_battery_check) > 300 or notify_critical_battery) then
last_battery_check = os.time()
notify_critical_battery = false
battery_warning()
end
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121")))
return
end
if battery_percentage > 0 and battery_percentage < 10 then
icon = icon .. '-' .. status .. '-' .. 'outline'
elseif battery_percentage >= 10 and battery_percentage < 20 then
icon = icon .. '-' .. status .. '-' .. '10'
elseif battery_percentage >= 20 and battery_percentage < 30 then
icon = icon .. '-' .. status .. '-' .. '20'
elseif battery_percentage >= 30 and battery_percentage < 40 then
icon = icon .. '-' .. status .. '-' .. '30'
elseif battery_percentage >= 40 and battery_percentage < 50 then
icon = icon .. '-' .. status .. '-' .. '40'
elseif battery_percentage >= 50 and battery_percentage < 60 then
icon = icon .. '-' .. status .. '-' .. '50'
elseif battery_percentage >= 60 and battery_percentage < 70 then
icon = icon .. '-' .. status .. '-' .. '60'
elseif battery_percentage >= 70 and battery_percentage < 80 then
icon = icon .. '-' .. status .. '-' .. '70'
elseif battery_percentage >= 80 and battery_percentage < 90 then
icon = icon .. '-' .. status .. '-' .. '80'
elseif battery_percentage >=90 and battery_percentage < 100 then
icon = icon .. '-' .. status .. '-' .. '90'
end
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121")))
end
)
end
local old_wibox, old_cursor, old_bg
battery_widget:connect_signal(
"mouse::enter",
function ()
old_bg = battery_widget.bg
battery_widget.bg = color.color["Purple200"] .. "dd"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
-- Signals
battery_widget:connect_signal(
"button::press",
function ()
battery_widget.bg = color.color["Purple200"] .. "bb"
end
)
battery_widget:connect_signal(
"button::release",
function ()
battery_widget.bg = color.color["Purple200"] .. "dd"
end
)
battery_widget:connect_signal(
"mouse::leave",
function ()
battery_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
battery_widget:connect_signal(
'button::press',
function ()
awful.spawn("xfce4-power-manager-settings")
end
)
battery_widget:connect_signal(
"mouse::enter",
function ()
get_battery_info()
end
)
watch(
[[sh -c "upower -i $(upower -e | grep BAT) | grep state | awk '{print \$2}' | tr -d '\n'"]],
5,
function (widget, stdout)
local status = stdout:gsub('%\n', '')
if status == nil or status == '' then
battery_widget.container.battery_layout.spacing = dpi(0)
battery_widget.container.battery_layout.label.visible = false
battery_tooltip:set_text('No battery found')
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. 'battery-off' .. '.svg', "#212121")))
end
update_battery(status)
end
)
return battery_widget
end

View File

@@ -0,0 +1,155 @@
----------------------------------
-- This is the bluetooth widget --
----------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("theme.crylia.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "theme/crylia/assets/icons/bluetooth/"
-- Returns the bluetooth widget
return function ()
local bluetooth_widget = wibox.widget{
{
{
{
id = "icon",
image = gears.color.recolor_image(icondir .. "bluetooth-off.svg"),
widget = wibox.widget.imagebox,
resize = false
},
id = "icon_layout",
widget = wibox.container.place
},
id = "icon_margin",
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin
},
bg = color.color["Blue200"],
fg = color.color["Grey900"],
shape = function (cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.widget.background
}
local bluetooth_tooltip = awful.tooltip{
objects = {bluetooth_widget},
text = "",
mode = "inside",
align = "right",
margins = dpi(10)
}
local bluetooth_state = "off"
local connected_device = "nothing"
local get_bluetooth_information = function ()
awful.spawn.easy_async_with_shell(
[[ bluetoothctl show | grep Powered | awk '{print $2}' ]],
function (stdout)
local icon = icondir .. "bluetooth"
stdout = stdout:gsub("\n", "")
if stdout == "yes" then
icon = icon .. "-on"
bluetooth_state = "on"
awful.spawn.easy_async_with_shell(
[[ bluetoothctl info | grep Name: | awk '{ first = $1; $1 = ""; print $0 }' ]],
function (stdout2)
if stdout2 == nil or stdout2:gsub("\n", "") == "" then
bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently not connected")
else
bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently connected to:" .. connected_device)
connected_device = stdout2
end
end
)
else
icon = icon .. "-off"
bluetooth_state = "off"
bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n")
end
bluetooth_widget.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icon .. ".svg", color.color["Grey900"]))
end
)
end
local bluetooth_update = gears.timer{
timeout = 5,
autostart = true,
call_now = true,
callback = function ()
get_bluetooth_information()
end
}
-- Signals
local old_wibox, old_cursor, old_bg
bluetooth_widget:connect_signal(
"mouse::enter",
function ()
old_bg = bluetooth_widget.bg
bluetooth_widget.bg = color.color["Blue200"] .. "dd"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
bluetooth_widget:connect_signal(
"button::press",
function ()
bluetooth_widget.bg = color.color["Blue200"] .. "bb"
end
)
bluetooth_widget:connect_signal(
"button::release",
function ()
bluetooth_widget.bg = color.color["Blue200"] .. "dd"
end
)
bluetooth_widget:connect_signal(
"mouse::leave",
function ()
bluetooth_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
bluetooth_widget:connect_signal(
"button::press",
function ()
if bluetooth_state == "on" then
awful.spawn.easy_async_with_shell(
"bluetoothctl power off",
function (stdout)
get_bluetooth_information()
end
)
else
awful.spawn.easy_async_with_shell(
"bluetoothctl power on",
function (stdout)
get_bluetooth_information()
end
)
end
end
)
get_bluetooth_information()
return bluetooth_widget
end

View File

@@ -0,0 +1,115 @@
------------------------------
-- This is the clock widget --
------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("theme.crylia.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "theme/crylia/assets/icons/clock/"
-- Returns the clock widget
return function ()
local clock_widget = wibox.widget{
{
{
{
{
{
id = "icon",
image = gears.color.recolor_image(icondir .. "clock.svg", color.color["Grey900"]),
widget = wibox.widget.imagebox,
resize = false
},
id = "icon_layout",
widget = wibox.container.place
},
id = "icon_margin",
top = dpi(2),
widget = wibox.container.margin
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "clock_layout",
layout = wibox.layout.fixed.horizontal
},
id = "container",
left = dpi(10),
right = dpi(10),
widget = wibox.container.margin
},
bg = color.color["Orange200"],
fg = color.color["Grey900"],
shape = function (cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.widget.background
}
local set_clock = function ()
clock_widget.container.clock_layout.label:set_text(os.date("%H:%M"))
end
-- Updates the clock every 5 seconds, worst case you are 5 seconds behind
-- ¯\_(ツ)_/¯
local clock_update = gears.timer {
timeout = 5,
autostart = true,
call_now = true,
callback = function ()
set_clock()
end
}
-- Signals
local old_wibox, old_cursor, old_bg
clock_widget:connect_signal(
"mouse::enter",
function ()
old_bg = clock_widget.bg
clock_widget.bg = color.color["Orange200"] .. "dd"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
clock_widget:connect_signal(
"button::press",
function ()
clock_widget.bg = color.color["Orange200"] .. "bb"
end
)
clock_widget:connect_signal(
"button::release",
function ()
clock_widget.bg = color.color["Orange200"] .. "dd"
end
)
clock_widget:connect_signal(
"mouse::leave",
function ()
clock_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
return clock_widget
end

View File

@@ -0,0 +1,114 @@
-----------------------------
-- This is the date widget --
-----------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("theme.crylia.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "theme/crylia/assets/icons/date/"
-- Returns the date widget
return function ()
local date_widget = wibox.widget{
{
{
{
{
{
id = "icon",
image = gears.color.recolor_image(icondir .. "calendar.svg", color.color["Grey900"]),
widget = wibox.widget.imagebox,
resize = false
},
id = "icon_layout",
widget = wibox.container.place
},
id = "icon_margin",
top = dpi(2),
widget = wibox.container.margin
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "date_layout",
layout = wibox.layout.fixed.horizontal
},
id = "container",
left = dpi(10),
right = dpi(10),
widget = wibox.container.margin
},
bg = color.color["Teal200"],
fg = color.color["Grey900"],
shape = function (cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.widget.background
}
local set_date = function ()
date_widget.container.date_layout.label:set_text(os.date("%a, %b %d"))
end
-- Updates the date every minute, dont blame me if you miss silvester
local date_updater = gears.timer {
timeout = 60,
autostart = true,
call_now = true,
callback = function ()
set_date()
end
}
-- Signals
local old_wibox, old_cursor, old_bg
date_widget:connect_signal(
"mouse::enter",
function ()
old_bg = date_widget.bg
date_widget.bg = color.color["Teal200"] .. "dd"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
date_widget:connect_signal(
"button::press",
function ()
date_widget.bg = color.color["Teal200"] .. "bb"
end
)
date_widget:connect_signal(
"button::release",
function ()
date_widget.bg = color.color["Teal200"] .. "dd"
end
)
date_widget:connect_signal(
"mouse::leave",
function ()
date_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
return date_widget
end

View File

@@ -0,0 +1,70 @@
----------------------------------
-- This is the layoutbox widget --
----------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("theme.crylia.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- Returns the layoutbox widget
return function ()
local layout = wibox.widget{
{
awful.widget.layoutbox(),
margins = dpi(3),
forced_width = dpi(33),
widget = wibox.container.margin
},
bg = color.color["LightBlue200"],
shape = function (cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.container.background
}
-- Signals
local old_wibox, old_cursor, old_bg
layout:connect_signal(
"mouse::enter",
function ()
old_bg = layout.bg
layout.bg = color.color["LightBlue200"] .. "dd"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
layout:connect_signal(
"button::press",
function ()
layout.bg = color.color["LightBlue200"] .. "bb"
end
)
layout:connect_signal(
"button::release",
function ()
layout.bg = color.color["LightBlue200"] .. "dd"
end
)
layout:connect_signal(
"mouse::leave",
function ()
layout.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
return layout
end

View File

@@ -0,0 +1,373 @@
--------------------------------
-- This is the network widget --
--------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("theme.crylia.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local naughty = require("naughty")
local wibox = require("wibox")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "theme/crylia/assets/icons/network/"
-- Insert your interfaces here, get the from ip a
local interfaces = {
wlan_interface = "wlo1",
lan_interface = "enx00e04c89ce6f"
}
local network_mode = nil
-- Returns the network widget
return function ()
local startup = true
local reconnect_startup = true
local network_widget = wibox.widget{
{
{
{
{
{
id = 'icon',
image = gears.color.recolor_image(icondir .. "no-internet" .. ".svg", color.color["Grey900"]),
widget = wibox.widget.imagebox,
resize = false
},
id = "icon_layout",
widget = wibox.container.place
},
id = "icon_margin",
top = dpi(2),
widget = wibox.container.margin
},
spacing = dpi(8),
{
id = "label",
visible = false,
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
id = "network_layout",
layout = wibox.layout.fixed.horizontal
},
id = "container",
left = dpi(10),
right = dpi(10),
widget = wibox.container.margin
},
bg = color.color["Red200"],
fg = color.color["Grey900"],
shape = function (cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.widget.background
}
local network_tooltip = awful.tooltip{
text = "Loading",
objects = {network_widget},
mode = "inside",
align = "right",
margins = dpi(10)
}
local check_for_internet = [=[
status_ping=0
packets="$(ping -q -w2 -c2 1.1.1.1 | grep -o "100% packet loss")"
if [ ! -z "${packets}" ];
then
status_ping=0
else
status_ping=1
fi
if [ $status_ping -eq 0 ];
then
echo "Connected but no internet"
fi
]=]
local update_startup = function ()
if startup then
startup = false
end
end
local update_reconnect_startup = function (status)
reconnect_startup = status
end
local update_tooltip = function (message)
network_tooltip:set_markup(message)
end
local network_notify = function (message, title, app_name, icon)
naughty.notify({
text = message,
title = title,
app_name = app_name,
icon = gears.color.recolor_image(icon, color.color["White"]),
timeout = 3
})
end
local update_wireless = function ()
network_mode = "wireless"
local notify_connected = function (essid)
local message = "You are now connected to ".. essid
local title = "Connection successfull"
local app_name = "System Notification"
local icon = icondir .. "wifi-strength-4.svg"
network_notify(message, title, app_name, icon)
end
local update_wireless_data = function (strength, healthy)
awful.spawn.easy_async_with_shell(
[[ iw dev ]] .. interfaces.wlan_interface .. [[ link ]],
function (stdout)
local essid = stdout:match("SSID: (.-)\n") or "N/A"
local bitrate = stdout: match("tx bitrate: (.+/s)") or "N/A"
local message = "Connected to <b>" .. essid .. "</b>\nSignal strength <b>" .. tostring(wifi_strength) .. "%</b>\n" .. "Bit rate <b>" .. tostring(bitrate) .. "</b>"
if healthy then
update_tooltip(message)
else
update_tooltip("You are connected but have no internet" .. message)
end
if reconnect_startup or startup then
notify_connected(essid)
update_reconnect_startup(false)
end
end
)
end
local update_wireless_icon = function (strength)
awful.spawn.easy_async_with_shell(
check_for_internet,
function (stdout)
local icon = "wifi-strength"
if not stdout:match("Connected but no internet") then
if startup or reconnect_startup then
awesome.emit_signal("system::network_connected")
end
icon = icon .. '-' .. tostring(strength)
update_wireless_data(wifi_strength_rounded, true)
else
icon = icon .. "-" .. tostring(strength)
update_wireless_data(wifi_strength_rounded, false)
end
network_widget.container.network_layout.spacing = dpi(8)
network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. icon .. ".svg", color.color["Grey900"]))
end
)
end
local update_wireless_strength = function ()
awful.spawn.easy_async_with_shell(
[[ awk 'NR==3 {printf "%3.0f", ($3/70)*100}' /proc/net/wireless ]],
function (stdout)
if not tonumber(stdout) then
return
end
wifi_strength = tonumber(stdout)
network_widget.container.network_layout.spacing = dpi(10)
network_widget.container.network_layout.label.visible = true
network_widget.container.network_layout.label:set_text(tostring(wifi_strength))
local wifi_strength_rounded = math.floor(wifi_strength / 25 + 0.5)
update_wireless_icon(wifi_strength_rounded)
end
)
end
update_wireless_strength()
update_startup()
end
local update_wired = function ()
network_mode = "wired"
local notify_connected = function ()
local message = "You are now connected to ".. interfaces.lan_interface
local title = "Connection successfull"
local app_name = "System Notification"
local icon = icondir .. "ethernet.svg"
network_notify(message, title, app_name, icon)
end
awful.spawn.easy_async_with_shell(
check_for_internet,
function (stdout)
local icon = "ethernet"
if stdout:match("Connected but no internet") then
icon = "no-internet"
update_tooltip(
"No internet"
)
else
update_tooltip("You are connected to:\nEthernet Interface <b>" .. interfaces.lan_interface .. "</b>")
if startup or reconnect_startup then
awesome.emit_signal("system::network_connected")
notify_connected()
update_startup()
end
update_reconnect_startup(false)
end
network_widget.container.network_layout.label.visible = false
network_widget.container.network_layout.spacing = dpi(0)
network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(icondir .. icon .. ".svg")
end
)
end
local update_disconnected = function ()
local notify_wireless_disconnected = function (essid)
local message = "WiFi has been disconnected"
local title = "Connection lost"
local app_name = "System Notification"
local icon = icondir .. "wifi-strength-off-outline.svg"
network_notify(message, title, app_name, icon)
end
local notify_wired_disconnected = function (essid)
local message = "Ethernet has been unplugged"
local title = "Connection lost"
local app_name = "System Notification"
local icon = icondir .. "no-internet.svg"
network_notify(message, title, app_name, icon)
end
local icon = "wifi-strength-off-outline"
if network_mode == "wireless" then
icon = "wifi-strength-off-outline"
if not reconnect_startup then
update_reconnect_startup(true)
notify_wireless_disconnected()
end
elseif network_mode == "wired" then
icon = "no-internet"
if not reconnect_startup then
update_reconnect_startup(true)
notify_wired_disconnected()
end
end
network_widget.container.network_layout.label.visible = false
update_tooltip("Network unreachable")
network_widget.test.test2.spacing = dpi(0)
network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. icon .. ".svg", color.color["Grey900"]))
end
local check_network_mode = function ()
awful.spawn.easy_async_with_shell(
[=[
wireless="]=] .. tostring(interfaces.wlan_interface) .. [=["
wired="]=] .. tostring(interfaces.lan_interface) .. [=["
net="/sys/class/net/"
wireless_state="down"
wired_state="down"
network_mode=""
function check_network_state(){
if [[ "${wireless_state}" == "up" ]];
then
network_mode="wireless"
elif [[ "${wired_state}" == "up" ]];
then
network_mode="wired"
else
network_mode="No internet connected"
fi
}
function check_network_directory(){
if [[ -n "${wireless}" && -d "${net}${wireless}" ]];
then
wireless_state="$(cat "${net}${wireless}/operstate")"
fi
if [[ -n "${wired}" && -d "${net}${wired}" ]];
then
wired_state="$(cat "${net}${wired}/operstate")"
fi
check_network_state
}
function print_network_mode(){
check_network_directory
print "${network_mode}"
}
print_network_mode
]=],
function (stdout)
local mode = stdout:gsub("%\n", "")
if stdout:match("No internet connected") then
update_disconnected()
elseif stdout:match("wireless") then
update_wireless()
elseif stdout:match("wired") then
update_wired()
end
end
)
end
local network_updater = gears.timer{
timeout = 5,
autostart = true,
call_now = true,
callback = function ()
check_network_mode()
end
}
-- Signals
local old_wibox, old_cursor, old_bg
network_widget:connect_signal(
"mouse::enter",
function ()
old_bg = network_widget.bg
network_widget.bg = color.color["Red200"] .. "dd"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
network_widget:connect_signal(
"button::press",
function ()
network_widget.bg = color.color["Red200"] .. "bb"
end
)
network_widget:connect_signal(
"button::release",
function ()
network_widget.bg = color.color["Red200"] .. "dd"
end
)
network_widget:connect_signal(
"mouse::leave",
function ()
network_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
network_widget:connect_signal(
"button::press",
function ()
awful.spawn("gnome-control-center wlan")
end
)
return network_widget
end

View File

@@ -0,0 +1,216 @@
local wibox = require("wibox")
local awful = require("awful")
local gears = require("gears")
local dpi = require("beautiful").xresources.apply_dpi
local color = require("theme.crylia.colors")
local list_update = function (widget, buttons, label, data, objects)
widget:reset()
for i, object in ipairs(objects) do
local tag_icon = wibox.widget{
nil,
{
id = "icon",
resize = true,
widget = wibox.widget.imagebox
},
nil,
layout = wibox.layout.align.horizontal
}
local tag_icon_margin = wibox.widget{
tag_icon,
forced_width = dpi(33),
margins = dpi(3),
widget = wibox.container.margin
}
local tag_label = wibox.widget{
text = "",
align = "center",
valign = "center",
visible = true,
font = "JetBrains Mono ExtraBold, 14",
forced_width = dpi(25),
widget = wibox.widget.textbox
}
local tag_label_margin = wibox.widget{
tag_label,
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin
}
local tag_widget = wibox.widget {
{
id = "widget_margin",
{
id = "container",
tag_label_margin,
--tag_icon_margin,
layout = wibox.layout.fixed.horizontal
},
margins = dpi(0),
widget = wibox.container.margin
},
fg = color.color["White"],
shape = function (cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.widget.background
}
tag_widget:buttons(buttons, object)
--local text, bg_color, bg_image, icon, args = label(object, tag_label)
tag_label:set_text(i)
if object == awful.screen.focused().selected_tag then
tag_widget:set_bg(color.color["White"])
tag_widget:set_fg(color.color["Grey900"])
else
tag_widget:set_bg("#3A475C")
end
for _, client in ipairs(object:clients()) do
if client.icon then
tag_label_margin:set_right(0)
local icon = wibox.widget{
{
id = "icon_container",
{
id = "icon",
resize = true,
widget = wibox.widget.imagebox
},
widget = wibox.container.place
},
tag_icon,
forced_width = dpi(33),
margins = dpi(6),
widget = wibox.container.margin
}
icon.icon_container.icon:set_image(client.icon)
tag_widget.widget_margin.container:setup({
icon,
layout = wibox.layout.align.horizontal
})
else
tag_icon_margin:set_margins(0)
tag_icon:set_forced_width(0)
end
end
local old_wibox, old_cursor, old_bg
tag_widget:connect_signal(
"mouse::enter",
function ()
old_bg = tag_widget.bg
tag_widget.bg = "#3A475C" .. "dd"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
tag_widget:connect_signal(
"button::press",
function ()
tag_widget.bg = "#3A475C" .. "bb"
end
)
tag_widget:connect_signal(
"button::release",
function ()
tag_widget.bg = "#3A475C" .. "dd"
end
)
tag_widget:connect_signal(
"mouse::leave",
function ()
tag_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
widget:add(tag_widget)
widget:set_spacing(dpi(6))
end
end
local tag_list = function (s)
return awful.widget.taglist(
s,
awful.widget.taglist.filter.all,
gears.table.join(
awful.button(
{ },
1,
function (t)
t:view_only()
end
),
awful.button(
{ modkey },
1,
function (t)
if client.focus then
client.focus:move_to_tag(t)
end
end
),
awful.button(
{ },
3,
function (t)
if client.focus then
client.focus:toggle_tag(t)
end
end
),
awful.button(
{ modkey },
3,
function (t)
if client.focus then
client.focus:toggle_tag(t)
end
end
),
awful.button(
{ },
4,
function (t)
awful.tag.viewnext(t.screen)
end
),
awful.button(
{ },
5,
function (t)
if client.focus then
awful.tag.viewprev(t.screen)
end
end
)
)
,
{},
list_update,
wibox.layout.fixed.horizontal()
)
end
return tag_list

View File

@@ -0,0 +1,171 @@
local awful = require('awful')
local wibox = require('wibox')
local dpi = require('beautiful').xresources.apply_dpi
local gears = require('gears')
local color = require('theme.crylia.colors')
local naughty = require("naughty")
local list_update = function (widget, buttons, label, data, objects)
widget:reset()
for i, object in ipairs(objects) do
local task_icon = wibox.widget{
nil,
{
id = "icon",
resize = true,
widget = wibox.widget.imagebox
},
nil,
layout = wibox.layout.align.horizontal
}
local task_icon_margin = wibox.widget{
task_icon,
forced_width = dpi(33),
margins = dpi(3),
widget = wibox.container.margin
}
local task_title = wibox.widget{
text = "",
align = "center",
valign = "center",
visible = true,
widget = wibox.widget.textbox
}
local task_widget = wibox.widget{
{
{
task_icon_margin,
task_title,
layout = wibox.layout.fixed.horizontal
},
margins = dpi(0),
widget = wibox.container.margin
},
bg = color.color["White"],
fg = color.color["Grey900"],
shape = function (cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.widget.background
}
local task_tool_tip = awful.tooltip{
objects = {task_widget},
mode = "inside",
align = "right",
delay_show = 1
}
task_widget:buttons(buttons, object)
local text, bg, bg_image, icon, args = label(object, task_title)
if object == client.focus then
if text == nil or text == '' then
task_title:set_margins(0)
else
local text_full = text:match('>(.-)<')
if text_full then
text = text_full
task_tool_tip:set_text(text_full)
task_tool_tip:add_to_object(task_widget)
else
task_tool_tip:remove_from_object(task_widget)
end
end
task_widget:set_bg(color.color["White"])
task_widget:set_fg(color.color["Grey900"])
task_title:set_text(text)
else
task_widget:set_bg("#3A475C")
task_title:set_text('')
end
if icon then
task_icon.icon:set_image(icon)
else
task_icon_margin:set_margins(0)
end
widget:add(task_widget)
widget:set_spacing(dpi(6))
local old_wibox, old_cursor, old_bg
task_widget:connect_signal(
"mouse::enter",
function ()
old_bg = task_widget.bg
task_widget.bg = "#ffffff" .. "bb"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
task_widget:connect_signal(
"button::press",
function ()
task_widget.bg = "#ffffff" .. "aa"
end
)
task_widget:connect_signal(
"button::release",
function ()
task_widget.bg = "#ffffff" .. "bb"
end
)
task_widget:connect_signal(
"mouse::leave",
function ()
task_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
end
if (widget.children and #widget.children or 0) == 0 then
awesome.emit_signal("hide_centerbar", false)
else
awesome.emit_signal("hide_centerbar", true)
end
return widget
end
return function(s)
return awful.widget.tasklist(
s,
awful.widget.tasklist.filter.currenttags,
gears.table.join(
awful.button(
{},
1,
function (c)
if c == client.focus then
c.minimized = true
else
c.minimized = false
if not c.invisible() and c.first_tag then
c:emit_signal("request::activate")
c:raise()
end
end
end
)
),
{},
list_update,
wibox.layout.fixed.horizontal()
)
end