worked on some stuff and finally the new install script (no idea if it works yet)

This commit is contained in:
Rene Kievits
2023-10-25 15:01:31 +02:00
parent bf8520ed9d
commit 294b15e9ea
28 changed files with 1439 additions and 1147 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 KiB

After

Width:  |  Height:  |  Size: 229 KiB

View File

@@ -240,7 +240,9 @@ return gtable.join(
{}, {},
'XF86AudioLowerVolume', 'XF86AudioLowerVolume',
function(c) function(c)
audio_helper.sink_volume_down() -- When changing the volume it makes sense to unmute
audio_helper:sink_volume_down()
audio_helper:sink_unmute()
end, end,
{ description = 'Lower volume', group = 'System' } { description = 'Lower volume', group = 'System' }
), ),
@@ -248,7 +250,9 @@ return gtable.join(
{}, {},
'XF86AudioRaiseVolume', 'XF86AudioRaiseVolume',
function(c) function(c)
audio_helper.sink_volume_up() -- When changing the volume it makes sense to unmute
audio_helper:sink_volume_up()
audio_helper:sink_unmute()
end, end,
{ description = 'Increase volume', group = 'System' } { description = 'Increase volume', group = 'System' }
), ),
@@ -256,7 +260,7 @@ return gtable.join(
{}, {},
'XF86AudioMute', 'XF86AudioMute',
function(c) function(c)
audio_helper.sink_toggle_mute() audio_helper:sink_toggle_mute()
end, end,
{ description = 'Mute volume', group = 'System' } { description = 'Mute volume', group = 'System' }
), ),
@@ -330,8 +334,8 @@ return gtable.join(
-- Check if data already had the client then return -- Check if data already had the client then return
for _, v in ipairs(data) do for _, v in ipairs(data) do
if v.WM_NAME == client_data.WM_NAME and if v.WM_NAME == client_data.WM_NAME and
v.WM_CLASS == client_data.WM_CLASS and v.WM_CLASS == client_data.WM_CLASS and
v.WM_INSTANCE == client_data.WM_INSTANCE then v.WM_INSTANCE == client_data.WM_INSTANCE then
return return
end end
end end
@@ -375,7 +379,7 @@ return gtable.join(
-- Remove client_data from data_table -- Remove client_data from data_table
for k, v in ipairs(data) do for k, v in ipairs(data) do
if v.WM_CLASS == client_data.WM_CLASS and if v.WM_CLASS == client_data.WM_CLASS and
v.WM_INSTANCE == client_data.WM_INSTANCE then v.WM_INSTANCE == client_data.WM_INSTANCE then
table.remove(data, k) table.remove(data, k)
ruled.client.remove_rule { ruled.client.remove_rule {
rule = { class = c.class, instance = c.instance }, rule = { class = c.class, instance = c.instance },

View File

@@ -48,7 +48,6 @@ if not instance then
raise = true, raise = true,
}) })
end end
collectgarbage('collect')
end) end)
capi.tag.connect_signal('property::selected', function(c) capi.tag.connect_signal('property::selected', function(c)

View File

@@ -0,0 +1,153 @@
-----------------------------------
-- This is the volume_old module --
-----------------------------------
-- Awesome Libs
local aplacement = require('awful.placement')
local apopup = require('awful.popup')
local beautiful = require('beautiful')
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gshape = require('gears.shape')
local gtable = require('gears.table')
local gtimer = require('gears.timer')
local wibox = require('wibox')
local audio_helper = require('src.tools.helpers.audio')
-- Icon directory path
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/audio/'
local capi = {
awesome = awesome,
}
local osd = {}
function osd:display()
self.popup.visible = true
if self.timer.started then
self.timer:again()
else
self.timer:start()
end
end
local instance = nil
if not instance then
instance = setmetatable(osd, {
__call = function(self, ...)
local args = ... or {}
self.popup = apopup {
widget = {
{
{
{ -- Volume Icon
{
image = gcolor.recolor_image(icondir .. 'volume-off.svg',
beautiful.colorscheme.bg_yellow),
resize = true,
id = 'icon_role',
widget = wibox.widget.imagebox,
},
widget = wibox.container.constraint,
width = dpi(36),
height = dpi(36),
strategy = 'exact',
},
{
widget = wibox.container.constraint,
width = dpi(24),
strategy = 'exact',
},
{ -- Volume Bar
{
{
id = 'progressbar',
value = 0,
max_value = 100,
color = beautiful.colorscheme.bg_yellow,
background_color = beautiful.colorscheme.bg1,
shape = gshape.rounded_rect,
widget = wibox.widget.progressbar,
},
widget = wibox.container.constraint,
width = dpi(250),
height = dpi(12),
},
widget = wibox.container.place,
},
{ -- Value text
{
widget = wibox.widget.textbox,
halign = 'right',
id = 'text_role',
text = 'NAN%',
},
widget = wibox.container.constraint,
width = dpi(60),
strategy = 'min',
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
margins = dpi(20),
widget = wibox.container.margin,
},
shape = beautiful.shape[12],
widget = wibox.container.background,
},
ontop = true,
stretch = false,
visible = true,
border_color = beautiful.colorscheme.border_color,
border_width = dpi(2),
fg = beautiful.colorscheme.fg,
bg = beautiful.colorscheme.bg,
screen = 1,
placement = function(c) aplacement.bottom(c, { margins = dpi(20) }) end,
}
self.popup.visible = false
self.timer = gtimer {
timeout = args.display_time or 3,
autostart = true,
callback = function()
self.popup.visible = false
end,
}
local volume_icon = self.popup.widget:get_children_by_id('icon_role')[1]
local volume_text = self.popup.widget:get_children_by_id('text_role')[1]
local volume_progressbar = self.popup.widget:get_children_by_id('progressbar')[1]
audio_helper:connect_signal('sink::get', function(_, muted, volume)
volume = tonumber(volume or 0)
local icon = 'volume-mute.svg'
if muted then
volume_progressbar.value = 0
else
volume_progressbar.value = volume
icon = icondir .. 'volume'
if volume < 1 then
icon = icon .. '-mute'
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
end
volume_icon:set_image(gcolor.recolor_image(icon .. '.svg', beautiful.colorscheme.bg_yellow))
volume_text.text = volume .. '%'
self:display()
end)
end,
})
end
return instance

View File

@@ -1,139 +0,0 @@
-----------------------------------
-- This is the volume_old module --
-----------------------------------
-- Awesome Libs
local aplacement = require('awful.placement')
local apopup = require('awful.popup')
local beautiful = require('beautiful')
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gshape = require('gears.shape')
local gtable = require('gears.table')
local gtimer = require('gears.timer')
local wibox = require('wibox')
local audio_helper = require('src.tools.helpers.audio')
-- Icon directory path
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/audio/'
local osd = {}
function osd:run()
self.visible = true
if self.timer.started then
self.timer:again()
else
self.timer:start()
end
end
function osd.new(args)
args = args or {}
args.screen = args.screen or 1
local w = apopup {
widget = {
{
{
{ -- Volume Icon
{
image = gcolor.recolor_image(icondir .. 'volume-off.svg', beautiful.colorscheme.bg_purple),
valign = 'center',
halign = 'center',
resize = true,
id = 'icon_role',
widget = wibox.widget.imagebox,
},
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
{ -- Volume Bar
{
{
id = 'progressbar',
color = beautiful.colorscheme.bg_purple,
background_color = beautiful.colorscheme.bg1,
max_value = 100,
value = 0,
shape = gshape.rounded_rect,
widget = wibox.widget.progressbar,
},
widget = wibox.container.constraint,
width = dpi(250),
height = dpi(5),
},
widget = wibox.container.place,
},
{ -- Volume text
widget = wibox.widget.textbox,
id = 'text_role',
text = '0',
valign = 'center',
halign = 'center',
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
left = dpi(10),
right = dpi(10),
top = dpi(20),
bottom = dpi(20),
widget = wibox.container.margin,
},
shape = beautiful.shape[12],
widget = wibox.container.background,
},
ontop = true,
stretch = false,
visible = false,
border_color = beautiful.colorscheme.border_color,
border_width = dpi(2),
fg = beautiful.colorscheme.bg_purple,
bg = beautiful.colorscheme.bg,
screen = 1,
placement = function(c) aplacement.bottom(c, { margins = dpi(20) }) end,
}
gtable.crush(w, osd)
w.timer = gtimer {
timeout = 2,
autostart = true,
callback = function()
w.visible = false
end,
}
audio_helper:connect_signal('output::get', function(_, muted, volume)
volume = tonumber(volume or 0)
if muted then
w.widget:get_children_by_id('icon_role')[1]:set_image(gcolor.recolor_image(icondir .. 'volume-mute' .. '.svg', beautiful.colorscheme.bg_purple))
w.widget:get_children_by_id('progressbar')[1].value = 0
else
w.widget:get_children_by_id('progressbar')[1].value = volume
local icon = icondir .. 'volume'
if volume < 1 then
icon = icon .. '-mute'
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
w.widget:get_children_by_id('icon_role')[1]:set_image(gcolor.recolor_image(icon .. '.svg', beautiful.colorscheme.bg_purple))
w.widget:get_children_by_id('text_role')[1].text = volume
end
w:run()
end)
return w
end
return setmetatable(osd, { __call = function(_, ...) return osd.new(...) end })

View File

@@ -227,7 +227,8 @@ function device.new(args)
widget = wibox.container.margin, widget = wibox.container.margin,
}, },
widget = wibox.container.background, widget = wibox.container.background,
}, spacing = dpi(10), },
spacing = dpi(10),
entries = { entries = {
{ -- Connect/Disconnect a device { -- Connect/Disconnect a device
name = ret.device.Connected and 'Disconnect' or 'Connect', name = ret.device.Connected and 'Disconnect' or 'Connect',

File diff suppressed because it is too large Load Diff

View File

@@ -1,144 +0,0 @@
---------------------------------------
-- This is the brightness_osd module --
---------------------------------------
-- Awesome Libs
local aplacement = require('awful.placement')
local apopup = require('awful.popup')
local beautiful = require('beautiful')
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gshape = require('gears.shape')
local gtable = require('gears.table')
local gtimer = require('gears.timer')
local wibox = require('wibox')
local backlight_helper = require('src.tools.helpers.backlight')
local capi = {
awesome = awesome,
mouse = mouse,
}
-- Icon directory path
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/brightness/'
local brightness_osd = { mt = {} }
-- Hide the brightness_osd after 3 seconds
function brightness_osd:run()
self.visible = true
if self.timer.started then
self.timer:again()
else
self.timer:start()
end
end
function brightness_osd.new(args)
args = args or {}
local w = apopup {
widget = {
{
{
{ -- Brightness Icon
{
image = gcolor.recolor_image(icondir .. 'volume-off.svg', beautiful.colorscheme.bg_blue),
valign = 'center',
halign = 'center',
resize = true,
id = 'icon_role',
widget = wibox.widget.imagebox,
},
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
{ -- Brightness Bar
{
{
id = 'progressbar',
color = beautiful.colorscheme.bg_blue,
background_color = beautiful.colorscheme.bg,
max_value = 100,
value = 0,
shape = gshape.rounded_rect,
widget = wibox.widget.progressbar,
},
widget = wibox.container.constraint,
width = dpi(250),
height = dpi(5),
},
widget = wibox.container.place,
},
{ -- Brightness text
widget = wibox.widget.textbox,
id = 'text_role',
text = '0',
valign = 'center',
halign = 'center',
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
left = dpi(10),
right = dpi(10),
top = dpi(20),
bottom = dpi(20),
widget = wibox.container.margin,
},
shape = beautiful.shape[4],
widget = wibox.container.background,
},
ontop = true,
stretch = false,
visible = false,
border_color = beautiful.colorscheme.border_color,
border_width = dpi(2),
fg = beautiful.colorscheme.bg_blue,
bg = beautiful.colorscheme.bg,
screen = 1,
placement = function(c) aplacement.bottom(c, { margins = dpi(20) }) end,
}
gtable.crush(w, brightness_osd, true)
w.timer = gtimer {
timeout = 2,
autostart = true,
callback = function()
w.visible = false
end,
}
backlight_helper:connect_signal('brightness_changed', function()
backlight_helper:brightness_get_async(function(brightness)
brightness = brightness / (backlight_helper.brightness_max or 24000) * 100
w.widget:get_children_by_id('progressbar')[1].value = brightness
local icon = icondir .. 'brightness'
if brightness >= 0 and brightness < 34 then
icon = icon .. '-low.svg'
elseif brightness >= 34 and brightness < 67 then
icon = icon .. '-medium.svg'
elseif brightness >= 67 then
icon = icon .. '-high.svg'
end
w.widget:get_children_by_id('icon')[1]:set_image(gcolor.recolor_image(icon, beautiful.colorscheme.bg_blue))
w.widget:get_children_by_id('text_role')[1].text = brightness
w:run()
end)
end)
return w
end
function brightness_osd.mt:__call(...)
return brightness_osd.new(...)
end
return setmetatable(brightness_osd, brightness_osd.mt)

View File

@@ -0,0 +1,154 @@
local setmetatable = setmetatable
local apopup = require('awful.popup')
local aplacement = require('awful.placement')
local beautiful = require('beautiful')
local dpi = beautiful.xresources.apply_dpi
local gcolor = require('gears.color')
local gobject = require('gears.object')
local gtable = require('gears.table')
local gtimer = require('gears.timer')
local gfilesystem = require('gears.filesystem')
local gshape = require('gears.shape')
local wibox = require('wibox')
local backlight_helper = require('src.tools.helpers.backlight')
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/brightness/'
local capi = {
awesome = awesome,
}
local osd = gobject {}
-- Show the popup for x seconds, default is 3
function osd:display()
self.popup.visible = true
if self.timer.started then
self.timer:again()
else
self.timer:start()
end
end
local instance = nil
if not instance then
instance = setmetatable(osd, {
---Create a backlight osd that shows when the backlight is changed
---@param ... table[display_time]
__call = function(self, ...)
local args = ... or {}
-- Set to visible on creation so the popup is cached on startup
self.popup = apopup {
widget = {
{
{
{ -- Icon
{
image = gcolor.recolor_image(icondir .. 'brightness-high.svg',
beautiful.colorscheme.bg_blue),
resize = true,
id = 'icon_role',
widget = wibox.widget.imagebox,
},
widget = wibox.container.constraint,
width = dpi(36),
height = dpi(36),
strategy = 'exact',
},
{
widget = wibox.container.constraint,
width = dpi(24),
strategy = 'exact',
},
{ -- Progressbar
{
{
id = 'progressbar',
value = 0,
max_value = 100,
color = beautiful.colorscheme.bg_blue,
background_color = beautiful.colorscheme.bg1,
shape = gshape.rounded_rect,
widget = wibox.widget.progressbar,
},
widget = wibox.container.constraint,
width = dpi(250),
height = dpi(12),
},
widget = wibox.container.place,
},
{ -- Value text
{
widget = wibox.widget.textbox,
halign = 'right',
id = 'text_role',
text = 'NAN%',
},
widget = wibox.container.constraint,
width = dpi(60),
strategy = 'min',
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
widget = wibox.container.margin,
margins = dpi(20),
},
widget = wibox.container.background,
shape = beautiful.shape[12],
},
ontop = true,
stretch = false,
visible = true,
border_color = beautiful.colorscheme.border_color,
border_width = dpi(2),
fg = beautiful.colorscheme.fg,
bg = beautiful.colorscheme.bg,
screen = 1,
placement = function(c) aplacement.bottom(c, { margins = dpi(20) }) end,
}
self.popup.visible = false
self.timer = gtimer {
timeout = args.display_time or 3,
autostart = true,
callback = function()
self.popup.visible = false
end,
}
local progressbar = self.popup.widget:get_children_by_id('progressbar')[1]
local brightness_text = self.popup.widget:get_children_by_id('text_role')[1]
local brightness_icon = self.popup.widget:get_children_by_id('icon_role')[1]
backlight_helper:connect_signal('brightness_changed', function()
backlight_helper.brightness_get_async(function(brightness)
if not brightness then return end
brightness = math.floor((tonumber(brightness) / (backlight_helper.brightness_max or 24000) * 100) + 0.5)
local icon = icondir .. 'brightness'
if brightness >= 0 and brightness < 34 then
icon = icon .. '-low.svg'
elseif brightness >= 34 and brightness < 67 then
icon = icon .. '-medium.svg'
elseif brightness >= 67 then
icon = icon .. '-high.svg'
end
brightness_icon.image = gcolor.recolor_image(icon,
beautiful.colorscheme.bg_blue)
progressbar.value = brightness
brightness_text.text = brightness .. '%'
self:display()
end)
end)
return self
end,
})
end
return instance

View File

@@ -101,7 +101,9 @@ function dock:get_element_widget(desktop_file)
if not desktop_file then return end if not desktop_file then return end
local GDesktopAppInfo = Gio.DesktopAppInfo.new_from_filename(desktop_file) local GDesktopAppInfo = Gio.DesktopAppInfo.new_from_filename(desktop_file)
if not GDesktopAppInfo then
return
end
local icon = icon_lookup:get_gicon_path(nil, GDesktopAppInfo.get_string(GDesktopAppInfo, 'Icon')) or local icon = icon_lookup:get_gicon_path(nil, GDesktopAppInfo.get_string(GDesktopAppInfo, 'Icon')) or
icon_lookup:get_gicon_path(nil, Gio.DesktopAppInfo.get_string(GDesktopAppInfo, 'X-AppImage-Old-Icon')) or '' icon_lookup:get_gicon_path(nil, Gio.DesktopAppInfo.get_string(GDesktopAppInfo, 'X-AppImage-Old-Icon')) or ''

View File

@@ -30,6 +30,8 @@ if not instance then
end) end)
require('src.modules.app_launcher')() require('src.modules.app_launcher')()
require('src.modules.powermenu')() require('src.modules.powermenu')()
require('src.modules.brightness')()
require('src.modules.audio')()
end, end,
}) })
end end

View File

@@ -454,9 +454,9 @@ end
local button_signal = function(self, x, y, button) local button_signal = function(self, x, y, button)
if button == 1 then if button == 1 then
self:set_cursor_pos_from_mouse(x, y) --self:set_cursor_pos_from_mouse(x, y)
self:start_mousegrabber(x, y) --self:start_mousegrabber(x, y)
self:start_keygrabber() --self:start_keygrabber()
end end
end end

View File

@@ -380,7 +380,7 @@ function network:add_ap_to_list(ap)
halign = 'center', halign = 'center',
widget = wibox.widget.imagebox, widget = wibox.widget.imagebox,
}, },
strategy = 'max', strategy = 'exact',
height = dpi(24), height = dpi(24),
width = dpi(24), width = dpi(24),
widget = wibox.container.constraint, widget = wibox.container.constraint,

View File

@@ -15,7 +15,7 @@ local rubato = require('src.lib.rubato')
-- Own Libs -- Own Libs
local audio = require('src.tools.helpers.audio') local audio = require('src.tools.helpers.audio')
local backlight = require('src.tools.helpers.backlight') local backlight_helper = require('src.tools.helpers.backlight')
--local battery = require('src.tools.helpers.battery') --local battery = require('src.tools.helpers.battery')
local cpu_usage = require('src.tools.helpers.cpu_usage') local cpu_usage = require('src.tools.helpers.cpu_usage')
local cpu_temp = require('src.tools.helpers.cpu_temp') local cpu_temp = require('src.tools.helpers.cpu_temp')
@@ -26,250 +26,277 @@ local gpu_temp = require('src.tools.helpers.gpu_temp')
-- Icon directory path -- Icon directory path
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/' local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/'
return setmetatable({}, { __call = function() local capi = {
awesome = awesome,
}
---Creates a layout with bar widgets based on the given table return setmetatable({}, {
---@param widget_table table __call = function()
---@return table ---Creates a layout with bar widgets based on the given table
local function create_bar_layout(widget_table) ---@param widget_table table
local bar_layout = { layout = wibox.layout.flex.horizontal, spacing = dpi(10) } ---@return table
local function create_bar_layout(widget_table)
local bar_layout = { layout = wibox.layout.flex.horizontal, spacing = dpi(10) }
for _, widget in pairs(widget_table) do for _, widget in pairs(widget_table) do
local w = base.make_widget_from_value { local w = base.make_widget_from_value {
{
{ {
{ {
{ --Bar {
color = beautiful.colorscheme.bg_teal, { --Bar
background_color = beautiful.colorscheme.bg1, color = beautiful.colorscheme.bg_teal,
max_value = 100, background_color = beautiful.colorscheme.bg1,
value = 0, max_value = 100,
forced_height = dpi(8), value = 0,
shape = function(cr) forced_height = dpi(8),
gears.shape.rounded_bar(cr, dpi(58), dpi(8)) shape = function(cr)
end, gears.shape.rounded_bar(cr, dpi(58), dpi(8))
id = 'progress_role', end,
widget = wibox.widget.progressbar, id = 'progress_role',
widget = wibox.widget.progressbar,
},
halign = 'center',
valign = 'center',
widget = wibox.container.place,
}, },
direction = 'east',
widget = wibox.container.rotate,
},
widget = wibox.container.constraint,
height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
width = dpi(24),
strategy = 'exact',
},
{
{ --Icon
id = 'image_role',
halign = 'center', halign = 'center',
valign = 'center', valign = 'center',
widget = wibox.container.place, widget = wibox.widget.imagebox,
}, },
direction = 'east', height = dpi(24),
widget = wibox.container.rotate, width = dpi(24),
widget = wibox.container.constraint,
}, },
widget = wibox.container.constraint, spacing = dpi(10),
height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58 layout = wibox.layout.fixed.vertical,
width = dpi(24), }
strategy = 'exact',
},
{
{ --Icon
id = 'image_role',
halign = 'center',
valign = 'center',
widget = wibox.widget.imagebox,
},
height = dpi(24),
width = dpi(24),
widget = wibox.container.constraint,
},
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
}
assert(type(w) == 'table', 'Widget creation failed') assert(type(w) == 'table', 'Widget creation failed')
local bar = w:get_children_by_id('progress_role')[1] local bar = w:get_children_by_id('progress_role')[1]
local rubato_timer = rubato.timed { local rubato_timer = rubato.timed {
duration = 1, duration = 1,
pos = bar.value, pos = bar.value,
easing = rubato.linear, easing = rubato.linear,
subscribed = function(v) subscribed = function(v)
bar.value = v bar.value = v
end, end,
} }
local tooltip = awful.tooltip { local tooltip = awful.tooltip {
objects = { w }, objects = { w },
mode = 'inside', mode = 'inside',
preferred_alignments = 'middle', preferred_alignments = 'middle',
margins = dpi(10), margins = dpi(10),
} }
if widget == 'cpu_usage' then if widget == 'cpu_usage' then
cpu_usage:connect_signal('update::cpu_usage', function(_, v) cpu_usage:connect_signal('update::cpu_usage', function(_, v)
if not v then return nil end if not v then return nil end
tooltip.text = 'CPU Usage: ' .. v .. '%' tooltip.text = 'CPU Usage: ' .. v .. '%'
rubato_timer.target = v rubato_timer.target = v
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/cpu.svg', w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/cpu.svg',
beautiful.colorscheme.bg_teal) beautiful.colorscheme.bg_teal)
end) end)
elseif widget == 'cpu_temp' then elseif widget == 'cpu_temp' then
cpu_temp:connect_signal('update::cpu_temp', function(_, v) cpu_temp:connect_signal('update::cpu_temp', function(_, v)
if not v then return nil end if not v then return nil end
local temp_icon local temp_icon
if v < 50 then if v < 50 then
temp_icon = icondir .. 'cpu/thermometer-low.svg'
elseif v >= 50 and v < 80 then
temp_icon = icondir .. 'cpu/thermometer.svg'
elseif v >= 80 then
temp_icon = icondir .. 'cpu/thermometer-high.svg'
end
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(temp_icon,
beautiful.colorscheme.bg_blue)
tooltip.text = 'CPU Temp: ' .. v .. '°C'
rubato_timer.target = v
end)
elseif widget == 'ram_usage' then
ram:connect_signal('update::ram_widget', function(_, MemTotal, _, MemAvailable)
if not MemTotal and MemAvailable then return nil end
if not MemTotal or not MemAvailable then return end
local ram_usage = math.floor(((MemTotal - MemAvailable) / MemTotal * 100) + 0.5)
tooltip.text = 'RAM Usage: ' .. ram_usage .. '%'
rubato_timer.target = ram_usage
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/ram.svg',
beautiful.colorscheme.bg_red)
end)
elseif widget == 'gpu_usage' then
gpu_usage:connect_signal('update::gpu_usage', function(_, v)
if not v then return nil end
tooltip.text = 'GPU Usage: ' .. v .. '%'
rubato_timer.target = tonumber(v)
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/gpu.svg',
beautiful.colorscheme.bg_green)
end)
elseif widget == 'gpu_temp' then
gpu_temp:connect_signal('update::gpu_temp', function(_, v)
if not v then return nil end
local temp_icon, temp_num
if v then
temp_num = tonumber(v)
if temp_num < 50 then
temp_icon = icondir .. 'cpu/thermometer-low.svg' temp_icon = icondir .. 'cpu/thermometer-low.svg'
elseif temp_num >= 50 and temp_num < 80 then elseif v >= 50 and v < 80 then
temp_icon = icondir .. 'cpu/thermometer.svg' temp_icon = icondir .. 'cpu/thermometer.svg'
elseif temp_num >= 80 then elseif v >= 80 then
temp_icon = icondir .. 'cpu/thermometer-high.svg' temp_icon = icondir .. 'cpu/thermometer-high.svg'
end end
else w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(temp_icon,
temp_num = 'NaN' beautiful.colorscheme.bg_blue)
temp_icon = icondir .. 'cpu/thermometer-low.svg' tooltip.text = 'CPU Temp: ' .. v .. '°C'
end rubato_timer.target = v
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(temp_icon, end)
beautiful.colorscheme.bg_green) elseif widget == 'ram_usage' then
tooltip.text = 'GPU Temp: ' .. temp_num .. '°C' ram:connect_signal('update::ram_widget', function(_, MemTotal, _, MemAvailable)
rubato_timer.target = temp_num if not MemTotal and MemAvailable then return nil end
end) if not MemTotal or not MemAvailable then return end
elseif widget == 'volume' then local ram_usage = math.floor(((MemTotal - MemAvailable) / MemTotal * 100) + 0.5)
audio:connect_signal('sink::get', function(_, muted, volume) tooltip.text = 'RAM Usage: ' .. ram_usage .. '%'
if not volume and muted then return nil end rubato_timer.target = ram_usage
local icon = icondir .. 'audio/volume' w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/ram.svg',
volume = tonumber(volume) beautiful.colorscheme.bg_red)
if not volume then end)
return elseif widget == 'gpu_usage' then
end gpu_usage:connect_signal('update::gpu_usage', function(_, v)
if muted then if not v then return nil end
icon = icon .. '-mute' tooltip.text = 'GPU Usage: ' .. v .. '%'
else rubato_timer.target = v
if volume < 1 then w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/gpu.svg',
icon = icon .. '-mute' beautiful.colorscheme.bg_green)
elseif volume >= 1 and volume < 34 then end)
icon = icon .. '-low' elseif widget == 'gpu_temp' then
elseif volume >= 34 and volume < 67 then gpu_temp:connect_signal('update::gpu_temp', function(_, v)
icon = icon .. '-medium' if not v then return nil end
elseif volume >= 67 then local temp_icon, temp_num
icon = icon .. '-high'
if v then
temp_num = tonumber(v)
if temp_num < 50 then
temp_icon = icondir .. 'cpu/thermometer-low.svg'
elseif temp_num >= 50 and temp_num < 80 then
temp_icon = icondir .. 'cpu/thermometer.svg'
elseif temp_num >= 80 then
temp_icon = icondir .. 'cpu/thermometer-high.svg'
end
else
temp_num = 'NaN'
temp_icon = icondir .. 'cpu/thermometer-low.svg'
end end
end w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(temp_icon,
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icon .. '.svg', beautiful.colorscheme.bg_green)
beautiful.colorscheme.bg_yellow) tooltip.text = 'GPU Temp: ' .. temp_num .. '°C'
tooltip.text = 'Volume: ' .. volume .. '%' rubato_timer.target = temp_num
rubato_timer.target = volume end)
end) elseif widget == 'volume' then
elseif widget == 'microphone' then audio:connect_signal('sink::get', function(_, muted, volume)
audio:connect_signal('source::get', function(_, muted, volume) if not volume and muted then return nil end
if not volume and muted then return nil end local icon = icondir .. 'audio/volume'
if not volume then volume = tonumber(volume)
return if not volume then
end return
local icon = icondir .. 'audio/microphone' end
volume = tonumber(volume) if muted then
if not volume then icon = icon .. '-mute'
return else
end if volume < 1 then
if muted or (volume < 1) then icon = icon .. '-mute'
icon = icon .. '-off' elseif volume >= 1 and volume < 34 then
end icon = icon .. '-low'
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icon .. '.svg', elseif volume >= 34 and volume < 67 then
beautiful.colorscheme.bg_blue) icon = icon .. '-medium'
tooltip.text = 'Microphone: ' .. volume .. '%' elseif volume >= 67 then
rubato_timer.target = volume icon = icon .. '-high'
end) end
elseif widget == 'backlight' then end
backlight:connect_signal('brightness::get', function(_, v) w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icon .. '.svg',
if not v then return nil end beautiful.colorscheme.bg_yellow)
local icon = icondir .. 'brightness' tooltip.text = 'Volume: ' .. volume .. '%'
if v >= 0 and v < 34 then rubato_timer.target = volume
icon = icon .. '-low' end)
elseif v >= 34 and v < 67 then elseif widget == 'microphone' then
icon = icon .. '-medium' audio:connect_signal('source::get', function(_, muted, volume)
elseif v >= 67 then if not volume and muted then return nil end
icon = icon .. '-high' if not volume then
end return
w:get_children_by_id('image_role')[1]:set_image(gears.color.recolor_image(icon .. '.svg', end
beautiful.colorscheme.bg_purple)) local icon = icondir .. 'audio/microphone'
tooltip.text = 'Backlight: ' .. v .. '%' volume = tonumber(volume)
rubato_timer.target = v if not volume then
end) return
elseif widget == 'battery' then end
--[[ battery:connect_signal('update::battery_widget', function(battery, battery_icon) if muted or (volume < 1) then
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(battery_icon, icon = icon .. '-off'
beautiful.colorscheme.bg_purple) end
tooltip.text = 'Battery: ' .. battery .. '%' w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icon .. '.svg',
rubato_timer.target = battery beautiful.colorscheme.bg_blue)
end) ]] tooltip.text = 'Microphone: ' .. volume .. '%'
rubato_timer.target = volume
end)
elseif widget == 'backlight' then
backlight_helper:connect_signal('brightness_changed', function()
backlight_helper.brightness_get_async(function(brightness)
if not brightness then return end
brightness = math.floor((tonumber(brightness) / (backlight_helper.brightness_max or 24000) * 100) + 0.5)
local icon = icondir .. 'brightness/brightness'
if brightness >= 0 and brightness < 34 then
icon = icon .. '-low.svg'
elseif brightness >= 34 and brightness < 67 then
icon = icon .. '-medium.svg'
elseif brightness >= 67 then
icon = icon .. '-high.svg'
end
w:get_children_by_id('image_role')[1]:set_image(gears.color.recolor_image(icon,
beautiful.colorscheme.bg_purple))
tooltip.text = 'Backlight: ' .. brightness .. '%'
rubato_timer.target = brightness
end)
end)
backlight_helper.brightness_get_async(function(brightness)
if not brightness then return end
brightness = math.floor((tonumber(brightness) / (backlight_helper.brightness_max or 24000) * 100) + 0.5)
local icon = icondir .. 'brightness/brightness'
if brightness >= 0 and brightness < 34 then
icon = icon .. '-low.svg'
elseif brightness >= 34 and brightness < 67 then
icon = icon .. '-medium.svg'
elseif brightness >= 67 then
icon = icon .. '-high.svg'
end
w:get_children_by_id('image_role')[1]:set_image(gears.color.recolor_image(icon,
beautiful.colorscheme.bg_purple))
tooltip.text = 'Backlight: ' .. brightness .. '%'
rubato_timer.target = brightness
end)
elseif widget == 'battery' then
capi.awesome.connect_signal('update::battery_widget', function(battery, battery_icon)
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(battery_icon,
beautiful.colorscheme.bg_purple)
tooltip.text = 'Battery: ' .. battery .. '%'
rubato_timer.target = battery
end)
end
table.insert(bar_layout, w)
end end
table.insert(bar_layout, w) return bar_layout
end end
return bar_layout return wibox.widget {
end
return wibox.widget {
{
{ {
{ {
{ {
{ {
create_bar_layout(beautiful.user_config.status_bar_widgets), {
width = dpi(480), create_bar_layout(beautiful.user_config.status_bar_widgets),
strategy = 'exact', width = dpi(480),
widget = wibox.container.constraint, strategy = 'exact',
widget = wibox.container.constraint,
},
widget = wibox.container.place,
}, },
widget = wibox.container.place, magins = dpi(10),
layout = wibox.container.margin,
}, },
magins = dpi(10), border_color = beautiful.colorscheme.border_color,
layout = wibox.container.margin, border_width = dpi(2),
shape = beautiful.shape[12],
widget = wibox.container.background,
}, },
border_color = beautiful.colorscheme.border_color, widget = wibox.container.constraint,
border_width = dpi(2), height = dpi(120),
shape = beautiful.shape[12], width = dpi(500),
widget = wibox.container.background, strategy = 'exact',
}, },
widget = wibox.container.constraint, top = dpi(10),
height = dpi(120), left = dpi(20),
width = dpi(500), right = dpi(20),
strategy = 'exact', bottom = dpi(10),
}, widget = wibox.container.margin,
top = dpi(10), }
left = dpi(20), end,
right = dpi(20), })
bottom = dpi(10),
widget = wibox.container.margin,
}
end, })

