yes, I'm very commit lazy

This commit is contained in:
2023-03-19 19:22:02 +01:00
parent 4f3fb75687
commit f399235db0
107 changed files with 11120 additions and 10906 deletions

View File

@@ -2,98 +2,118 @@
-- This is the audio widget --
------------------------------
-- Awesome Libs
local abutton = require('awful.button')
local apopup = require('awful.popup')
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gtable = require('gears.table')
local wibox = require('wibox')
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- Local libs
local audio_controller = require('src.modules.audio.audio_controller')
local audio_helper = require('src.tools.helpers.audio')
local hover = require('src.tools.hover')
require("src.tools.helpers.audio")
local capi = {
awesome = awesome,
}
local capi = { mouse = mouse }
-- Icon directory path
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/audio/"
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/audio/'
-- Returns the audio widget
return function(s)
return setmetatable({}, { __call = function(_, screen)
local audio_widget = wibox.widget {
local ac_popup = apopup {
widget = audio_controller,
ontop = true,
visible = false,
screen = screen,
border_color = Theme_config.bluetooth_controller.container_border_color,
border_width = Theme_config.bluetooth_controller.container_border_width,
bg = Theme_config.bluetooth_controller.container_bg,
}
local w = wibox.widget {
{
{
{
{
{
id = "icon",
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
resize = false
},
id = "icon_layout",
widget = wibox.container.place
id = 'icon',
widget = wibox.widget.imagebox,
valign = 'center',
halign = 'center',
resize = true,
},
top = dpi(2),
widget = wibox.container.margin,
id = "icon_margin"
width = dpi(25),
height = dpi(25),
strategy = 'exact',
widget = wibox.container.constraint,
},
{
id = 'label',
halign = 'center',
valign = 'center',
widget = wibox.widget.textbox,
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "audio_layout",
layout = wibox.layout.fixed.horizontal
id = 'audio_layout',
layout = wibox.layout.fixed.horizontal,
},
id = "container",
id = 'container',
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
widget = wibox.container.margin,
},
bg = Theme_config.audio.bg,
fg = Theme_config.audio.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
shape = Theme_config.audio.shape,
widget = wibox.container.background,
buttons = { gtable.join(
abutton({}, 1, function()
local geo = capi.mouse.coords()
ac_popup.y = dpi(65)
ac_popup.x = geo.x - ac_popup.width / 2
ac_popup.visible = not ac_popup.visible
end)
), },
}
capi.awesome.connect_signal("audio::get", function(muted, volume)
hover.bg_hover { widget = w }
local audio_label = w:get_children_by_id('label')[1]
local audio_icon = w:get_children_by_id('icon')[1]
local audio_spacing = w:get_children_by_id('audio_layout')[1]
audio_helper:connect_signal('sink::get', function(_, muted, volume)
volume = tonumber(volume)
assert(type(volume) == 'number' and type(muted) == 'boolean', 'Invalid arguments')
if w.volume == volume and w.muted == muted then return end
w.volume = volume
w.muted = muted
if muted then
audio_widget.container.audio_layout.label.visible = false
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(
gears.color.recolor_image(icondir .. "volume-mute" .. ".svg", Theme_config.audio.fg))
audio_label.visible = false
audio_icon:set_image(gcolor.recolor_image(icondir .. 'volume-mute' .. '.svg', Theme_config.audio.fg))
else
audio_widget.container:set_right(10)
local icon = icondir .. "volume"
audio_widget.container.audio_layout.spacing = dpi(5)
audio_widget.container.audio_layout.label.visible = true
volume = tonumber(volume)
if not volume then
return
end
if not volume then return end
w.container:set_right(10)
audio_spacing.spacing = dpi(5)
audio_label.visible = true
local icon = icondir .. 'volume'
if volume < 1 then
icon = icon .. "-mute"
audio_widget.container.audio_layout.spacing = dpi(0)
audio_widget.container.audio_layout.label.visible = false
icon = icon .. '-mute'
audio_spacing.spacing = 0
audio_label.visible = false
elseif volume >= 1 and volume < 34 then
icon = icon .. "-low"
icon = icon .. '-low'
elseif volume >= 34 and volume < 67 then
icon = icon .. "-medium"
icon = icon .. '-medium'
elseif volume >= 67 then
icon = icon .. "-high"
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", Theme_config.audio.fg))
audio_label:set_text(volume .. '%')
audio_icon:set_image(gcolor.recolor_image(icon .. '.svg', Theme_config.audio.fg))
end
end)
-- Signals
Hover_signal(audio_widget)
return audio_widget
end
return w
end, })

View File

@@ -3,20 +3,23 @@
--------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local lgi = require("lgi")
local naughty = require("naughty")
local upower_glib = lgi.require("UPowerGlib")
local wibox = require("wibox")
local awful = require('awful')
local dpi = require('beautiful').xresources.apply_dpi
local gears = require('gears')
local lgi = require('lgi')
local naughty = require('naughty')
local upower_glib = lgi.require('UPowerGlib')
local wibox = require('wibox')
-- Local libs
local hover = require('src.tools.hover')
local capi = {
awesome = awesome,
}
-- Icon directory path
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/battery/"
local icondir = gears.filesystem.get_configuration_dir() .. 'src/assets/icons/battery/'
---Returns the battery widget
---@return wibox.widget
@@ -29,46 +32,46 @@ return function(battery_kind)
{
{
{
id = "icon",
image = gears.color.recolor_image(icondir .. "battery-unknown.svg", Theme_config.battery.fg),
id = 'icon',
image = gears.color.recolor_image(icondir .. 'battery-unknown.svg', Theme_config.battery.fg),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
resize = false
valign = 'center',
halign = 'center',
resize = false,
},
id = "icon_layout",
widget = wibox.container.place
id = 'icon_layout',
widget = wibox.container.place,
},
id = "icon_margin",
id = 'icon_margin',
top = dpi(2),
widget = wibox.container.margin
widget = wibox.container.margin,
},
spacing = dpi(10),
{
visible = false,
align = 'center',
valign = 'center',
id = "label",
widget = wibox.widget.textbox
id = 'label',
widget = wibox.widget.textbox,
},
id = "battery_layout",
layout = wibox.layout.fixed.horizontal
id = 'battery_layout',
layout = wibox.layout.fixed.horizontal,
},
id = "container",
id = 'container',
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
widget = wibox.container.margin,
},
bg = Theme_config.battery.bg,
fg = Theme_config.battery.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
widget = wibox.container.background,
}
-- Color change on mouse over
Hover_signal(battery_widget)
hover.bg_hover { widget = battery_widget }
-- Open an energy manager on click
battery_widget:connect_signal(
@@ -105,9 +108,9 @@ return function(battery_kind)
local tooltip = awful.tooltip {
objects = { battery_widget },
mode = "inside",
preferred_alignments = "middle",
margins = dpi(10)
mode = 'inside',
preferred_alignments = 'middle',
margins = dpi(10),
}
---Sets the battery information for the widget
@@ -125,50 +128,50 @@ return function(battery_kind)
battery_time = device.time_to_full
end
local battery_string = math.floor(battery_time / 3600) .. "h, " .. math.floor((battery_time / 60) % 60) .. "m"
local battery_string = math.floor(battery_time / 3600) .. 'h, ' .. math.floor((battery_time / 60) % 60) .. 'm'
if battery_temp == 0.0 then
battery_temp = "NaN"
battery_temp = 'NaN'
else
battery_temp = math.floor(battery_temp + 0.5) .. "°C"
battery_temp = math.floor(battery_temp + 0.5) .. '°C'
end
if not battery_percentage then
return
end
battery_widget:get_children_by_id("battery_layout")[1].spacing = dpi(5)
battery_widget:get_children_by_id("label")[1].visible = true
battery_widget:get_children_by_id("label")[1].text = battery_percentage .. '%'
battery_widget:get_children_by_id('battery_layout')[1].spacing = dpi(5)
battery_widget:get_children_by_id('label')[1].visible = true
battery_widget:get_children_by_id('label')[1].text = battery_percentage .. '%'
tooltip.markup = "<span foreground='#64ffda'>Battery Status:</span> <span foreground='#90caf9'>"
.. battery_status .. "</span>\n<span foreground='#64ffda'>Remaining time:</span> <span foreground='#90caf9'>"
.. battery_string .. "</span>\n<span foreground='#64ffda'>Temperature:</span> <span foreground='#90caf9'>"
.. battery_temp .. "</span>"
.. battery_temp .. '</span>'
local icon = 'battery'
if battery_status == 'fully-charged' or battery_status == 'charging' and battery_percentage == 100 then
icon = icon .. '-' .. 'charging.svg'
naughty.notification {
title = "Battery notification",
message = "Battery is fully charged",
title = 'Battery notification',
message = 'Battery is fully charged',
icon = icondir .. icon,
timeout = 5
timeout = 5,
}
battery_widget:get_children_by_id("icon")[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir
battery_widget:get_children_by_id('icon')[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir
.. icon, Theme_config.battery.fg))
return
elseif battery_percentage > 0 and battery_percentage < 10 and battery_status == 'discharging' then
icon = icon .. '-' .. 'alert.svg'
naughty.notification {
title = "Battery warning",
message = "Battery is running low!\n" .. battery_percentage .. "% left",
urgency = "critical",
title = 'Battery warning',
message = 'Battery is running low!\n' .. battery_percentage .. '% left',
urgency = 'critical',
icon = icondir .. icon,
timeout = 60
timeout = 60,
}
battery_widget:get_children_by_id("icon")[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir
battery_widget:get_children_by_id('icon')[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir
.. icon, Theme_config.battery.fg))
return
end
@@ -195,9 +198,9 @@ return function(battery_kind)
icon = icon .. '-' .. battery_status .. '-' .. '90'
end
battery_widget:get_children_by_id("icon")[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir ..
battery_widget:get_children_by_id('icon')[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir ..
icon .. '.svg', Theme_config.battery.fg))
capi.awesome.emit_signal("update::battery_widget", battery_percentage, icondir .. icon .. ".svg")
capi.awesome.emit_signal('update::battery_widget', battery_percentage, icondir .. icon .. '.svg')
end
@@ -208,12 +211,12 @@ return function(battery_kind)
---Will report to the bluetooth widget.
---@param path string device path /org/freedesktop/...
local function attach_to_device(path)
local device_path = User_config.battery_path or path or ""
local device_path = User_config.battery_path or path or ''
battery_widget.device = get_device_from_path(device_path) or upower_glib.Client():get_display_device()
battery_widget.device.on_notify = function(device)
battery_widget:emit_signal("upower::update", device)
battery_widget:emit_signal('upower::update', device)
end
-- Check which device kind the user wants to display
@@ -223,7 +226,7 @@ return function(battery_kind)
end
-- The delayed call will fire every time awesome finishes its main event loop
gears.timer.delayed_call(battery_widget.emit_signal, battery_widget, "upower::update", battery_widget.device)
gears.timer.delayed_call(battery_widget.emit_signal, battery_widget, 'upower::update', battery_widget.device)
end
for _, device in ipairs(get_device_path()) do
@@ -231,7 +234,7 @@ return function(battery_kind)
end
battery_widget:connect_signal(
"upower::update",
'upower::update',
function(_, device)
if upower_glib.DeviceKind[battery_widget.device.kind] == battery_kind then
set_battery(device)

View File

@@ -3,21 +3,22 @@
----------------------------------
-- Awesome libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local awful = require('awful')
local dpi = require('beautiful').xresources.apply_dpi
local gears = require('gears')
local wibox = require('wibox')
-- Own libs
local bt_module = require("src.modules.bluetooth.init")
local bt_module = require('src.modules.bluetooth.init')
local hover = require('src.tools.hover')
local capi = {
awesome = awesome,
mouse = mouse
mouse = mouse,
}
-- Icon directory path
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/bluetooth/"
local icondir = gears.filesystem.get_configuration_dir() .. 'src/assets/icons/bluetooth/'
-- Returns the bluetooth widget
return function(s)
@@ -29,29 +30,31 @@ return function(s)
{
{
{
id = "icon",
image = gears.color.recolor_image(icondir .. "bluetooth-off.svg", Theme_config.bluetooth.fg),
id = 'icon',
image = gears.color.recolor_image(icondir .. 'bluetooth-off.svg', Theme_config.bluetooth.fg),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
resize = false
valign = 'center',
halign = 'center',
resize = false,
},
id = "icon_layout",
widget = wibox.container.place
id = 'icon_layout',
widget = wibox.container.place,
},
id = "icon_margin",
id = 'icon_margin',
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
widget = wibox.container.margin,
},
bg = Theme_config.bluetooth.bg,
fg = Theme_config.bluetooth.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
widget = wibox.container.background,
}
hover.bg_hover { widget = bluetooth_widget }
-- If bt_widget is nil then there is no bluetooth adapter and there shouldn't be done
-- anything besides returning the widget without any logic behind
if not bt_widget then
@@ -67,27 +70,24 @@ return function(s)
screen = s,
border_color = Theme_config.bluetooth_controller.container_border_color,
border_width = Theme_config.bluetooth_controller.container_border_width,
bg = Theme_config.bluetooth_controller.container_bg
bg = Theme_config.bluetooth_controller.container_bg,
}
-- When the status changes update the icon
bt_widget:connect_signal("bluetooth::status", function(status)
bluetooth_widget:get_children_by_id("icon")[1].image = gears.color.recolor_image(status._private.Adapter1.Powered and
icondir .. "bluetooth-on.svg" or icondir .. "bluetooth-off.svg", Theme_config.bluetooth.fg)
bt_widget:connect_signal('bluetooth::status', function(status)
bluetooth_widget:get_children_by_id('icon')[1].image = gears.color.recolor_image(status._private.Adapter1.Powered and
icondir .. 'bluetooth-on.svg' or icondir .. 'bluetooth-off.svg', Theme_config.bluetooth.fg)
end)
-- Hover signal to change color when mouse is over
Hover_signal(bluetooth_widget)
-- On left click toggle the bluetooth container else toggle the bluetooth on/off
bluetooth_widget:connect_signal("button::press", function(_, _, _, key)
bluetooth_widget:connect_signal('button::press', function(_, _, _, key)
if key == 1 then
local geo = capi.mouse.current_wibox:geometry()
bluetooth_container.x = geo.x
bluetooth_container.y = geo.y + dpi(55)
bluetooth_container.visible = not bluetooth_container.visible
else
capi.awesome.emit_signal("toggle_bluetooth")
capi.awesome.emit_signal('toggle_bluetooth')
end
end)

View File

@@ -3,62 +3,55 @@
------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local wibox = require('wibox')
-- Local libs
local hover = require('src.tools.hover')
-- Icon directory path
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/clock/"
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/clock/'
-- Returns the clock widget
return function()
return setmetatable({}, { __call = function()
local clock_widget = wibox.widget {
{
{
{
{
{
id = "icon",
image = gears.color.recolor_image(icondir .. "clock.svg", Theme_config.clock.fg),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
resize = false
},
id = "icon_layout",
widget = wibox.container.place
image = gcolor.recolor_image(icondir .. 'clock.svg', Theme_config.clock.fg),
widget = wibox.widget.imagebox,
valign = 'center',
halign = 'center',
resize = true,
},
id = "icon_margin",
top = dpi(2),
widget = wibox.container.margin
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
{
halign = 'center',
valign = 'center',
format = '%H:%M',
widget = wibox.widget.textclock,
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
format = "%H:%M",
widget = wibox.widget.textclock
},
id = "clock_layout",
layout = wibox.layout.fixed.horizontal
layout = wibox.layout.fixed.horizontal,
},
id = "container",
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
widget = wibox.container.margin,
},
bg = Theme_config.clock.bg,
fg = Theme_config.clock.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
shape = Theme_config.clock.shape,
widget = wibox.container.background,
}
Hover_signal(clock_widget)
hover.bg_hover { widget = clock_widget }
return clock_widget
end
end, })

View File

@@ -3,217 +3,234 @@
---------------------------------
-- Awesome Libs
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local base = require('wibox.widget.base')
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gtable = require('gears.table')
local wibox = require('wibox')
local color = require("src.lib.color")
local rubato = require("src.lib.rubato")
-- Third Party Libs
local color = require('src.lib.color')
local rubato = require('src.lib.rubato')
local hover = require('src.tools.hover')
require("src.tools.helpers.cpu_freq")
require("src.tools.helpers.cpu_temp")
require("src.tools.helpers.cpu_usage")
local icon_dir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/cpu/'
local capi = {
awesome = awesome,
}
local cpu_info = {}
local icon_dir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/cpu/"
local function cpu_temp_new()
local cpu_temp_helper = require('src.tools.helpers.cpu_temp')
--TODO: Add tooltip with more CPU and per core information
return function(widget)
local cpu_usage_widget = wibox.widget {
local w = base.make_widget_from_value(wibox.widget {
{
{
{
{
{
id = "icon",
id = 'icon_role',
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
image = gears.color.recolor_image(icon_dir .. "cpu.svg", Theme_config.cpu_usage.fg),
resize = false
valign = 'center',
halign = 'center',
image = gcolor.recolor_image(icon_dir .. 'thermometer.svg', Theme_config.cpu_temp.fg),
resize = true,
},
id = "icon_layout",
widget = wibox.container.place
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
top = dpi(2),
widget = wibox.container.margin,
id = "icon_margin"
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "cpu_layout",
layout = wibox.layout.fixed.horizontal
},
id = "container",
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
},
bg = Theme_config.cpu_usage.bg,
fg = Theme_config.cpu_usage.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
}
local cpu_temp = wibox.widget {
{
{
{
{
{
id = "icon",
image = gears.color.recolor_image(icon_dir .. "thermometer.svg", Theme_config.cpu_temp.fg),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
resize = false
},
id = "icon_layout",
widget = wibox.container.place
id = 'text_role',
halign = 'center',
valign = 'center',
widget = wibox.widget.textbox,
},
top = dpi(2),
widget = wibox.container.margin,
id = "icon_margin"
spacing = dpi(5),
layout = wibox.layout.fixed.horizontal,
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "cpu_layout",
layout = wibox.layout.fixed.horizontal
widget = wibox.container.place,
},
id = "container",
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin,
},
bg = Theme_config.cpu_temp.bg_low,
bg = Theme_config.cpu_temp.bg,
fg = Theme_config.cpu_temp.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
}
shape = Theme_config.cpu_temp.shape,
widget = wibox.container.background,
})
local cpu_clock = wibox.widget {
{
{
{
{
{
id = "icon",
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
image = gears.color.recolor_image(icon_dir .. "cpu.svg", Theme_config.cpu_freq.fg),
resize = false
},
id = "icon_layout",
widget = wibox.container.place
},
top = dpi(2),
widget = wibox.container.margin,
id = "icon_margin"
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "cpu_layout",
layout = wibox.layout.fixed.horizontal
},
id = "container",
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
},
bg = Theme_config.cpu_freq.bg,
fg = Theme_config.cpu_freq.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
}
assert(w, 'Failed to create widget')
capi.awesome.connect_signal("update::cpu_usage", function(usage)
cpu_usage_widget.container.cpu_layout.label.text = usage .. "%"
end)
gtable.crush(w, cpu_info, true)
local r_timed_cpu_bg = rubato.timed { duration = 2.5 }
local g_timed_cpu_bg = rubato.timed { duration = 2.5 }
local b_timed_cpu_bg = rubato.timed { duration = 2.5 }
local r = rubato.timed { duration = 2.5 }
local g = rubato.timed { duration = 2.5 }
local b = rubato.timed { duration = 2.5 }
r_timed_cpu_bg.pos, g_timed_cpu_bg.pos, b_timed_cpu_bg.pos = color.utils.hex_to_rgba(Theme_config.cpu_temp.bg_low)
r.pos, g.pos, b.pos = color.utils.hex_to_rgba(Theme_config.cpu_temp.bg_low)
-- Subscribable function to have rubato set the bg/fg color
local function update_bg()
cpu_temp:set_bg("#" .. color.utils.rgba_to_hex { r_timed_cpu_bg.pos, g_timed_cpu_bg.pos, b_timed_cpu_bg.pos })
w:set_bg('#' .. color.utils.rgba_to_hex { r.pos, g.pos, b.pos })
end
r_timed_cpu_bg:subscribe(update_bg)
g_timed_cpu_bg:subscribe(update_bg)
b_timed_cpu_bg:subscribe(update_bg)
r:subscribe(update_bg)
g:subscribe(update_bg)
b:subscribe(update_bg)
-- Both functions to set a color, if called they take a new color
local function set_bg(newbg)
r_timed_cpu_bg.target, g_timed_cpu_bg.target, b_timed_cpu_bg.target = color.utils.hex_to_rgba(newbg)
r.target, g.target, b.target = color.utils.hex_to_rgba(newbg)
end
capi.awesome.connect_signal("update::cpu_temp", function(temp)
cpu_temp_helper:connect_signal('update::cpu_temp', function(_, temp)
local temp_icon
local temp_color
if temp < 50 then
temp_color = Theme_config.cpu_temp.bg_low
temp_icon = icon_dir .. "thermometer-low.svg"
temp_icon = icon_dir .. 'thermometer-low.svg'
elseif temp >= 50 and temp < 80 then
temp_color = Theme_config.cpu_temp.bg_mid
temp_icon = icon_dir .. "thermometer.svg"
temp_icon = icon_dir .. 'thermometer.svg'
elseif temp >= 80 then
temp_color = Theme_config.cpu_temp.bg_high
temp_icon = icon_dir .. "thermometer-high.svg"
temp_icon = icon_dir .. 'thermometer-high.svg'
end
cpu_temp.container.cpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon)
w:get_children_by_id('icon_role')[1].image = temp_icon
set_bg(temp_color)
cpu_temp.container.cpu_layout.label.text = math.floor(temp) .. "°C"
capi.awesome.emit_signal("update::cpu_temp_widget", temp, temp_icon)
w:get_children_by_id('text_role')[1].text = math.floor(temp) .. '°C'
end)
capi.awesome.connect_signal("update::cpu_freq_average", function(average)
cpu_clock.container.cpu_layout.label.text = average .. "Mhz"
end)
capi.awesome.connect_signal("update::cpu_freq_core", function(freq)
cpu_clock.container.cpu_layout.label.text = freq .. "Mhz"
end)
Hover_signal(cpu_temp)
Hover_signal(cpu_usage_widget)
Hover_signal(cpu_clock)
if widget == "usage" then
return cpu_usage_widget
elseif widget == "temp" then
return cpu_temp
elseif widget == "freq" then
return cpu_clock
end
return w
end
local function cpu_usage_new()
local cpu_usage_helper = require('src.tools.helpers.cpu_usage')
local w = base.make_widget_from_value(wibox.widget {
{
{
{
{
{
id = 'icon_role',
widget = wibox.widget.imagebox,
valign = 'center',
halign = 'center',
image = gcolor.recolor_image(icon_dir .. 'cpu.svg', Theme_config.cpu_usage.fg),
resize = true,
},
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
{
id = 'text_role',
text = '0%',
halign = 'center',
valign = 'center',
widget = wibox.widget.textbox,
},
spacing = dpi(5),
layout = wibox.layout.fixed.horizontal,
},
widget = wibox.container.place,
},
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin,
},
bg = Theme_config.cpu_usage.bg,
fg = Theme_config.cpu_usage.fg,
shape = Theme_config.cpu_usage.shape,
widget = wibox.container.background,
})
assert(w, 'failed to create widget')
hover.bg_hover { widget = w }
gtable.crush(w, cpu_info, true)
cpu_usage_helper:connect_signal('update::cpu_usage', function(_, usage)
w:get_children_by_id('text_role')[1].text = usage .. '%'
end)
return w
end
local function cpu_freq_new()
local cpu_freq_helper = require('src.tools.helpers.cpu_freq')
local w = base.make_widget_from_value(wibox.widget {
{
{
{
{
{
id = 'icon_role',
widget = wibox.widget.imagebox,
valign = 'center',
halign = 'center',
image = gcolor.recolor_image(icon_dir .. 'cpu.svg', Theme_config.cpu_freq.fg),
resize = true,
},
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
{
id = 'text_role',
text = '0Mhz',
halign = 'center',
valign = 'center',
widget = wibox.widget.textbox,
},
spacing = dpi(5),
layout = wibox.layout.fixed.horizontal,
},
widget = wibox.container.place,
},
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin,
},
bg = Theme_config.cpu_freq.bg,
fg = Theme_config.cpu_freq.fg,
shape = Theme_config.cpu_freq.shape,
widget = wibox.container.background,
})
assert(w, 'failed to create widget')
hover.bg_hover { widget = w }
gtable.crush(w, cpu_info, true)
cpu_freq_helper:connect_signal('update::cpu_freq_average', function(_, average)
w:get_children_by_id('text_role')[1].text = average .. 'Mhz'
end)
cpu_freq_helper:connect_signal('update::cpu_freq_core', function(_, freq)
w:get_children_by_id('text_role')[1].text = freq .. 'Mhz'
end)
return w
end
return setmetatable(cpu_info, { __call = function(_, widget)
if widget == 'temp' then
return cpu_temp_new()
elseif widget == 'usage' then
return cpu_usage_new()
elseif widget == 'freq' then
return cpu_freq_new()
else
return nil
end
end, })

View File

@@ -3,83 +3,81 @@
-----------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local apopup = require('awful.popup')
local dpi = require('beautiful').xresources.apply_dpi
local wibox = require('wibox')
local abutton = require('awful.button')
local gfilesystem = require('gears.filesystem')
local gtable = require('gears.table')
local gcolor = require('gears.color')
-- Local libs
local cal = require('src.modules.calendar.init') {}
local hover = require('src.tools.hover')
-- Icon directory path
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/date/"
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/date/'
local capi = { mouse = mouse }
-- Returns the date widget
return function(s)
local cal = require("src.modules.calendar.init") { screen = s }
return setmetatable({}, { __call = function(_, screen)
local date_widget = wibox.widget {
{
{
{
{
{
id = "icon",
image = gears.color.recolor_image(icondir .. "calendar.svg", Theme_config.date.fg),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
resize = false
},
id = "icon_layout",
widget = wibox.container.place
image = gcolor.recolor_image(icondir .. 'calendar.svg', Theme_config.date.fg),
widget = wibox.widget.imagebox,
valign = 'center',
halign = 'center',
resize = true,
},
id = "icon_margin",
top = dpi(2),
widget = wibox.container.margin
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
{
halign = 'center',
valign = 'center',
format = '%a, %b %d',
widget = wibox.widget.textclock,
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
format = "%a, %b %d",
widget = wibox.widget.textclock
},
id = "date_layout",
layout = wibox.layout.fixed.horizontal
layout = wibox.layout.fixed.horizontal,
},
id = "container",
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
widget = wibox.container.margin,
},
bg = Theme_config.date.bg,
fg = Theme_config.date.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
shape = Theme_config.date.shape,
widget = wibox.container.background,
}
local calendar_popup = awful.popup {
local calendar_popup = apopup {
widget = cal:get_widget(),
screen = s,
screen = screen,
ontop = true,
bg = "#00000000",
visible = false,
}
-- Signals
Hover_signal(date_widget)
hover.bg_hover { widget = date_widget }
date_widget:buttons {
gears.table.join(
awful.button({}, 1, function()
local geo = mouse.current_wibox:geometry()
calendar_popup.x = geo.x
calendar_popup.y = geo.y + dpi(55)
calendar_popup.visible = not calendar_popup.visible
end)
)
}
date_widget:buttons { gtable.join(
abutton({}, 1, function()
local geo = capi.mouse.coords()
calendar_popup.y = dpi(65)
if geo.x + (calendar_popup.width / 2) > capi.mouse.screen.geometry.width then
calendar_popup.x = capi.mouse.screen.geometry.x + capi.mouse.screen.geometry.width - calendar_popup.width
else
calendar_popup.x = geo.x - (calendar_popup.width / 2)
end
calendar_popup.visible = not calendar_popup.visible
end)
), }
return date_widget
end
end, })

View File

@@ -3,179 +3,173 @@
---------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local base = require('wibox.widget.base')
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local wibox = require('wibox')
local color = require("src.lib.color")
local rubato = require("src.lib.rubato")
-- Third Party Libs
local color = require('src.lib.color')
local rubato = require('src.lib.rubato')
local hover = require('src.tools.hover')
require("src.tools.helpers.gpu_temp")
require("src.tools.helpers.gpu_usage")
local icon_dir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/cpu/'
local capi = {
awesome = awesome,
}
local gpu_info = {}
local icon_dir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/cpu/"
local function gpu_temp_new()
local gpu_temp_helper = require('src.tools.helpers.gpu_temp')
return function(widget)
local gpu_usage_widget = wibox.widget {
local w = base.make_widget_from_value(wibox.widget {
{
{
{
{
{
id = "icon",
id = 'icon_role',
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
image = gears.color.recolor_image(icon_dir .. "gpu.svg", Theme_config.gpu_usage.fg),
resize = false
valign = 'center',
halign = 'center',
image = gcolor.recolor_image(icon_dir .. 'gpu.svg', Theme_config.gpu_temp.fg),
resize = true,
},
id = "icon_layout",
widget = wibox.container.place
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
top = dpi(2),
widget = wibox.container.margin,
id = "icon_margin"
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "gpu_layout",
layout = wibox.layout.fixed.horizontal
},
id = "container",
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
},
bg = Theme_config.gpu_usage.bg,
fg = Theme_config.gpu_usage.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
}
local gpu_temp_widget = wibox.widget {
{
{
{
{
{
id = "icon",
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
image = gears.color.recolor_image(icon_dir .. "gpu.svg", Theme_config.gpu_temp.fg),
resize = false
},
id = "icon_layout",
widget = wibox.container.place
id = 'text_role',
text = '0°C',
halign = 'center',
valign = 'center',
widget = wibox.widget.textbox,
},
top = dpi(2),
widget = wibox.container.margin,
id = "icon_margin"
spacing = dpi(5),
layout = wibox.layout.fixed.horizontal,
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "gpu_layout",
layout = wibox.layout.fixed.horizontal
widget = wibox.container.place,
},
id = "container",
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin,
},
bg = Theme_config.gpu_temp.bg_low,
bg = Theme_config.gpu_temp.bg,
fg = Theme_config.gpu_temp.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
}
shape = Theme_config.gpu_temp.shape,
widget = wibox.container.background,
})
Hover_signal(gpu_temp_widget)
Hover_signal(gpu_usage_widget)
assert(w, 'Widget not created')
-- GPU Utilization
capi.awesome.connect_signal(
"update::gpu_usage",
function(stdout)
gpu_usage_widget.container.gpu_layout.label.text = stdout:gsub("\n", "") .. "%"
end
)
local r = rubato.timed { duration = 2.5 }
local g = rubato.timed { duration = 2.5 }
local b = rubato.timed { duration = 2.5 }
local r_timed_gpu_bg = rubato.timed { duration = 2.5 }
local g_timed_gpu_bg = rubato.timed { duration = 2.5 }
local b_timed_gpu_bg = rubato.timed { duration = 2.5 }
r_timed_gpu_bg.pos, g_timed_gpu_bg.pos, b_timed_gpu_bg.pos = color.utils.hex_to_rgba(Theme_config.cpu_temp.bg_low)
r.pos, g.pos, b.pos = color.utils.hex_to_rgba(Theme_config.cpu_temp.bg_low)
-- Subscribable function to have rubato set the bg/fg color
local function update_bg()
gpu_temp_widget:set_bg("#" ..
color.utils.rgba_to_hex { math.max(0, r_timed_gpu_bg.pos), math.max(0, g_timed_gpu_bg.pos),
math.max(0, b_timed_gpu_bg.pos) })
w:set_bg('#' .. color.utils.rgba_to_hex { math.max(0, r.pos), math.max(0, g.pos),
math.max(0, b.pos), })
end
r_timed_gpu_bg:subscribe(update_bg)
g_timed_gpu_bg:subscribe(update_bg)
b_timed_gpu_bg:subscribe(update_bg)
r:subscribe(update_bg)
g:subscribe(update_bg)
b:subscribe(update_bg)
-- Both functions to set a color, if called they take a new color
local function set_bg(newbg)
r_timed_gpu_bg.target, g_timed_gpu_bg.target, b_timed_gpu_bg.target = color.utils.hex_to_rgba(newbg)
r.target, g.target, b.target = color.utils.hex_to_rgba(newbg)
end
-- GPU Temperature
capi.awesome.connect_signal(
"update::gpu_temp",
function(stdout)
local temp_icon
local temp_color
local temp_num = tonumber(stdout) or "N/A"
if temp_num then
if temp_num < 50 then
temp_color = Theme_config.gpu_temp.bg_low
temp_icon = icon_dir .. "thermometer-low.svg"
elseif temp_num >= 50 and temp_num < 80 then
temp_color = Theme_config.gpu_temp.bg_mid
temp_icon = icon_dir .. "thermometer.svg"
elseif temp_num >= 80 then
temp_color = Theme_config.gpu_temp.bg_high
temp_icon = icon_dir .. "thermometer-high.svg"
end
else
temp_num = "N/A"
gpu_temp_helper:connect_signal('update::gpu_temp', function(_, stdout)
local temp_icon
local temp_color
local temp_num = tonumber(stdout) or 0
if temp_num then
if temp_num < 50 then
temp_color = Theme_config.gpu_temp.bg_low
temp_icon = icon_dir .. "thermometer-low.svg"
temp_icon = icon_dir .. 'thermometer-low.svg'
elseif temp_num >= 50 and temp_num < 80 then
temp_color = Theme_config.gpu_temp.bg_mid
temp_icon = icon_dir .. 'thermometer.svg'
elseif temp_num >= 80 then
temp_color = Theme_config.gpu_temp.bg_high
temp_icon = icon_dir .. 'thermometer-high.svg'
end
gpu_temp_widget.container.gpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon)
set_bg(temp_color)
gpu_temp_widget.container.gpu_layout.label.text = tostring(temp_num) .. "°C"
else
temp_color = Theme_config.gpu_temp.bg_low
temp_icon = icon_dir .. 'thermometer-low.svg'
end
)
w:get_children_by_id('icon_role')[1]:set_image(temp_icon)
set_bg(temp_color)
w:get_children_by_id('text_role')[1].text = tostring(temp_num) .. '°C'
end)
if widget == "usage" then
return gpu_usage_widget
elseif widget == "temp" then
return gpu_temp_widget
end
return w
end
local function gpu_usage_new()
local gpu_usage_helper = require('src.tools.helpers.gpu_usage')
local w = base.make_widget_from_value(wibox.widget {
{
{
{
{
{
id = 'icon_role',
widget = wibox.widget.imagebox,
valign = 'center',
halign = 'center',
image = gcolor.recolor_image(icon_dir .. 'gpu.svg', Theme_config.gpu_usage.fg),
resize = true,
},
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
{
id = 'text_role',
text = '0%',
halign = 'center',
valign = 'center',
widget = wibox.widget.textbox,
},
spacing = dpi(5),
layout = wibox.layout.fixed.horizontal,
},
widget = wibox.container.place,
},
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin,
},
bg = Theme_config.gpu_usage.bg,
fg = Theme_config.gpu_usage.fg,
shape = Theme_config.gpu_usage.shape,
widget = wibox.container.background,
})
assert(w, 'Widget not created')
hover.bg_hover { widget = w }
gpu_usage_helper:connect_signal('update::gpu_usage', function(_, stdout)
w:get_children_by_id('text_role')[1].text = stdout:gsub('\n', '') .. '%'
end)
return w
end
return setmetatable(gpu_info, { __call = function(_, widget)
if widget == 'usage' then
return gpu_usage_new()
elseif widget == 'temp' then
return gpu_temp_new()
end
end, })

View File

@@ -3,395 +3,278 @@
------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local dpi = require('beautiful').xresources.apply_dpi
local wibox = require('wibox')
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gtable = require('gears.table')
local abutton = require('awful.button')
local apopup = require('awful.popup')
-- Local libs
local kb_helper = require('src.tools.helpers.kb_helper')
local hover = require('src.tools.hover')
local capi = {
awesome = awesome,
mousegrabber = mousegrabber,
mouse = mouse,
}
-- Icon directory path
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/kblayout/"
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/kblayout/'
return function(s)
local kb_layout_popup
local function create_kb_layout_list()
local widget = wibox.widget {
{
{
id = 'list',
layout = wibox.layout.fixed.vertical,
spacing = dpi(10),
},
widget = wibox.container.margin,
margins = dpi(10),
},
widget = wibox.container.background,
bg = Theme_config.kblayout.bg_container,
}
local list = widget:get_children_by_id('list')[1]
for _, keymap in pairs(User_config.kblayout) do
-- TODO: Add more, too lazy rn
local xkeyboard_country_code = {
['af'] = { 'أفغانيش(Afghanistan)', 'AFG' }, -- Afghanistan
['al'] = { 'Shqip(Albania)', 'ALB' }, -- Albania
['am'] = { 'Hայերեն(Armenia)', 'ARM' }, -- Armenia
['ara'] = { 'عربي(Arab)', 'ARB' }, -- Arabic
['at'] = { 'Österreichisch (Austria)', 'AUT' }, -- Austria
['az'] = { 'Azərbaycan(Azerbaijan)', 'AZE' }, -- Azerbaijan
['ba'] = { 'Bosanski(Bosnia and Herzegovina)', 'BIH' }, -- Bosnia and Herzegovina
['bd'] = { '', 'BGD' }, -- Bangladesh
['be'] = { '', 'BEL' }, -- Belgium
['bg'] = { '', 'BGR' }, -- Bulgaria
['br'] = { '', 'BRA' }, -- Brazil
['bt'] = { '', 'BTN' }, -- Bhutan
['bw'] = { '', 'BWA' }, -- Botswana
['by'] = { '', 'BLR' }, -- Belarus
['ca'] = { '', 'CAN' }, -- Canada
['cd'] = { '', 'COD' }, -- Congo
['ch'] = { '', 'CHE' }, -- Switzerland
['cm'] = { '', 'CMR' }, -- Cameroon
['cn'] = { '', 'CHN' }, -- China
['cz'] = { '', 'CZE' }, -- Czechia
['de'] = { 'Deutsch (Germany)', 'GER' }, -- Germany
['dk'] = { '', 'DNK' }, -- Denmark
['ee'] = { '', 'EST' }, -- Estonia
['es'] = { '', 'ESP' }, -- Spain
['et'] = { '', 'ETH' }, -- Ethiopia
['eu'] = { '?', '?' }, -- EurKey
['fi'] = { '', 'FIN' }, -- Finland
['fo'] = { '', 'FRO' }, -- Faroe Islands
['fr'] = { '', 'FRA' }, -- France
['gb'] = { "English (Bri'ish)", 'ENG' }, -- United Kingdom
['ge'] = { '', 'GEO' }, -- Georgia
['gh'] = { '', 'GHA' }, -- Ghana
['gn'] = { '', 'GIN' }, -- Guinea
['gr'] = { '', 'GRC' }, -- Greece
['hr'] = { '', 'HRV' }, -- Croatia
['hu'] = { '', 'HUN' }, -- Hungary
['ie'] = { '', 'IRL' }, -- Ireland
['il'] = { '', 'ISR' }, -- Israel
['in'] = { '', 'IND' }, -- India
['iq'] = { '', 'IRQ' }, -- Iraq
['ir'] = { '', 'IRN' }, -- Iran
['is'] = { '', 'ISL' }, -- Iceland
['it'] = { '', 'ITA' }, -- Italy
['jp'] = { '', 'JPN' }, -- Japan
['ke'] = { '', 'KEN' }, -- Kenya
['kg'] = { '', 'KGZ' }, -- Kyrgyzstan
['kh'] = { '', 'KHM' }, -- Cambodia
['kr'] = { '', 'KOR' }, -- Korea
['kz'] = { '', 'KAZ' }, -- Kazakhstan
['la'] = { '', 'LAO' }, -- Laos
['latm'] = { '?', '?' }, -- Latin America
['latn'] = { '?', '?' }, -- Latin
['lk'] = { '', 'LKA' }, -- Sri Lanka
['lt'] = { '', 'LTU' }, -- Lithuania
['lv'] = { '', 'LVA' }, -- Latvia
['ma'] = { '', 'MAR' }, -- Morocco
['mao'] = { '?', '?' }, -- Maori
['me'] = { '', 'MNE' }, -- Montenegro
['mk'] = { '', 'MKD' }, -- Macedonia
['ml'] = { '', 'MLI' }, -- Mali
['mm'] = { '', 'MMR' }, -- Myanmar
['mn'] = { '', 'MNG' }, -- Mongolia
['mt'] = { '', 'MLT' }, -- Malta
['mv'] = { '', 'MDV' }, -- Maldives
['ng'] = { '', 'NGA' }, -- Nigeria
['nl'] = { '', 'NLD' }, -- Netherlands
['no'] = { '', 'NOR' }, -- Norway
['np'] = { '', 'NRL' }, -- Nepal
['ph'] = { '', 'PHL' }, -- Philippines
['pk'] = { '', 'PAK' }, -- Pakistan
['pl'] = { '', 'POL' }, -- Poland
['pt'] = { '', 'PRT' }, -- Portugal
['ro'] = { '', 'ROU' }, -- Romania
['rs'] = { '', 'SRB' }, -- Serbia
['ru'] = { 'Русский (Russia)', 'RUS' }, -- Russia
['se'] = { '', 'SWE' }, -- Sweden
['si'] = { '', 'SVN' }, -- Slovenia
['sk'] = { '', 'SVK' }, -- Slovakia
['sn'] = { '', 'SEN' }, -- Senegal
['sy'] = { '', 'SYR' }, -- Syria
['th'] = { '', 'THA' }, -- Thailand
['tj'] = { '', 'TJK' }, -- Tajikistan
['tm'] = { '', 'TKM' }, -- Turkmenistan
['tr'] = { '', 'TUR' }, -- Turkey
['tw'] = { '', 'TWN' }, -- Taiwan
['tz'] = { '', 'TZA' }, -- Tanzania
['ua'] = { '', 'UKR' }, -- Ukraine
['us'] = { 'English (United States)', 'USA' }, -- USA
['uz'] = { '', 'UZB' }, -- Uzbekistan
['vn'] = { '', 'VNM' }, -- Vietnam
['za'] = { '', 'ZAF' }, -- South Africa
}
local longname, shortname = table.unpack(xkeyboard_country_code[keymap])
local kb_layout_item = wibox.widget {
{
{
{
id = 'shortname',
markup = '<span foreground="' .. Theme_config.kblayout.item.fg_short .. '">' .. shortname .. '</span>',
widget = wibox.widget.textbox,
valign = 'center',
halign = 'center',
},
{
id = 'longname',
markup = '<span foreground="' .. Theme_config.kblayout.item.fg_long .. '">' .. longname .. '</span>',
widget = wibox.widget.textbox,
font = User_config.font.bold,
},
spacing = dpi(15),
layout = wibox.layout.fixed.horizontal,
},
margins = dpi(10),
widget = wibox.container.margin,
},
id = 'hover',
shape = Theme_config.kblayout.item.shape,
border_width = Theme_config.kblayout.item.border_width,
border_color = Theme_config.kblayout.item.border_color,
bg = Theme_config.kblayout.item.bg,
widget = wibox.container.background,
}
kb_helper:connect_signal('KB::layout_changed', function(_, k)
if keymap == k then
kb_layout_item.bg = Theme_config.kblayout.item.bg_selected
kb_layout_item.border_color = Theme_config.kblayout.item.bg_selected
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_selected .. '">' .. shortname .. '</span>'
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_selected .. '">' .. longname .. '</span>'
else
kb_layout_item.bg = Theme_config.kblayout.item.bg
kb_layout_item.border_color = Theme_config.kblayout.item.border_color
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_short .. '">' .. shortname .. '</span>'
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_long .. '">' .. longname .. '</span>'
end
end)
kb_helper:get_layout_async(function(k)
if keymap == k then
kb_layout_item.bg = Theme_config.kblayout.item.bg_selected
kb_layout_item.border_color = Theme_config.kblayout.item.bg_selected
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_selected .. '">' .. shortname .. '</span>'
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_selected .. '">' .. longname .. '</span>'
else
kb_layout_item.bg = Theme_config.kblayout.item.bg
kb_layout_item.border_color = Theme_config.kblayout.item.border_color
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_short .. '">' .. shortname .. '</span>'
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_long .. '">' .. longname .. '</span>'
end
end)
hover.bg_hover { widget = kb_layout_item }
kb_layout_item:buttons { gtable.join(
abutton({}, 1, function()
kb_helper:set_layout(keymap)
--kb_layout_popup.visible = not kb_layout_popup.visible
end)
), }
list:add(kb_layout_item)
end
return widget
end
return setmetatable({}, { __call = function(_, screen)
local kblayout_widget = wibox.widget {
{
{
{
{
{
id = "icon",
widget = wibox.widget.imagebox,
resize = false,
valign = "center",
halign = "center",
image = gears.color.recolor_image(icondir .. "keyboard.svg", Theme_config.kblayout.fg)
},
id = "icon_layout",
widget = wibox.container.place
widget = wibox.widget.imagebox,
resize = true,
valign = 'center',
halign = 'center',
image = gcolor.recolor_image(icondir .. 'keyboard.svg', Theme_config.kblayout.fg),
},
top = dpi(2),
widget = wibox.container.margin,
id = "icon_margin"
widget = wibox.container.constraint,
width = dpi(24),
height = dpi(24),
strategy = 'exact',
},
{
id = 'text_role',
halign = 'center',
valign = 'center',
widget = wibox.widget.textbox,
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "kblayout_layout",
layout = wibox.layout.fixed.horizontal
layout = wibox.layout.fixed.horizontal,
},
id = "container",
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
widget = wibox.container.margin,
},
bg = Theme_config.kblayout.bg,
fg = Theme_config.kblayout.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
}
local function get_kblayout()
awful.spawn.easy_async_with_shell(
[[ setxkbmap -query | grep layout | awk '{print $2}' ]],
function(stdout)
local layout = stdout:gsub("\n", "")
kblayout_widget.container.kblayout_layout.label.text = layout
capi.awesome.emit_signal("update::background:kblayout")
end
)
end
local function create_kb_layout_item(keymap)
-- TODO: Add more, too lazy rn
local longname, shortname
local xkeyboard_country_code = {
{ "af", "أفغانيش(Afghanistan)", "AFG" }, -- Afghanistan
{ "al", "Shqip(Albania)", "ALB" }, -- Albania
{ "am", "Hայերեն(Armenia)", "ARM" }, -- Armenia
{ "ara", "عربي(Arab)", "ARB" }, -- Arabic
{ "at", "Österreichisch (Austria)", "AUT" }, -- Austria
{ "az", "Azərbaycan(Azerbaijan)", "AZE" }, -- Azerbaijan
{ "ba", "Bosanski(Bosnia and Herzegovina)", "BIH" }, -- Bosnia and Herzegovina
{ "bd", "", "BGD" }, -- Bangladesh
{ "be", "", "BEL" }, -- Belgium
{ "bg", "", "BGR" }, -- Bulgaria
{ "br", "", "BRA" }, -- Brazil
{ "bt", "", "BTN" }, -- Bhutan
{ "bw", "", "BWA" }, -- Botswana
{ "by", "", "BLR" }, -- Belarus
{ "ca", "", "CAN" }, -- Canada
{ "cd", "", "COD" }, -- Congo
{ "ch", "", "CHE" }, -- Switzerland
{ "cm", "", "CMR" }, -- Cameroon
{ "cn", "", "CHN" }, -- China
{ "cz", "", "CZE" }, -- Czechia
{ "de", "Deutsch (Germany)", "GER" }, -- Germany
{ "dk", "", "DNK" }, -- Denmark
{ "ee", "", "EST" }, -- Estonia
{ "es", "", "ESP" }, -- Spain
{ "et", "", "ETH" }, -- Ethiopia
{ "eu", "?", "?" }, -- EurKey
{ "fi", "", "FIN" }, -- Finland
{ "fo", "", "FRO" }, -- Faroe Islands
{ "fr", "", "FRA" }, -- France
{ "gb", "English (Bri'ish)", "ENG" }, -- United Kingdom
{ "ge", "", "GEO" }, -- Georgia
{ "gh", "", "GHA" }, -- Ghana
{ "gn", "", "GIN" }, -- Guinea
{ "gr", "", "GRC" }, -- Greece
{ "hr", "", "HRV" }, -- Croatia
{ "hu", "", "HUN" }, -- Hungary
{ "ie", "", "IRL" }, -- Ireland
{ "il", "", "ISR" }, -- Israel
{ "in", "", "IND" }, -- India
{ "iq", "", "IRQ" }, -- Iraq
{ "ir", "", "IRN" }, -- Iran
{ "is", "", "ISL" }, -- Iceland
{ "it", "", "ITA" }, -- Italy
{ "jp", "", "JPN" }, -- Japan
{ "ke", "", "KEN" }, -- Kenya
{ "kg", "", "KGZ" }, -- Kyrgyzstan
{ "kh", "", "KHM" }, -- Cambodia
{ "kr", "", "KOR" }, -- Korea
{ "kz", "", "KAZ" }, -- Kazakhstan
{ "la", "", "LAO" }, -- Laos
{ "latam", "?", "?" }, -- Latin America
{ "latin", "?", "?" }, -- Latin
{ "lk", "", "LKA" }, -- Sri Lanka
{ "lt", "", "LTU" }, -- Lithuania
{ "lv", "", "LVA" }, -- Latvia
{ "ma", "", "MAR" }, -- Morocco
{ "mao", "?", "?" }, -- Maori
{ "me", "", "MNE" }, -- Montenegro
{ "mk", "", "MKD" }, -- Macedonia
{ "ml", "", "MLI" }, -- Mali
{ "mm", "", "MMR" }, -- Myanmar
{ "mn", "", "MNG" }, -- Mongolia
{ "mt", "", "MLT" }, -- Malta
{ "mv", "", "MDV" }, -- Maldives
{ "ng", "", "NGA" }, -- Nigeria
{ "nl", "", "NLD" }, -- Netherlands
{ "no", "", "NOR" }, -- Norway
{ "np", "", "NRL" }, -- Nepal
{ "ph", "", "PHL" }, -- Philippines
{ "pk", "", "PAK" }, -- Pakistan
{ "pl", "", "POL" }, -- Poland
{ "pt", "", "PRT" }, -- Portugal
{ "ro", "", "ROU" }, -- Romania
{ "rs", "", "SRB" }, -- Serbia
{ "ru", "Русский (Russia)", "RUS" }, -- Russia
{ "se", "", "SWE" }, -- Sweden
{ "si", "", "SVN" }, -- Slovenia
{ "sk", "", "SVK" }, -- Slovakia
{ "sn", "", "SEN" }, -- Senegal
{ "sy", "", "SYR" }, -- Syria
{ "th", "", "THA" }, -- Thailand
{ "tj", "", "TJK" }, -- Tajikistan
{ "tm", "", "TKM" }, -- Turkmenistan
{ "tr", "", "TUR" }, -- Turkey
{ "tw", "", "TWN" }, -- Taiwan
{ "tz", "", "TZA" }, -- Tanzania
{ "ua", "", "UKR" }, -- Ukraine
{ "us", "English (United States)", "USA" }, -- USA
{ "uz", "", "UZB" }, -- Uzbekistan
{ "vn", "", "VNM" }, -- Vietnam
{ "za", "", "ZAF" } -- South Africa
}
for _, c in ipairs(xkeyboard_country_code) do
if c[1] == keymap then
longname = c[2]
shortname = c[3]
end
end
local kb_layout_item = wibox.widget {
{
{
-- Short name e.g. GER, ENG, RUS
{
{
text = shortname,
widget = wibox.widget.textbox,
font = User_config.font.extrabold,
id = "shortname"
},
fg = Theme_config.kblayout.item.fg_short,
widget = wibox.container.background,
id = "background2"
},
{
{
text = longname,
widget = wibox.widget.textbox,
font = User_config.font.bold,
id = "longname",
},
fg = Theme_config.kblayout.item.fg_long,
widget = wibox.container.background,
id = "background1"
},
spacing = dpi(15),
layout = wibox.layout.fixed.horizontal,
id = "container"
},
margins = dpi(10),
widget = wibox.container.margin,
id = "margin"
},
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(8))
end,
bg = Theme_config.kblayout.item.bg,
widget = wibox.container.background,
id = "background",
keymap = keymap
}
Hover_signal(kb_layout_item)
capi.awesome.connect_signal(
"update::background:kblayout",
function()
awful.spawn.easy_async_with_shell(
[[ setxkbmap -query | grep layout | awk '{print $2}' ]],
function(stdout)
local layout = stdout:gsub("\n", "")
if kb_layout_item.keymap == layout then
kb_layout_item.bg = Theme_config.kblayout.item.bg_selected
kb_layout_item:get_children_by_id("background2")[1].fg = Theme_config.kblayout.item.fg_selected
kb_layout_item:get_children_by_id("background1")[1].fg = Theme_config.kblayout.item.fg_selected
else
kb_layout_item.bg = Theme_config.kblayout.item.bg
kb_layout_item:get_children_by_id("background2")[1].fg = Theme_config.kblayout.item.fg_short
kb_layout_item:get_children_by_id("background1")[1].fg = Theme_config.kblayout.item.fg_long
end
end
)
end
)
get_kblayout()
kb_layout_item:connect_signal(
"button::press",
function()
awful.spawn.easy_async_with_shell(
"setxkbmap " .. keymap,
function()
capi.awesome.emit_signal("kblayout::hide:kbmenu")
capi.mousegrabber.stop()
get_kblayout()
end
)
end
)
return kb_layout_item
end
local function get_kblist()
local kb_layout_items = {
layout = wibox.layout.fixed.vertical,
spacing = dpi(10)
}
for i, keymap in pairs(User_config.kblayout) do
kb_layout_items[i] = create_kb_layout_item(keymap)
end
local cont = {
{
kb_layout_items,
margins = dpi(10),
widget = wibox.container.margin
},
layout = wibox.layout.fixed.vertical,
}
return cont
end
local kb_menu_widget = awful.popup {
screen = s,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(12))
end,
shape = Theme_config.kblayout.shape,
widget = wibox.container.background,
bg = Theme_config.kblayout.bg_container,
border_width = dpi(4),
border_color = Theme_config.kblayout.border_color_container,
width = dpi(100),
max_height = dpi(600),
visible = false,
}
hover.bg_hover { widget = kblayout_widget }
kb_helper:get_layout_async(function(stdout)
kblayout_widget:get_children_by_id('text_role')[1].text = stdout:gsub('\n', '')
end)
kb_helper:connect_signal('KB::layout_changed', function(_, k)
kblayout_widget:get_children_by_id('text_role')[1].text = k
end)
kb_layout_popup = apopup {
widget = create_kb_layout_list(),
border_color = Theme_config.kblayout.border_color,
border_width = Theme_config.kblayout.border_width,
screen = screen,
ontop = true,
placement = function(c) awful.placement.align(c,
{ position = "top_right", margins = { right = dpi(255), top = dpi(60) } })
end
visible = false,
bg = Theme_config.kblayout.bg_container,
}
kb_menu_widget:connect_signal(
"mouse::leave",
function()
capi.mousegrabber.run(
function()
kblayout_widget.bg = Theme_config.kblayout.bg
capi.awesome.emit_signal("kblayout::hide:kbmenu")
capi.mousegrabber.stop()
return true
end,
"arrow"
)
end
)
kblayout_widget:buttons { gtable.join(
abutton({}, 1, function()
local geo = capi.mouse.coords()
kb_layout_popup.y = dpi(65)
kb_layout_popup.x = geo.x - kb_layout_popup.width / 2
kb_layout_popup.visible = not kb_layout_popup.visible
end)
), }
kb_menu_widget:connect_signal(
"mouse::enter",
function()
mousegrabber.stop()
end
)
kb_menu_widget:setup(
get_kblist()
)
local function toggle_kb_layout()
awful.spawn.easy_async_with_shell(
"setxkbmap -query | grep layout: | awk '{print $2}'",
function(stdout)
for j, n in ipairs(User_config.kblayout) do
if stdout:match(n) then
if j == #User_config.kblayout then
awful.spawn.easy_async_with_shell(
"setxkbmap " .. User_config.kblayout[1],
function()
get_kblayout()
end
)
else
awful.spawn.easy_async_with_shell(
"setxkbmap " .. User_config.kblayout[j + 1],
function()
get_kblayout()
end
)
end
end
end
end
)
end
capi.awesome.connect_signal(
"kblayout::toggle",
function()
toggle_kb_layout()
end
)
-- Signals
Hover_signal(kblayout_widget)
local kblayout_keygrabber = awful.keygrabber {
autostart = false,
stop_event = 'release',
keypressed_callback = function(self, mod, key, command)
capi.awesome.emit_signal("kblayout::hide:kbmenu")
capi.mousegrabber.stop()
end
}
kblayout_widget:connect_signal(
"button::press",
function()
capi.mousegrabber.stop()
if kb_menu_widget.visible then
kb_menu_widget.visible = false
kblayout_keygrabber:stop()
else
kb_menu_widget.visible = true
kblayout_keygrabber:start()
end
end
)
capi.awesome.connect_signal(
"kblayout::hide:kbmenu",
function()
kb_menu_widget.visible = false
kblayout_keygrabber:stop()
end
)
get_kblayout()
kb_menu_widget.visible = false
return kblayout_widget
end
end, })

View File

@@ -3,32 +3,35 @@
----------------------------------
-- Awesome Libs
local abutton = require("awful.button")
local alayout = require("awful.layout")
local awidget = require("awful.widget")
local dpi = require("beautiful").xresources.apply_dpi
local gtable = require("gears.table")
local wibox = require("wibox")
local abutton = require('awful.button')
local alayout = require('awful.layout')
local awidget = require('awful.widget')
local dpi = require('beautiful').xresources.apply_dpi
local gtable = require('gears.table')
local wibox = require('wibox')
-- Local libs
local hover = require('src.tools.hover')
--#region Layout icons
local layout_path = Theme_path .. "../assets/layout/"
local layout_path = Theme_path .. '../assets/layout/'
Theme.layout_cornerne = layout_path .. "cornerne.png"
Theme.layout_cornernw = layout_path .. "cornernw.png"
Theme.layout_cornerse = layout_path .. "cornerse.png"
Theme.layout_cornersw = layout_path .. "cornersw.png"
Theme.layout_dwindle = layout_path .. "dwindle.png"
Theme.layout_fairh = layout_path .. "fairh.png"
Theme.layout_fairv = layout_path .. "fairv.png"
Theme.layout_floating = layout_path .. "floating.png"
Theme.layout_fullscreen = layout_path .. "fullscreen.png"
Theme.layout_magnifier = layout_path .. "magnifier.png"
Theme.layout_max = layout_path .. "max.png"
Theme.layout_spiral = layout_path .. "spiral.png"
Theme.layout_tile = layout_path .. "tile.png"
Theme.layout_tilebottom = layout_path .. "tilebottom.png"
Theme.layout_tileleft = layout_path .. "tileleft.png"
Theme.layout_tiletop = layout_path .. "tiletop.png"
Theme.layout_cornerne = layout_path .. 'cornerne.png'
Theme.layout_cornernw = layout_path .. 'cornernw.png'
Theme.layout_cornerse = layout_path .. 'cornerse.png'
Theme.layout_cornersw = layout_path .. 'cornersw.png'
Theme.layout_dwindle = layout_path .. 'dwindle.png'
Theme.layout_fairh = layout_path .. 'fairh.png'
Theme.layout_fairv = layout_path .. 'fairv.png'
Theme.layout_floating = layout_path .. 'floating.png'
Theme.layout_fullscreen = layout_path .. 'fullscreen.png'
Theme.layout_magnifier = layout_path .. 'magnifier.png'
Theme.layout_max = layout_path .. 'max.png'
Theme.layout_spiral = layout_path .. 'spiral.png'
Theme.layout_tile = layout_path .. 'tile.png'
Theme.layout_tilebottom = layout_path .. 'tilebottom.png'
Theme.layout_tileleft = layout_path .. 'tileleft.png'
Theme.layout_tiletop = layout_path .. 'tiletop.png'
--#endregion
-- Returns the layoutbox widget
@@ -39,22 +42,21 @@ return function()
{
awidget.layoutbox(),
widget = wibox.container.place,
halign = "center",
valign = "center"
},
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin,
},
widget = wibox.container.constraint,
width = dpi(40)
strategy = 'exact',
width = dpi(40),
},
bg = Theme_config.layout_list.bg,
shape = Theme_config.layout_list.shape,
widget = wibox.container.background
widget = wibox.container.background,
}
Hover_signal(layout)
hover.bg_hover { widget = layout }
layout:buttons(gtable.join(
abutton({}, 1, function()

View File

@@ -3,15 +3,14 @@
--------------------------------
-- Awesome Libs
local abutton = require("awful.button")
local apopup = require("awful.popup")
local atooltip = require("awful.tooltip")
local base = require("wibox.widget.base")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local gtable = require("gears.table")
local naughty = require("naughty")
local wibox = require("wibox")
local abutton = require('awful.button')
local apopup = require('awful.popup')
local atooltip = require('awful.tooltip')
local base = require('wibox.widget.base')
local dpi = require('beautiful').xresources.apply_dpi
local gears = require('gears')
local gtable = require('gears.table')
local wibox = require('wibox')
local capi = {
awesome = awesome,
@@ -19,51 +18,79 @@ local capi = {
}
-- Icon directory path
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/network/"
local icondir = gears.filesystem.get_configuration_dir() .. 'src/assets/icons/network/'
local nm_widget = require("src.modules.network_controller.init")
local nm_widget = require('src.modules.network_controller.init')
local hover = require('src.tools.hover')
local network = { mt = {} }
function network.new(args)
args = args or {}
local w = base.make_widget_from_value({
local w = base.make_widget_from_value {
{
{
{
{
id = 'wifi_icon',
image = gears.color.recolor_image(icondir .. "no-internet" .. ".svg", Theme_config.network.fg),
image = gears.color.recolor_image(icondir .. 'no-internet.svg', Theme_config.network.fg),
widget = wibox.widget.imagebox,
resize = false
resize = false,
},
{
id = "wifi_strength",
id = 'wifi_strength',
visible = true,
widget = wibox.widget.textbox
widget = wibox.widget.textbox,
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal
layout = wibox.layout.fixed.horizontal,
},
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
widget = wibox.container.margin,
},
widget = wibox.container.place,
halign = "center",
valign = "center"
halign = 'center',
valign = 'center',
},
bg = Theme_config.network.bg,
fg = Theme_config.network.fg,
shape = Theme_config.network.shape,
widget = wibox.container.background
})
widget = wibox.container.background,
}
Hover_signal(w)
assert(w, 'Failed to create widget')
hover.bg_hover { widget = w }
gtable.crush(w, network, true)
capi.awesome.connect_signal('NM::AccessPointStrength', function(strength)
strength = math.floor(strength)
w:get_children_by_id('wifi_strength')[1].text = strength .. '%'
w:get_children_by_id('wifi_icon')[1].image = gears.color.recolor_image(icondir ..
'wifi-strength-' .. math.floor(strength / 25) + 1 .. '.svg', Theme_config.network.fg)
end)
capi.awesome.connect_signal('NM::EthernetStatus', function(connected, speed)
local tt = atooltip {
objects = { w },
mode = 'outside',
preferred_alignments = 'middle',
margins = dpi(10),
}
if connected then
w:get_children_by_id('wifi_icon')[1].image = gears.color.recolor_image(icondir .. 'ethernet.svg',
Theme_config.network.fg)
tt.text = 'Connected via Ethernet at ' .. math.floor(speed or 0) .. '/Mbps'
else
w:get_children_by_id('wifi_icon')[1].image = gears.color.recolor_image(icondir .. 'no-internet.svg',
Theme_config.network.fg)
tt.text = 'No connection found'
end
end)
local nm = nm_widget { screen = args.screen }
local network_controler_popup = apopup {
@@ -82,25 +109,6 @@ function network.new(args)
end)
))
awesome.connect_signal("NM::AccessPointStrength", function(strength)
strength = math.floor(strength)
w:get_children_by_id("wifi_strength")[1].text = strength .. "%"
w:get_children_by_id("wifi_icon")[1].image = gears.color.recolor_image(icondir ..
"wifi-strength-" .. math.floor(strength / 25) + 1 .. ".svg", Theme_config.network.fg)
end)
nm:connect_signal("NM::Bitrate", function(_, bitrate)
print(bitrate)
end)
atooltip {
objects = { w },
mode = "outside",
preferred_alignments = "middle",
margins = dpi(10),
text = "Connected to " .. "" .. " with " .. "" .. " signal strength"
}
return w
end

View File

@@ -3,65 +3,49 @@
--------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local abutton = require('awful.button')
local gtable = require('gears.table')
local dpi = require('beautiful').xresources.apply_dpi
local wibox = require('wibox')
local gfilesystem = require('gears.filesystem')
local gcolor = require('gears.color')
local capi = {
awesome = awesome,
}
-- Local libs
local powermenu = require('src.modules.powermenu.init')
local hover = require('src.tools.hover')
-- Icon directory path
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/power/"
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/power/'
return function()
return setmetatable({}, { __call = function()
local power_widget = wibox.widget {
{
{
{
{
{
id = "icon",
image = gears.color.recolor_image(icondir .. "power.svg", Theme_config.power_button.fg),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
resize = false
},
id = "icon_layout",
widget = wibox.container.place
},
id = "icon_margin",
top = dpi(2),
widget = wibox.container.margin
},
id = "power_layout",
layout = wibox.layout.fixed.horizontal
image = gcolor.recolor_image(icondir .. 'power.svg', Theme_config.power_button.fg),
widget = wibox.widget.imagebox,
valign = 'center',
halign = 'center',
resize = false,
},
id = "container",
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
widget = wibox.container.margin,
},
bg = Theme_config.power_button.bg,
fg = Theme_config.power_button.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
shape = Theme_config.power_button.shape,
widget = wibox.container.background,
}
-- Signals
Hover_signal(power_widget)
hover.bg_hover { widget = power_widget }
power_widget:connect_signal(
"button::release",
function()
capi.awesome.emit_signal("module::powermenu:show")
end
)
power_widget:buttons { gtable.join(
abutton({}, 1, function()
powermenu:toggle()
end)
), }
return power_widget
end
end, })

View File

@@ -3,19 +3,16 @@
---------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local watch = awful.widget.watch
local wibox = require("wibox")
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gshape = require('gears.shape')
local wibox = require('wibox')
require("src.tools.helpers.ram")
local ram_helper = require('src.tools.helpers.ram')
local hover = require('src.tools.hover')
local capi = {
awesome = awesome,
}
local icon_dir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/cpu/"
local icon_dir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/cpu/'
return function()
local ram_widget = wibox.widget {
@@ -24,53 +21,50 @@ return function()
{
{
{
id = "icon",
id = 'icon',
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
image = gears.color.recolor_image(icon_dir .. "ram.svg", Theme_config.ram_info.fg),
resize = false
valign = 'center',
halign = 'center',
image = gcolor.recolor_image(icon_dir .. 'ram.svg', Theme_config.ram_info.fg),
resize = false,
},
id = "icon_layout",
widget = wibox.container.place
id = 'icon_layout',
widget = wibox.container.place,
},
top = dpi(2),
widget = wibox.container.margin,
id = "icon_margin"
id = 'icon_margin',
},
spacing = dpi(10),
{
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
id = 'label',
align = 'center',
valign = 'center',
widget = wibox.widget.textbox,
},
id = "ram_layout",
layout = wibox.layout.fixed.horizontal
id = 'ram_layout',
layout = wibox.layout.fixed.horizontal,
},
id = "container",
id = 'container',
left = dpi(8),
right = dpi(8),
widget = wibox.container.margin
widget = wibox.container.margin,
},
bg = Theme_config.ram_info.bg,
fg = Theme_config.ram_info.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
gshape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
widget = wibox.container.background,
}
Hover_signal(ram_widget)
hover.bg_hover { widget = ram_widget }
capi.awesome.connect_signal(
"update::ram_widget",
function(MemTotal, MemFree, MemAvailable)
local ram_string = tostring(string.format("%.1f", ((MemTotal - MemAvailable) / 1024 / 1024)) ..
"/" .. string.format("%.1f", (MemTotal / 1024 / 1024)) .. "GB"):gsub(",", ".")
ram_widget.container.ram_layout.label.text = ram_string
end
)
ram_helper:connect_signal('update::ram_widget', function(_, MemTotal, MemFree, MemAvailable)
local ram_string = tostring(string.format('%.1f', ((MemTotal - MemAvailable) / 1024 / 1024)) ..
'/' .. string.format('%.1f', (MemTotal / 1024 / 1024)) .. 'GB'):gsub(',', '.')
ram_widget.container.ram_layout.label.text = ram_string
end)
return ram_widget
end

View File

@@ -3,47 +3,48 @@
--------------------------------
-- Awesome Libs
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local dpi = require('beautiful').xresources.apply_dpi
local wibox = require('wibox')
local capi = {
awesome = awesome,
}
local capi = { awesome = awesome }
-- Systray theme variables
Theme.bg_systray = Theme_config.systray.bg
Theme.systray_icon_spacing = dpi(10)
return function(s)
return function()
local systray = wibox.widget {
{
{
wibox.widget.systray(),
id = 'systray_margin',
widget = wibox.container.margin,
id = 'st'
},
strategy = "exact",
strategy = 'exact',
widget = wibox.container.constraint,
id = "container"
},
widget = wibox.container.background,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
shape = Theme_config.systray.shape,
bg = Theme_config.systray.bg
}
capi.awesome.connect_signal("systray::update", function()
local systray_margin = systray:get_children_by_id('systray_margin')[1]
-- Wait for an systray update
capi.awesome.connect_signal('systray::update', function()
-- Get the number of entries in the systray
local num_entries = capi.awesome.systray()
-- If its 0 remove the margins to hide the widget
if num_entries == 0 then
systray.container.st:set_margins(0)
systray_margin:set_margins(0)
else
systray.container.st:set_margins(dpi(6))
systray_margin:set_margins(dpi(6))
end
end)
systray.container.st.widget:set_base_size(dpi(24))
-- Set the icon size
systray_margin.widget:set_base_size(dpi(24))
return systray
end

View File

@@ -3,178 +3,135 @@
--------------------------------
-- Awesome Libs
local wibox = require("wibox")
local awful = require("awful")
local gears = require("gears")
local dpi = require("beautiful").xresources.apply_dpi
local abutton = require('awful.button')
local ascreen = require('awful.screen')
local atag = require('awful.tag')
local awidget = require('awful.widget')
local dpi = require('beautiful').xresources.apply_dpi
local gtable = require('gears.table')
local wibox = require('wibox')
local capi = {
client = client,
}
-- Local Libs
local hover = require('src.tools.hover')
local capi = { client = client }
local modkey = User_config.modkey
local list_update = function(widget, buttons, _, _, objects)
widget:reset()
local tag_text = {
[1] = '',
[2] = '',
[3] = '',
[4] = '',
[5] = '',
[6] = '',
[7] = '',
[8] = '',
[9] = '',
[10] = '',
}
for _, object in ipairs(objects) do
return setmetatable({}, { __call = function(_, screen)
return awidget.taglist {
filter = awidget.taglist.filter.noempty,
layout = wibox.layout.fixed.horizontal,
screen = screen,
update_function = function(widget, _, _, _, tags)
widget:reset()
-- Create a tag widget for each tag
for _, tag in ipairs(tags) do
local tag_widget = wibox.widget {
{
{
local tag_widget = wibox.widget {
{
text = "",
align = "center",
valign = "center",
visible = true,
font = User_config.font.extrabold,
forced_width = dpi(25),
id = "label",
widget = wibox.widget.textbox
{
{
text = tag_text[tag.index],
halign = 'center',
valign = 'center',
id = 'text_role',
widget = wibox.widget.textbox,
},
id = 'tag_layout',
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
left = dpi(10),
right = dpi(10),
widget = wibox.container.margin,
},
id = "margin",
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin
},
id = "container",
layout = wibox.layout.fixed.horizontal
},
fg = Theme_config.taglist.fg,
bg = Theme_config.taglist.bg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
}
fg = Theme_config.taglist.fg,
bg = Theme_config.taglist.bg,
shape = Theme_config.taglist.shape,
widget = wibox.container.background,
}
local function create_buttons(buttons_t, object_t)
if buttons_t then
local btns = {}
for _, b in ipairs(buttons_t) do
local btn = awful.button {
modifiers = b.modifiers,
button = b.button,
on_press = function()
b:emit_signal('press', object_t)
end,
on_release = function()
b:emit_signal('release', object_t)
-- Add the buttons for each tag
tag_widget:buttons { gtable.join(
abutton({}, 1, function()
tag:view_only()
end),
abutton({ modkey }, 1, function()
if capi.client.focus then
capi.client.focus:move_to_tag(tag)
end
}
btns[#btns + 1] = btn
end),
abutton({}, 3, function()
if capi.client.focus then
capi.client.focus:toggle_tag(tag)
end
end),
abutton({ modkey }, 3, function()
if capi.client.focus then
capi.client.focus:toggle_tag(tag)
end
end),
abutton({}, 4, function()
atag.viewnext(tag.screen)
end),
abutton({}, 5, function()
atag.viewprev(tag.screen)
end)
), }
-- Change the taglist colors depending on the state of the tag
if tag == ascreen.focused().selected_tag then
tag_widget:set_bg(Theme_config.taglist.bg_focus)
tag_widget:set_fg(Theme_config.taglist.fg_focus)
elseif tag.urgent == true then
tag_widget:set_bg(Theme_config.taglist.bg_urgent)
tag_widget:set_fg(Theme_config.taglist.fg_urgent)
else
tag_widget:set_bg(Theme_config.taglist.bg)
tag_widget:set_fg(Theme_config.taglist.fg)
end
return btns
-- Add the client icons to the tag widget
for _, client in ipairs(tag:clients()) do
tag_widget:get_children_by_id('tag_layout')[1]:add(wibox.widget {
{
resize = true,
valign = 'center',
halign = 'center',
image = client.icon or '',
widget = wibox.widget.imagebox,
},
height = dpi(25),
width = dpi(25),
strategy = 'exact',
widget = wibox.container.constraint,
})
end
hover.bg_hover { widget = tag_widget }
widget:add(tag_widget)
widget:set_spacing(dpi(5))
end
end
tag_widget:buttons(create_buttons(buttons, object))
tag_widget.container.margin.label:set_text(object.index)
-- Use the wraper function to call the set_bg and set_fg based on the client state
if object == awful.screen.focused().selected_tag then
tag_widget:set_bg(Theme_config.taglist.bg_focus)
tag_widget:set_fg(Theme_config.taglist.fg_focus)
elseif object.urgent == true then
tag_widget:set_bg(Theme_config.taglist.bg_urgent)
tag_widget:set_fg(Theme_config.taglist.fg_urgent)
else
tag_widget:set_bg(Theme_config.taglist.bg)
tag_widget:set_fg(Theme_config.taglist.fg)
end
--#endregion
-- Set the icon for each client
for _, client in ipairs(object:clients()) do
tag_widget.container.margin:set_right(0)
local icon = wibox.widget {
{
id = "icon_container",
{
id = "icon",
image = Get_icon(client.class, client.name) or client.icon,
resize = true,
valign = "center",
halign = "center",
widget = wibox.widget.imagebox
},
widget = wibox.container.place
},
forced_width = dpi(33),
margins = dpi(6),
widget = wibox.container.margin
}
tag_widget.container:setup({
icon,
strategy = "exact",
layout = wibox.container.constraint,
})
end
Hover_signal(tag_widget)
widget:add(tag_widget)
widget:set_spacing(dpi(6))
end
end
return function(s)
return awful.widget.taglist(
s,
awful.widget.taglist.filter.noempty,
gears.table.join(
awful.button(
{},
1,
function(t)
t:view_only()
end
),
awful.button(
{ modkey },
1,
function(t)
if capi.client.focus then
capi.client.focus:move_to_tag(t)
end
end
),
awful.button(
{},
3,
function(t)
if capi.client.focus then
capi.client.focus:toggle_tag(t)
end
end
),
awful.button(
{ modkey },
3,
function(t)
if capi.client.focus then
capi.client.focus:toggle_tag(t)
end
end
),
awful.button(
{},
4,
function(t)
awful.tag.viewnext(t.screen)
end
),
awful.button(
{},
5,
function(t)
awful.tag.viewprev(t.screen)
end
)
),
{},
list_update,
wibox.layout.fixed.horizontal()
)
end
end,
}
end, })

View File

@@ -3,152 +3,110 @@
---------------------------------
-- Awesome Libs
local awful = require('awful')
local wibox = require('wibox')
local abutton = require('awful.button')
local atooltip = require('awful.tooltip')
local awidget = require('awful.widget')
local dpi = require('beautiful').xresources.apply_dpi
local gears = require('gears')
local gtable = require('gears.table')
local wibox = require('wibox')
local capi = {
client = client,
}
-- Local libs
local hover = require('src.tools.hover')
local list_update = function(widget, buttons, label, _, objects)
widget:reset()
for _, object in ipairs(objects) do
local task_widget = wibox.widget {
{
{
local capi = { client = client }
return setmetatable({}, { __call = function(_, screen)
return awidget.tasklist {
filter = awidget.tasklist.filter.currenttags,
layout = wibox.layout.fixed.horizontal,
screen = screen,
update_function = function(widget, _, _, _, clients)
widget:reset()
-- Create a task widget for each client
for _, client in ipairs(clients) do
local task_widget = wibox.widget {
{
{
nil,
{
id = "icon",
valign = "center",
halign = "center",
resize = true,
image = Get_icon(object.class, object.name) or object.icon,
widget = wibox.widget.imagebox
{
valign = 'center',
halign = 'center',
resize = true,
image = client.icon or '',
widget = wibox.widget.imagebox,
},
width = dpi(25),
height = dpi(25),
strategy = 'exact',
widget = wibox.container.constraint,
},
nil,
layout = wibox.layout.align.horizontal,
id = "layout_icon"
{
id = 'text_role',
halign = 'center',
valign = 'center',
widget = wibox.widget.textbox,
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
forced_width = dpi(33),
margins = dpi(3),
right = dpi(10),
left = dpi(10),
widget = wibox.container.margin,
id = "margin"
},
{
text = "",
align = "center",
valign = "center",
visible = true,
widget = wibox.widget.textbox,
id = "title"
},
layout = wibox.layout.fixed.horizontal,
id = "layout_it"
},
right = dpi(5),
left = dpi(5),
widget = wibox.container.margin,
id = "container"
},
fg = Theme_config.tasklist.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
widget = wibox.container.background
}
fg = Theme_config.tasklist.fg,
bg = Theme_config.tasklist.bg,
shape = Theme_config.tasklist.shape,
widget = wibox.container.background,
}
local task_tool_tip = awful.tooltip {
objects = { task_widget },
mode = "inside",
preferred_alignments = "middle",
preferred_positions = "bottom",
margins = dpi(10),
gaps = 0,
delay_show = 1
}
local function create_buttons(buttons_t, object_t)
if buttons_t then
local btns = {}
for _, b in ipairs(buttons_t) do
local btn = awful.button {
modifiers = b.modifiers,
button = b.button,
on_press = function()
b:emit_signal('press', object_t)
end,
on_release = function()
b:emit_signal('release', object_t)
task_widget:buttons { gtable.join(
abutton({}, 1, nil, function()
if client == capi.client.focus then
client.minimized = true
else
client.minimized = false
if not client:isvisible() and client.first_tag then
client.first_tag:view_only()
end
client:emit_signal('request::activate')
client:raise()
end
end),
abutton({}, 3, function(c)
client:kill()
end)
), }
local label = User_config.taskbar_use_name and client.name or client.class or ''
-- If the client is focused, show the tooltip and add a label
if client == capi.client.focus then
atooltip {
text = label,
objects = { task_widget },
mode = 'outside',
preferred_alignments = 'middle',
preferred_positions = 'bottom',
margins = dpi(10),
delay_show = 1,
}
btns[#btns + 1] = btn
task_widget:get_children_by_id('text_role')[1].text = label:sub(1, 20)
task_widget.bg = Theme_config.tasklist.bg_focus
task_widget.fg = Theme_config.tasklist.fg_focus
else
task_widget.bg = Theme_config.tasklist.bg
task_widget:get_children_by_id('text_role')[1].text = ''
end
return btns
hover.bg_hover { widget = task_widget }
widget:add(task_widget)
widget:set_spacing(dpi(5))
end
end
task_widget:buttons(create_buttons(buttons, object))
local client_string = User_config.taskbar_use_name and object.name or object.class
if object == capi.client.focus then
if client_string == nil or client_string == '' then
task_widget.container.layout_it.title:set_margins(0)
else
task_tool_tip:set_text(client_string)
task_tool_tip:add_to_object(task_widget)
task_widget.container.layout_it.title:set_text(client_string:sub(1, 20))
end
task_widget:set_bg(Theme_config.tasklist.bg_focus)
task_widget:set_fg(Theme_config.tasklist.fg_focus)
else
task_widget:set_bg(Theme_config.tasklist.bg)
task_widget.container.layout_it.title:set_text('')
end
Hover_signal(task_widget)
widget:add(task_widget)
widget:set_spacing(dpi(6))
end
return widget
end
return function(s)
return awful.widget.tasklist(
s,
awful.widget.tasklist.filter.currenttags,
awful.util.table.join(
awful.button(
{},
1,
function(c)
if c == capi.client.focus then
c.minimized = true
else
c.minimized = false
if not c:isvisible() and c.first_tag then
c.first_tag:view_only()
end
c:emit_signal('request::activate')
c:raise()
end
end
),
awful.button(
{},
3,
function(c)
c:kill()
end
)
),
{},
list_update,
wibox.layout.fixed.horizontal()
)
end
return widget
end,
}
end, })