View File

View File

@@ -10,6 +10,7 @@ local dpi = require('beautiful').xresources.apply_dpi
local gfilesystem = require('gears.filesystem') local gfilesystem = require('gears.filesystem')
local gtable = require('gears.table') local gtable = require('gears.table')
local wibox = require('wibox') local wibox = require('wibox')
local gsurface = require('gears.surface')
local hover = require('src.tools.hover') local hover = require('src.tools.hover')
@@ -116,7 +117,7 @@ if instance == nil then
{ {
{ {
{ {
image = icondir .. 'defaultpfp.svg', image = gsurface.load_uncached(gfilesystem.get_configuration_dir() .. 'src/assets/userpfp/userpfp.png'),
resize = true, resize = true,
clip_shape = beautiful.shape[30], clip_shape = beautiful.shape[30],
valign = 'center', valign = 'center',
@@ -192,13 +193,14 @@ if instance == nil then
-- Get the profile script from /var/lib/AccountsService/icons/${USER} -- Get the profile script from /var/lib/AccountsService/icons/${USER}
-- and copy it to the assets folder -- and copy it to the assets folder
-- TODO: If the user doesnt have AccountsService look into $HOME/.faces -- TODO: If the user doesnt have AccountsService look into $HOME/.faces
aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userPfp'", function(stdout) --[[ aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userPfp'", function(stdout)
print(stdout)
if stdout then if stdout then
self.w:get_children_by_id('icon_role')[1].image = stdout:gsub('\n', '') self.w:get_children_by_id('icon_role')[1].image = gsurface.load_uncached(gfilesystem.get_configuration_dir() .. 'src/assets/userpfp/userpfp.png')
else else
self.w:get_children_by_id('icon_role')[1].image = icondir .. 'defaultpfp.svg' self.w:get_children_by_id('icon_role')[1].image = icondir .. 'defaultpfp.svg'
end end
end) end) ]]
aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userName' '" .. beautiful.user_config.namestyle .. "'", function(stdout) aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userName' '" .. beautiful.user_config.namestyle .. "'", function(stdout)
self.w:get_children_by_id('text_role')[1].text = stdout:gsub('\n', '') self.w:get_children_by_id('text_role')[1].text = stdout:gsub('\n', '')

View File

@@ -5,7 +5,7 @@ case $1 in
"userPfp") "userPfp")
iconPath="/var/lib/AccountsService/icons/$USER" iconPath="/var/lib/AccountsService/icons/$USER"
userIconPath="$HOME/.config/awesome/src/assets/userpfp/" userIconPath="../assets/userpfp/"
if [[ -f "$userIconPath" ]]; if [[ -f "$userIconPath" ]];
then then

View File

@@ -0,0 +1,4 @@
#!/bin/bash
# First update the profile picture

View File

@@ -0,0 +1,91 @@
local setmetatable = setmetatable
local gtable = require('gears.table')
local gobject = require('gears.object')
local lgi = require('lgi')
local dbus_proxy = require('src.lib.lua-dbus_proxy.src.dbus_proxy')
local bluetooth = {}
function bluetooth:StartDiscovery()
self.Adapter1:StartDiscovery()
self:emit_signal('Bluetooth::DiscoveryStarted')
end
function bluetooth:StopDiscovery()
self.Adapter1:StopDiscovery()
self:emit_signal('Bluetooth::DiscoveryStopped')
end
function bluetooth:RemoveDevice(device)
if not device then return end
self.Adapter1:RemoveDevice(device)
end
function bluetooth:toggle_wifi()
local powered = not self.Adapter1.Powered
self.Adapter1:Set('org.bluez.Adapter1', 'Powered', lgi.GLib.Variant('b', powered))
self.Adapter1.Powered = {
signature = 'b',
value = powered,
}
end
return setmetatable(bluetooth, {
__call = function(self)
gtable.crush(self, gobject())
self.ObjectManager = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.freedesktop.DBus.ObjectManager',
path = '/',
}
self.Adapter1 = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.bluez.Adapter1',
path = '/org/bluez/hci0',
}
self.Adapter1Properties = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.freedesktop.DBus.Properties',
path = '/org/bluez/hci0',
}
self.Adapter1Properties:connect_signal(function(_, _, data)
if data.Powered ~= nil then
self:emit_signal('Bluetooth::Powered', data.Powered)
end
end, 'PropertiesChanged')
self.ObjectManager:connect_signal(function(_, path)
self:emit_signal('Bluetooth::DeviceAdded', path)
end, 'InterfacesAdded')
self.ObjectManager:connect_signal(function(_, path)
self:emit_signal('Bluetooth::DeviceRemoved', path)
end, 'InterfacesRemoved')
setmetatable(self, {
__index = function(_, key)
if key == 'Powered' then
return self.Adapter1.Powered
elseif key == 'Alias' then
return self.Adapter1.Alias
elseif key == 'PowerState' then
return self.Adapter1.PowerState
end
end,
})
return self
end,
})

View File

@@ -0,0 +1,88 @@
local setmetatable = setmetatable
local gtable = require('gears.table')
local gobject = require('gears.object')
local lgi = require('lgi')
local dbus_proxy = require('src.lib.lua-dbus_proxy.src.dbus_proxy')
local device = {}
function device:Connect()
self.Device1:ConnectAsync()
end
function device:Disconnect()
self.Device1:DisconnectAsync()
end
function device:Pair()
self.AgentManager1:RegisterAgent(self.Agent1.object_path, 'KeyboardDisplay')
self.Device1:PairAsync()
end
function device:CancelPair()
self.Device1:CancelPairAsync()
end
function device:Rename(newname)
self.Device1:Set('org.bluez.Device1', 'Alias', lgi.GLib.Variant('s', newname))
self.Device1.Alias = { signature = 's', value = newname }
return self.Device1:Get('org.bluez.Device1', 'Alias')
end
function device:ToggleTrusted()
local trusted = not self.Device1.Trusted
self.Device1:Set('org.bluez.Device1', 'Trusted', lgi.GLib.Variant('b', trusted))
self.Device1.Trusted = { signature = 'b', value = trusted }
end
return setmetatable(device, {
__call = function(_, path)
if not path then return end
local self = gobject {}
gtable.crush(self, device, true)
self.Device1 = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.bluez.Device1',
path = path,
}
if not self.Device1 then return end
self.Agent1 = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.bluez.Agent1',
path = '/org/bluez/agent',
}
self.AgentManager1 = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.bluez.AgentManager1',
path = '/org/bluez',
}
setmetatable(self, {
__index = function(_, key)
if key == 'Alias' then
return self.Device1.Alias
elseif key == 'Icon' then
return self.Device1.Icon
elseif key == 'Paired' then
return self.Device1.Paired
elseif key == 'Connected' then
return self.Device1.Connected
elseif key == 'Trusted' then
return self.Device1.Trusted
elseif key == 'RSSI' then
return self.Device1.RSSI
end
end,
})
return self
end,
})

View File

@@ -7,23 +7,31 @@ local Gtk = lgi.require('Gtk', '3.0')
local icon_lookup = {} local icon_lookup = {}
function icon_lookup:get_gicon_path(app, icon_string) function icon_lookup:get_gicon_path(app, icon_string)
if (not app) and (not icon_string) then return end if (not app) and (not icon_string) or not self.gtk_theme then return end
if icon_string then if icon_string then
return self.gtk_theme:lookup_icon(icon_string, 64, 0):get_filename() or '' local icon = self.gtk_theme:lookup_icon(icon_string or "", 64, 0)
if icon then
return icon:get_filename() or ''
end
end
if app then
local icon_info = self.gtk_theme:lookup_by_gicon(app, 64, 0)
if icon_info then
return icon_info:get_filename()
end
end end
local icon_info = self.gtk_theme:lookup_by_gicon(app, 64, 0)
if icon_info then
return icon_info:get_filename()
end
return nil return nil
end end
local instance = nil local instance = nil
if not instance then if not instance then
instance = setmetatable(icon_lookup, { instance = setmetatable(icon_lookup, {
__call = function(self, ...) __call = function(self, theme_name,...)
self.gtk_theme = Gtk.IconTheme.get_default() self.gtk_theme = Gtk.IconTheme.get_default()
return self return self
end, end,
}) })

View File

@@ -6,43 +6,108 @@ local audio = {}
local instance = nil local instance = nil
function audio.set_sink_volume(volume) function audio:set_sink_volume(volume)
aspawn('pactl set-sink-volume @DEFAULT_SINK@ ' .. volume .. '%') if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-volume @DEFAULT_SINK@ ' .. volume .. '%', function()
self.allow_cmd = true
end)
end end
function audio.set_source_volume(volume) function audio:set_source_volume(volume)
aspawn('pactl set-source-volume @DEFAULT_SOURCE@ ' .. volume .. '%') if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-source-volume @DEFAULT_SOURCE@ ' .. volume .. '%', function()
self.allow_cmd = true
end)
end end
function audio.sink_volume_up() function audio:sink_volume_up()
aspawn('pactl set-sink-volume @DEFAULT_SINK@ +2%') if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-volume @DEFAULT_SINK@ +2%', function()
self.allow_cmd = true
end)
end end
function audio.source_volume_up() function audio:source_volume_up()
aspawn('pactl set-source-volume @DEFAULT_SOURCE@ +2%') if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-source-volume @DEFAULT_SOURCE@ +2%', function()
self.allow_cmd = true
end)
end end
function audio.sink_volume_down() function audio:sink_volume_down()
aspawn('pactl set-sink-volume @DEFAULT_SINK@ -2%') if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-volume @DEFAULT_SINK@ -2%', function()
self.allow_cmd = true
end)
end end
function audio.source_volume_down() function audio:source_volume_down()
aspawn('pactl set-source-volume @DEFAULT_SOURCE@ -2%') if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-source-volume @DEFAULT_SOURCE@ -2%', function()
self.allow_cmd = true
end)
end end
function audio.sink_toggle_mute() function audio:sink_toggle_mute()
aspawn('pactl set-sink-mute @DEFAULT_SINK@ toggle') if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-mute @DEFAULT_SINK@ toggle', function()
self.allow_cmd = true
end)
end end
function audio.source_toggle_mute() function audio:source_toggle_mute()
aspawn('pactl set-source-mute @DEFAULT_SOURCE@ toggle') if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-source-mute @DEFAULT_SOURCE@ toggle', function()
self.allow_cmd = true
end)
end
function audio:sink_unmute()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-mute @DEFAULT_SINK@ false', function()
self.allow_cmd = true
end)
end
function audio:sink_mute()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-mute @DEFAULT_SINK@ true', function()
self.allow_cmd = true
end)
end
function audio:source_unmute()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-source-mute @DEFAULT_SOURCE@ false', function()
self.allow_cmd = true
end)
end
function audio:source_mute()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn('pactl set-source-mute @DEFAULT_SOURCE@ true', function()
self.allow_cmd = true
end)
end end
local function new() local function new()
local self = gobject {} local self = gobject {}
gtable.crush(self, audio, true) gtable.crush(self, audio, true)
self.allow_cmd = true
aspawn.with_line_callback([[bash -c "LC_ALL=C pactl subscribe"]], { aspawn.with_line_callback([[bash -c "LC_ALL=C pactl subscribe"]], {
stdout = function(line) stdout = function(line)
-- Volume changed -- Volume changed

View File

@@ -1,6 +1,7 @@
local aspawn = require('awful.spawn') local aspawn = require('awful.spawn')
local gobject = require('gears.object') local gobject = require('gears.object')
local gtable = require('gears.table') local gtable = require('gears.table')
local gtimer = require('gears.timer')
local backlight = {} local backlight = {}
@@ -8,17 +9,25 @@ local instance = nil
function backlight.brightness_get_async(callback) function backlight.brightness_get_async(callback)
aspawn.easy_async_with_shell('brightnessctl get', function(stdout) aspawn.easy_async_with_shell('brightnessctl get', function(stdout)
callback(tonumber(stdout:gsub('\n', ''))) callback(stdout:gsub('\n', ''))
end) end)
end end
function backlight:brightness_increase() function backlight:brightness_increase()
aspawn('brightnessctl set 2+%') if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('brightnessctl set 2+%', function()
self.allow_cmd = true
end)
self:emit_signal('brightness_changed') self:emit_signal('brightness_changed')
end end
function backlight:brightness_decrease() function backlight:brightness_decrease()
aspawn('brightnessctl set 2-%') if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('brightnessctl set 2-%', function()
self.allow_cmd = true
end)
self:emit_signal('brightness_changed') self:emit_signal('brightness_changed')
end end
@@ -32,6 +41,11 @@ local function new()
self.max_brightness = tonumber(stdout:gsub('\n', '') or 1) self.max_brightness = tonumber(stdout:gsub('\n', '') or 1)
end) end)
-- Function locker to avoid spawning more commands than can be processed at a time
self.allow_cmd = true
self:emit_signal('brightness_changed')
return self return self
end end

View File

@@ -1,15 +1,38 @@
local awatch = require('awful.widget.watch') local awatch = require('awful.widget.watch')
local aspawn = require('awful.spawn')
local gobject = require('gears.object') local gobject = require('gears.object')
local instance local instance
local json = require('src.lib.json-lua.json-lua')
local function new() local function new()
local self = gobject {} local self = gobject {}
awatch([[ bash -c "nvidia-smi -q -d UTILIZATION | grep Gpu | awk '{print $3}'"]], 3, function(_, stdout) aspawn.easy_async_with_shell([[ lspci | grep ' VGA ' | cut -d" " -f 1 ]], function(stdout)
stdout = stdout:match('%d+') if stdout:match('00:03.0') then -- Nvidia
if not stdout then return end awatch([[ bash -c "nvidia-smi -q -d UTILIZATION | grep Gpu | awk '{print $3}'"]], 3, function(_, stdout)
self:emit_signal('update::gpu_usage', stdout) stdout = stdout:match('%d+')
if not stdout then return end
self:emit_signal('update::gpu_usage', stdout)
end)
elseif stdout:match('00:02.0') then -- Intel
awatch([[ bash -c "intel_gpu_top -J & sleep 1 && pkill intel_gpu_top" ]], 3, function(_, stdout)
local gpu_data = json:decode('[' .. stdout:gsub('/', '') .. ']')[2]
if not gpu_data or type(gpu_data) ~= table then return end
local gpu_usage = (gpu_data.engines.Render3D0.busy +
gpu_data.engines.Blitter0.busy +
gpu_data.engines.Video0.busy +
gpu_data.engines.VideoEnhance0.busy) / 4
self:emit_signal('update::gpu_usage', math.floor(gpu_usage + 0.5))
end)
elseif stdout:match('00:01.0') then -- AMD
-- AMD
end
end) end)
return self return self
end end

View File

@@ -30,7 +30,7 @@ local function overlay_color(col, overlay, opacity)
end end
local function bg_hover(args) local function bg_hover(args)
--[[ args = args or {} --[[ args = args or {}
local old_cursor, old_wibox local old_cursor, old_wibox
local _, r, g, b, a = args.widget.bg:get_rgba() local _, r, g, b, a = args.widget.bg:get_rgba()

View File

@@ -0,0 +1,60 @@
local setmetatable = setmetatable
local aspawn = require("awful.spawn")
local lgi = require('lgi')
local cairo = lgi.cairo
local gfilesystem = require('gears.filesystem')
local gsurface = require('gears.surface')
local gtable = require('gears.table')
local gobject = require('gears.object')
--[[
Preload all external image or svg files as cairo surfaces and return them,
if no icon is found an empty surface is returned
]]
local cache = {}
local ret = {}
local instance = nil
if not instance then
instance = setmetatable(ret, {
__call = function()
gtable.crush(ret, gobject{}, true)
local icon_path = gfilesystem.get_configuration_dir() .. 'src/assets/icons/'
local layout_path = gfilesystem.get_configuration_dir() .. 'src/assets/layout/'
aspawn.easy_async_with_shell('ls -a "' .. icon_path .. '"', function(stdout)
for str in stdout:gmatch("([^\n]*)\n?") do
if str ~= "" and str ~= "." and str ~= ".." then
local surface = cairo.ImageSurface(cairo.ARGB, 64, 64)
cache[str] = surface
end
end
ret:emit_signal("done")
end)
aspawn.easy_async_with_shell('ls -a "' .. layout_path .. '"', function(stdout)
for str in stdout:gmatch("([^\n]*)\n?") do
if str ~= "" and str ~= "." and str ~= ".." then
local surface = cairo.ImageSurface(cairo.ARGB, 64, 64)
cache[str] = surface
end
end
end)
return ret
end,
__index = function(self,key)
print(key, cache[key])
if key and cache[key] then
print("test")
return cache[key]
elseif(key == "user_image") or (key == "background") or (key == "os_logo") then
return cache[key]
else
--return cairo.ImageSurface()
end
end
})
end
return instance

7
awesome_crylia.desktop Normal file
View File

@@ -0,0 +1,7 @@
[Desktop Entry]
Name=Awesome Crylia Theme
Comment=Crylia Theme for AwesomeWM
TryExec=sh -c "awesome_crylia -c $HOME/.config/crylia_theme/rc.lua"
Exec=sh -c "/usr/local/bin/awesome_crylia -c $HOME/.config/crylia_theme/rc.lua"
Type=Application

96
install.sh Normal file
View File

@@ -0,0 +1,96 @@
#!/bin/bash
echo "
╭─────────────────────────────────────────────────────────────────╮
│ ______ ___ ________ │
│ / ____/______ __/ (_)___ _ /_ __/ /_ ___ ____ ___ ___ │
│ / / / ___/ / / / / / __ `/ / / / __ \/ _ \/ __ `__ \/ _ \ │
│ / /___/ / / /_/ / / / /_/ / / / / / / / __/ / / / / / __/ │
│ \____/_/ \__, /_/_/\__,_/ /_/ /_/ /_/\___/_/ /_/ /_/\___/ │
│ /____/ │
╰─────────────────────────────────────────────────────────────────╯
"
if (($EUID != 0)); then
echo "ERROR: Please run as root!\n"
exit
fi
# Try to install dependencies
if [whereis apt | awk '{print $2}' = "*apt"]; then
apt update && apt install libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev libxext-dev meson ninja-build uthash-dev
else if [whereis pacman | awk '{print $2}' = "*apt"]; then
pacman -Suy
fi
CONFIG_PATH="$HOME/.config";
DESKTOP_FILE="awesome_crylia.desktop";
SESSION_PATH="/usr/share/xsessions";
# Copy the desktop file to the xsessions folder
cp $DESKTOP_FILE "$SESSION_PATH/$DESKTOP_FILE"
# Check if the file got copied
if ![ -f "$SESSION_PATH/$DESKTOP_FILE"]; then
printf '%c' "ERROR: Couldn't copy .desktop file";
fi
function y_or_n {
while true; do
read -p "$* [Y/N]: " yn
case $yn in
[Yy]*) return 1;;
[Nn]*) return 0;;
esac
done
}
# $1 the folder that should be backuped
# $2 the new backup folder name
# $3 the file to copy to $1
function backup_and_copy {
if [-d "$1"]; then
cp -r "$1" "$2"
if [-d "$2"]; then
rm -r "$1"
else
if (yes_or_no "WARNING: Couldn't create backup of $1, continue?" == 0); then
echo "Aborted";
exit -1;
fi
fi
fi
cp -r "$3 $1"
if ![-d "$1"]; then
echo "ERROR: Couldn't copy $3 to $1"
fi
}
backup_and_copy "$CONFIG_PATH/crylia_theme" "$CONFIG_PATH/crylia_theme_backup" "awesome"
backup_and_copy "$CONFIG_PATH/kitty" "$CONFIG_PATH/kitty_backup" "kitty"
backup_and_copy "$CONFIG_PATH/starship.toml" "$CONFIG_PATH/starship.toml.backup" "starship.toml"
# Clone, build and install my awesome fork
git clone https://github.com/Crylia/awesome /tmp
cd /tmp/awesome
make
make install
rm -rf /tmp/awesome
while true; do
read -p "Would you like to install my neofetch config? [Y/N]: " yn
if (($yn == [Yy*])); then
backup_and_copy "$CONFIG_PATH/neofetch" "$CONFIG_PATH/neofetch_backup" "neofetch"
fi
done
# Clone, build and install picom
git clone https://github.com/yshui/picom.git /tmp
meson setup --buildtype=release build
ninja -C build
ninja -C build install
rm -rf /tmp/picom