Added audio device selector, new notification theme and much more. Rewritten some files and made a new README
This commit is contained in:
@@ -15,222 +15,220 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/brightness/"
|
||||
BACKLIGHT_MAX_BRIGHTNESS = 0
|
||||
BACKLIGHT_SEPS = 0
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"pkexec xfpm-power-backlight-helper --get-max-brightness",
|
||||
function(stdout)
|
||||
BACKLIGHT_MAX_BRIGHTNESS = tonumber(stdout)
|
||||
BACKLIGHT_SEPS = BACKLIGHT_MAX_BRIGHTNESS / 100
|
||||
BACKLIGHT_SEPS = math.floor(BACKLIGHT_SEPS)
|
||||
end
|
||||
"pkexec xfpm-power-backlight-helper --get-max-brightness",
|
||||
function(stdout)
|
||||
BACKLIGHT_MAX_BRIGHTNESS = tonumber(stdout)
|
||||
BACKLIGHT_SEPS = BACKLIGHT_MAX_BRIGHTNESS / 100
|
||||
BACKLIGHT_SEPS = math.floor(BACKLIGHT_SEPS)
|
||||
end
|
||||
)
|
||||
|
||||
return function(s)
|
||||
|
||||
local brightness_osd_widget = wibox.widget {
|
||||
local brightness_osd_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
nil,
|
||||
{
|
||||
{
|
||||
{
|
||||
nil,
|
||||
{
|
||||
nil,
|
||||
{
|
||||
id = "icon",
|
||||
forced_height = dpi(220),
|
||||
image = icondir .. "brightness-high.svg",
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
nil,
|
||||
expand = "none",
|
||||
id = "icon_margin2",
|
||||
layout = wibox.layout.align.vertical
|
||||
},
|
||||
nil,
|
||||
id = "icon_margin1",
|
||||
expand = "none",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
{
|
||||
{
|
||||
id = "label",
|
||||
text = "Brightness",
|
||||
align = "left",
|
||||
valign = "center",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
nil,
|
||||
{
|
||||
id = "value",
|
||||
text = "0%",
|
||||
align = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
id = "label_value_layout",
|
||||
forced_height = dpi(48),
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
{
|
||||
{
|
||||
id = "brightness_slider",
|
||||
bar_shape = gears.shape.rounded_rect,
|
||||
bar_height = dpi(10),
|
||||
bar_color = color["Grey800"] .. "88",
|
||||
bar_active_color = "#ffffff",
|
||||
handle_color = "#ffffff",
|
||||
handle_shape = gears.shape.circle,
|
||||
handle_width = dpi(10),
|
||||
handle_border_color = color["White"],
|
||||
maximum = 100,
|
||||
widget = wibox.widget.slider
|
||||
},
|
||||
id = "slider_layout",
|
||||
forced_height = dpi(24),
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "icon_slider_layout",
|
||||
spacing = dpi(0),
|
||||
layout = wibox.layout.align.vertical
|
||||
},
|
||||
id = "osd_layout",
|
||||
layout = wibox.layout.align.vertical
|
||||
nil,
|
||||
{
|
||||
id = "icon",
|
||||
forced_height = dpi(220),
|
||||
image = icondir .. "brightness-high.svg",
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
nil,
|
||||
expand = "none",
|
||||
id = "icon_margin2",
|
||||
layout = wibox.layout.align.vertical
|
||||
},
|
||||
id = "container",
|
||||
left = dpi(24),
|
||||
right = dpi(24),
|
||||
widget = wibox.container.margin
|
||||
nil,
|
||||
id = "icon_margin1",
|
||||
expand = "none",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
{
|
||||
{
|
||||
id = "label",
|
||||
text = "Brightness",
|
||||
align = "left",
|
||||
valign = "center",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
nil,
|
||||
{
|
||||
id = "value",
|
||||
text = "0%",
|
||||
align = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
id = "label_value_layout",
|
||||
forced_height = dpi(48),
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
{
|
||||
{
|
||||
id = "brightness_slider",
|
||||
bar_shape = gears.shape.rounded_rect,
|
||||
bar_height = dpi(10),
|
||||
bar_color = color["Grey800"] .. "88",
|
||||
bar_active_color = "#ffffff",
|
||||
handle_color = "#ffffff",
|
||||
handle_shape = gears.shape.circle,
|
||||
handle_width = dpi(10),
|
||||
handle_border_color = color["White"],
|
||||
maximum = 100,
|
||||
widget = wibox.widget.slider
|
||||
},
|
||||
id = "slider_layout",
|
||||
forced_height = dpi(24),
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "icon_slider_layout",
|
||||
spacing = dpi(0),
|
||||
layout = wibox.layout.align.vertical
|
||||
},
|
||||
bg = color["Grey900"] .. "88",
|
||||
widget = wibox.container.background,
|
||||
ontop = true,
|
||||
visible = true,
|
||||
type = "notification",
|
||||
forced_height = dpi(300),
|
||||
forced_width = dpi(300),
|
||||
offset = dpi(5),
|
||||
}
|
||||
id = "osd_layout",
|
||||
layout = wibox.layout.align.vertical
|
||||
},
|
||||
id = "container",
|
||||
left = dpi(24),
|
||||
right = dpi(24),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = color["Grey900"] .. "88",
|
||||
widget = wibox.container.background,
|
||||
ontop = true,
|
||||
visible = true,
|
||||
type = "notification",
|
||||
forced_height = dpi(300),
|
||||
forced_width = dpi(300),
|
||||
offset = dpi(5),
|
||||
}
|
||||
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:connect_signal(
|
||||
"property::value",
|
||||
function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"pkexec xfpm-power-backlight-helper --get-brightness",
|
||||
function(stdout)
|
||||
local brightness_value = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100)
|
||||
-- Performance is horrible, or it overrides and executes at the same time as the keymappings
|
||||
--awful.spawn("xbacklight -set " .. brightness_value, false)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text(tostring(brightness_value) .. "%")
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:connect_signal(
|
||||
"property::value",
|
||||
function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"pkexec xfpm-power-backlight-helper --get-brightness",
|
||||
function(stdout)
|
||||
local brightness_value = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text(tostring(brightness_value) .. "%")
|
||||
|
||||
awesome.emit_signal(
|
||||
"widget::brightness:update",
|
||||
brightness_value
|
||||
)
|
||||
|
||||
if awful.screen.focused().show_brightness_osd then
|
||||
awesome.emit_signal(
|
||||
"module::brightness_osd:show",
|
||||
true
|
||||
)
|
||||
end
|
||||
|
||||
local icon = icondir .. "brightness"
|
||||
if brightness_value >= 0 and brightness_value < 34 then
|
||||
icon = icon .. "-low"
|
||||
elseif brightness_value >= 34 and brightness_value < 67 then
|
||||
icon = icon .. "-medium"
|
||||
elseif brightness_value >= 67 then
|
||||
icon = icon .. "-high"
|
||||
end
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icon .. ".svg")
|
||||
end
|
||||
)
|
||||
end
|
||||
)
|
||||
|
||||
local update_slider = function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[[ pkexec xfpm-power-backlight-helper --get-brightness ]],
|
||||
function(stdout)
|
||||
stdout = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(stdout)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
awesome.connect_signal(
|
||||
"module::brightness_slider:update",
|
||||
function()
|
||||
update_slider()
|
||||
end
|
||||
)
|
||||
|
||||
awesome.connect_signal(
|
||||
awesome.emit_signal(
|
||||
"widget::brightness:update",
|
||||
function(value)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(tonumber(value))
|
||||
end
|
||||
)
|
||||
brightness_value
|
||||
)
|
||||
|
||||
if awful.screen.focused().show_brightness_osd then
|
||||
awesome.emit_signal(
|
||||
"module::brightness_osd:show",
|
||||
true
|
||||
)
|
||||
end
|
||||
|
||||
local icon = icondir .. "brightness"
|
||||
if brightness_value >= 0 and brightness_value < 34 then
|
||||
icon = icon .. "-low"
|
||||
elseif brightness_value >= 34 and brightness_value < 67 then
|
||||
icon = icon .. "-medium"
|
||||
elseif brightness_value >= 67 then
|
||||
icon = icon .. "-high"
|
||||
end
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icon .. ".svg")
|
||||
end
|
||||
)
|
||||
end
|
||||
)
|
||||
|
||||
local update_slider = function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[[ pkexec xfpm-power-backlight-helper --get-brightness ]],
|
||||
function(stdout)
|
||||
stdout = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(stdout)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
awesome.connect_signal(
|
||||
"module::brightness_slider:update",
|
||||
function()
|
||||
update_slider()
|
||||
end
|
||||
)
|
||||
|
||||
local brightness_container = awful.popup {
|
||||
widget = wibox.container.background,
|
||||
ontop = true,
|
||||
bg = color["Grey900"] .. "00",
|
||||
stretch = false,
|
||||
visible = false,
|
||||
screen = s,
|
||||
placement = function(c) awful.placement.centered(c, { margins = { top = dpi(200) } }) end,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 15)
|
||||
end
|
||||
}
|
||||
awesome.connect_signal(
|
||||
"widget::brightness:update",
|
||||
function(value)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(tonumber(value))
|
||||
end
|
||||
)
|
||||
|
||||
local hide_brightness_osd = gears.timer {
|
||||
timeout = 2,
|
||||
autostart = true,
|
||||
callback = function()
|
||||
brightness_container.visible = false
|
||||
end
|
||||
}
|
||||
update_slider()
|
||||
|
||||
brightness_container:setup {
|
||||
brightness_osd_widget,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
local brightness_container = awful.popup {
|
||||
widget = wibox.container.background,
|
||||
ontop = true,
|
||||
bg = color["Grey900"] .. "00",
|
||||
stretch = false,
|
||||
visible = false,
|
||||
screen = s,
|
||||
placement = function(c) awful.placement.centered(c, { margins = { top = dpi(200) } }) end,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 15)
|
||||
end
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"widget::brightness_osd:rerun",
|
||||
function()
|
||||
if hide_brightness_osd.started then
|
||||
hide_brightness_osd:again()
|
||||
else
|
||||
hide_brightness_osd:start()
|
||||
end
|
||||
end
|
||||
)
|
||||
local hide_brightness_osd = gears.timer {
|
||||
timeout = 2,
|
||||
autostart = true,
|
||||
callback = function()
|
||||
brightness_container.visible = false
|
||||
end
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"module::brightness_osd:show",
|
||||
function()
|
||||
if s == mouse.screen then
|
||||
brightness_container.visible = true
|
||||
end
|
||||
end
|
||||
)
|
||||
brightness_container:setup {
|
||||
brightness_osd_widget,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
|
||||
brightness_container:connect_signal(
|
||||
"mouse::enter",
|
||||
function()
|
||||
brightness_container.visible = true
|
||||
hide_brightness_osd:stop()
|
||||
end
|
||||
)
|
||||
awesome.connect_signal(
|
||||
"widget::brightness_osd:rerun",
|
||||
function()
|
||||
if hide_brightness_osd.started then
|
||||
hide_brightness_osd:again()
|
||||
else
|
||||
hide_brightness_osd:start()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
brightness_container:connect_signal(
|
||||
"mouse::leave",
|
||||
function()
|
||||
brightness_container.visible = true
|
||||
hide_brightness_osd:again()
|
||||
end
|
||||
)
|
||||
awesome.connect_signal(
|
||||
"module::brightness_osd:show",
|
||||
function()
|
||||
if s == mouse.screen then
|
||||
brightness_container.visible = true
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
brightness_container:connect_signal(
|
||||
"mouse::enter",
|
||||
function()
|
||||
brightness_container.visible = true
|
||||
hide_brightness_osd:stop()
|
||||
end
|
||||
)
|
||||
|
||||
brightness_container:connect_signal(
|
||||
"mouse::leave",
|
||||
function()
|
||||
brightness_container.visible = true
|
||||
hide_brightness_osd:again()
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
---------------------------------------
|
||||
-- This is the calendar_osd module --
|
||||
---------------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
|
||||
local awful = require("awful")
|
||||
local wibox = require("wibox")
|
||||
local gears = require("gears")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local color = require("src.theme.colors")
|
||||
|
||||
return function(s)
|
||||
local styles = {}
|
||||
|
||||
styles.month = {
|
||||
padding = 15,
|
||||
bg_color = color["Grey900"],
|
||||
border_width = 1,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end
|
||||
}
|
||||
styles.normal = {
|
||||
fg_color = color["Grey900"],
|
||||
font = user_vars.font.extrabold,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end
|
||||
}
|
||||
styles.focus = {
|
||||
fg_color = color["Grey900"],
|
||||
bg_color = color["Purple200"],
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end
|
||||
}
|
||||
styles.header = {
|
||||
fg_color = color["Grey900"],
|
||||
bg_color = color["Teal200"],
|
||||
markup = function(t) return '<b>' .. t .. '</b>' end,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end
|
||||
}
|
||||
styles.weekday = {
|
||||
padding = 8,
|
||||
fg_color = color["Grey900"],
|
||||
bg_color = color["Teal200"],
|
||||
markup = function(t) return '<b>' .. t .. '</b>' end,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end
|
||||
}
|
||||
local function decorate_cell(widget, flag, date)
|
||||
if flag == 'monthheader' and not styles.monthheader then
|
||||
flag = 'header'
|
||||
end
|
||||
local props = styles[flag] or {}
|
||||
if props.markup and widget.get_text and widget.set_markup then
|
||||
widget:set_markup(props.markup(widget:get_text()))
|
||||
end
|
||||
-- Change bg color for weekends
|
||||
local d = { year = date.year, month = (date.month or 1), day = (date.day or 1) }
|
||||
local weekday = tonumber(os.date('%w', os.time(d)))
|
||||
local default_bg = (weekday == 0 or weekday == 6) and color["Red200"] or color["White"]
|
||||
local ret = wibox.widget {
|
||||
{
|
||||
widget,
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
top = dpi(4),
|
||||
bottom = dpi(4),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end,
|
||||
fg = props.fg_color or '#999999',
|
||||
bg = props.bg_color or default_bg,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
return ret
|
||||
end
|
||||
|
||||
local calendar = wibox.widget {
|
||||
date = os.date('*t'),
|
||||
fn_embed = decorate_cell,
|
||||
widget = wibox.widget.calendar.month,
|
||||
font = user_vars.font.extrabold,
|
||||
spacing = dpi(10)
|
||||
}
|
||||
|
||||
local calendar_osd_widget = wibox.widget {
|
||||
{
|
||||
widget = wibox.widget.textbox,
|
||||
fg = "#ffffff",
|
||||
align = "center",
|
||||
valign = "center",
|
||||
font = "DS-Digital, Bold Italic 50",
|
||||
id = "digital_clock"
|
||||
},
|
||||
{
|
||||
widget = calendar
|
||||
},
|
||||
visible = true,
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local set_clock = function()
|
||||
calendar_osd_widget.digital_clock:set_text(os.date("%H:%M"))
|
||||
end
|
||||
|
||||
local calendar_clock_update = gears.timer {
|
||||
timeout = 5,
|
||||
autostart = true,
|
||||
call_now = true,
|
||||
callback = function()
|
||||
set_clock()
|
||||
end
|
||||
}
|
||||
|
||||
local calendar_osd_container = awful.popup {
|
||||
screen = s,
|
||||
widget = wibox.container.background,
|
||||
ontop = true,
|
||||
bg = color["Grey900"],
|
||||
stretch = false,
|
||||
visible = false,
|
||||
placement = function(c) awful.placement.top_right(c, { margins = { right = dpi(100), top = dpi(60) } }) end,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end
|
||||
}
|
||||
|
||||
local hide_osd = gears.timer {
|
||||
timeout = 0.25,
|
||||
autostart = true,
|
||||
callback = function()
|
||||
calendar_osd_container.visible = false
|
||||
end
|
||||
}
|
||||
|
||||
calendar_osd_container:setup {
|
||||
calendar_osd_widget,
|
||||
layout = wibox.layout.align.horizontal
|
||||
}
|
||||
|
||||
calendar_osd_container:connect_signal(
|
||||
"mouse::enter",
|
||||
function()
|
||||
calendar_osd_container.visible = true
|
||||
hide_osd:stop()
|
||||
end
|
||||
)
|
||||
|
||||
calendar_osd_container:connect_signal(
|
||||
"mouse::leave",
|
||||
function()
|
||||
calendar_osd_container.visible = false
|
||||
hide_osd:stop()
|
||||
end
|
||||
)
|
||||
|
||||
awesome.connect_signal(
|
||||
"widget::calendar_osd:stop",
|
||||
function()
|
||||
calendar_osd_container.visible = true
|
||||
hide_osd:stop()
|
||||
end
|
||||
)
|
||||
|
||||
awesome.connect_signal(
|
||||
"widget::calendar_osd:rerun",
|
||||
function()
|
||||
if hide_osd.started then
|
||||
hide_osd:again()
|
||||
else
|
||||
hide_osd:start()
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
@@ -15,32 +15,32 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/powermenu/"
|
||||
|
||||
return function(s)
|
||||
|
||||
-- Profile picture imagebox
|
||||
local profile_picture = wibox.widget {
|
||||
image = icondir .. "defaultpfp.svg",
|
||||
resize = true,
|
||||
forced_height = dpi(200),
|
||||
clip_shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 30)
|
||||
end,
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
-- Profile picture imagebox
|
||||
local profile_picture = wibox.widget {
|
||||
image = icondir .. "defaultpfp.svg",
|
||||
resize = true,
|
||||
forced_height = dpi(200),
|
||||
clip_shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 30)
|
||||
end,
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
|
||||
-- Username textbox
|
||||
local profile_name = wibox.widget {
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
text = " ",
|
||||
font = "JetBrains Mono Bold 30",
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
-- Username textbox
|
||||
local profile_name = wibox.widget {
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
text = " ",
|
||||
font = "JetBrains Mono Bold 30",
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
|
||||
-- Get the profile script from /var/lib/AccountsService/icons/${USER}
|
||||
-- and copy it to the assets folder
|
||||
-- TODO: If the user doesnt have AccountsService look into $HOME/.faces
|
||||
local update_profile_picture = function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[=[
|
||||
-- Get the profile script from /var/lib/AccountsService/icons/${USER}
|
||||
-- and copy it to the assets folder
|
||||
-- TODO: If the user doesnt have AccountsService look into $HOME/.faces
|
||||
local update_profile_picture = function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[=[
|
||||
iconPath="/var/lib/AccountsService/icons/${USER}"
|
||||
userIconPath="${HOME}/.config/awesome/src/assets/userpfp/"
|
||||
if [[ -f "${userIconPath}" ]];
|
||||
@@ -65,23 +65,23 @@ return function(s)
|
||||
fi
|
||||
fi
|
||||
]=],
|
||||
function(stdout)
|
||||
if stdout then
|
||||
profile_picture:set_image(stdout:gsub("\n", ""))
|
||||
else
|
||||
profile_picture:set_image(icondir .. "defaultpfp.svg")
|
||||
end
|
||||
end
|
||||
)
|
||||
function(stdout)
|
||||
if stdout then
|
||||
profile_picture:set_image(stdout:gsub("\n", ""))
|
||||
else
|
||||
profile_picture:set_image(icondir .. "defaultpfp.svg")
|
||||
end
|
||||
end
|
||||
update_profile_picture()
|
||||
)
|
||||
end
|
||||
update_profile_picture()
|
||||
|
||||
-- Will determin the display style
|
||||
local namestyle = user_vars.namestyle
|
||||
-- Get the full username(if set) and the username + hostname
|
||||
local update_user_name = function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[=[
|
||||
-- Will determin the display style
|
||||
local namestyle = user_vars.namestyle
|
||||
-- Get the full username(if set) and the username + hostname
|
||||
local update_user_name = function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[=[
|
||||
fullname="$(getent passwd `whoami` | cut -d ':' -f 5)"
|
||||
user="$(whoami)"
|
||||
host="$(hostname)"
|
||||
@@ -95,227 +95,227 @@ return function(s)
|
||||
printf "Rick Astley"
|
||||
fi
|
||||
]=],
|
||||
function(stdout)
|
||||
if stdout:gsub("\n", "") == "Rick Astley" then
|
||||
profile_picture:set_image(awful.util.getdir("config") .. "src/assets/userpfp/" .. "rickastley.jpg")
|
||||
end
|
||||
profile_name:set_text(stdout)
|
||||
end
|
||||
)
|
||||
function(stdout)
|
||||
if stdout:gsub("\n", "") == "Rick Astley" then
|
||||
profile_picture:set_image(awful.util.getdir("config") .. "src/assets/userpfp/" .. "rickastley.jpg")
|
||||
end
|
||||
profile_name:set_text(stdout)
|
||||
end
|
||||
update_user_name()
|
||||
)
|
||||
end
|
||||
update_user_name()
|
||||
|
||||
-- Universal Button widget
|
||||
local button = function(name, icon, bg_color, callback)
|
||||
local item = wibox.widget {
|
||||
-- Universal Button widget
|
||||
local button = function(name, icon, bg_color, callback)
|
||||
local item = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
-- TODO: using gears.color to recolor a SVG will make it look super low res
|
||||
-- currently I recolor it in the .svg file directly, but later implement
|
||||
-- a better way to recolor a SVG
|
||||
-- image = gears.color.recolor_image(icon, color["Grey900"]),
|
||||
image = icon,
|
||||
resize = true,
|
||||
forced_height = dpi(30),
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
margins = dpi(0),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
{
|
||||
{
|
||||
text = name,
|
||||
font = "JetBrains Mono Bold 30",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
margins = dpi(0),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
widget = wibox.layout.fixed.horizontal
|
||||
},
|
||||
margins = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
fg = color["Grey900"],
|
||||
bg = bg_color,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 10)
|
||||
end,
|
||||
widget = wibox.container.background,
|
||||
id = 'background'
|
||||
{
|
||||
-- TODO: using gears.color to recolor a SVG will make it look super low res
|
||||
-- currently I recolor it in the .svg file directly, but later implement
|
||||
-- a better way to recolor a SVG
|
||||
-- image = gears.color.recolor_image(icon, color["Grey900"]),
|
||||
image = icon,
|
||||
resize = true,
|
||||
forced_height = dpi(30),
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
margins = dpi(0),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
spacing = dpi(0),
|
||||
layout = wibox.layout.align.vertical
|
||||
}
|
||||
{
|
||||
{
|
||||
text = name,
|
||||
font = "JetBrains Mono Bold 30",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
margins = dpi(0),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
widget = wibox.layout.fixed.horizontal
|
||||
},
|
||||
margins = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
fg = color["Grey900"],
|
||||
bg = bg_color,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 10)
|
||||
end,
|
||||
widget = wibox.container.background,
|
||||
id = 'background'
|
||||
},
|
||||
spacing = dpi(0),
|
||||
layout = wibox.layout.align.vertical
|
||||
}
|
||||
|
||||
item:connect_signal(
|
||||
"button::release",
|
||||
function()
|
||||
callback()
|
||||
end
|
||||
)
|
||||
|
||||
return item
|
||||
item:connect_signal(
|
||||
"button::release",
|
||||
function()
|
||||
callback()
|
||||
end
|
||||
)
|
||||
|
||||
-- Create the power menu actions
|
||||
local suspend_command = function()
|
||||
awful.spawn("dm-tool lock & systemctl suspend")
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
return item
|
||||
end
|
||||
|
||||
local logout_command = function()
|
||||
awesome.quit()
|
||||
end
|
||||
-- Create the power menu actions
|
||||
local suspend_command = function()
|
||||
awful.spawn("dm-tool lock & systemctl suspend")
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
|
||||
local lock_command = function()
|
||||
awful.spawn("dm-tool lock")
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
local logout_command = function()
|
||||
awesome.quit()
|
||||
end
|
||||
|
||||
local shutdown_command = function()
|
||||
awful.spawn("shutdown now")
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
local lock_command = function()
|
||||
awful.spawn("dm-tool lock")
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
|
||||
local reboot_command = function()
|
||||
awful.spawn("reboot")
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
local shutdown_command = function()
|
||||
awful.spawn("shutdown now")
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
|
||||
-- Create the buttons with their command and name etc
|
||||
local shutdown_button = button("Shutdown", icondir .. "shutdown.svg", color["Blue200"], shutdown_command)
|
||||
local reboot_button = button("Reboot", icondir .. "reboot.svg", color["Red200"], reboot_command)
|
||||
local suspend_button = button("Suspend", icondir .. "suspend.svg", color["Yellow200"], suspend_command)
|
||||
local logout_button = button("Logout", icondir .. "logout.svg", color["Green200"], logout_command)
|
||||
local lock_button = button("Lock", icondir .. "lock.svg", color["Orange200"], lock_command)
|
||||
local reboot_command = function()
|
||||
awful.spawn("reboot")
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
|
||||
-- Signals to change color on hover
|
||||
Hover_signal(shutdown_button.background, color["Blue200"])
|
||||
Hover_signal(reboot_button.background, color["Red200"])
|
||||
Hover_signal(suspend_button.background, color["Yellow200"])
|
||||
Hover_signal(logout_button.background, color["Green200"])
|
||||
Hover_signal(lock_button.background, color["Orange200"])
|
||||
-- Create the buttons with their command and name etc
|
||||
local shutdown_button = button("Shutdown", icondir .. "shutdown.svg", color["Blue200"], shutdown_command)
|
||||
local reboot_button = button("Reboot", icondir .. "reboot.svg", color["Red200"], reboot_command)
|
||||
local suspend_button = button("Suspend", icondir .. "suspend.svg", color["Yellow200"], suspend_command)
|
||||
local logout_button = button("Logout", icondir .. "logout.svg", color["Green200"], logout_command)
|
||||
local lock_button = button("Lock", icondir .. "lock.svg", color["Orange200"], lock_command)
|
||||
|
||||
-- The powermenu widget
|
||||
local powermenu = wibox.widget {
|
||||
layout = wibox.layout.align.vertical,
|
||||
expand = "none",
|
||||
-- Signals to change color on hover
|
||||
Hover_signal(shutdown_button.background, color["Blue200"])
|
||||
Hover_signal(reboot_button.background, color["Red200"])
|
||||
Hover_signal(suspend_button.background, color["Yellow200"])
|
||||
Hover_signal(logout_button.background, color["Green200"])
|
||||
Hover_signal(lock_button.background, color["Orange200"])
|
||||
|
||||
-- The powermenu widget
|
||||
local powermenu = wibox.widget {
|
||||
layout = wibox.layout.align.vertical,
|
||||
expand = "none",
|
||||
nil,
|
||||
{
|
||||
{
|
||||
nil,
|
||||
{
|
||||
{
|
||||
nil,
|
||||
{
|
||||
nil,
|
||||
{
|
||||
{
|
||||
nil,
|
||||
{
|
||||
nil,
|
||||
{
|
||||
profile_picture,
|
||||
margins = dpi(0),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
nil,
|
||||
expand = "none",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
nil,
|
||||
layout = wibox.layout.align.vertical,
|
||||
expand = "none"
|
||||
},
|
||||
spacing = dpi(50),
|
||||
{
|
||||
profile_name,
|
||||
margins = dpi(0),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
nil,
|
||||
expand = "none",
|
||||
layout = wibox.layout.align.horizontal
|
||||
nil,
|
||||
{
|
||||
profile_picture,
|
||||
margins = dpi(0),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
nil,
|
||||
expand = "none",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
{
|
||||
nil,
|
||||
{
|
||||
{
|
||||
shutdown_button,
|
||||
reboot_button,
|
||||
logout_button,
|
||||
lock_button,
|
||||
suspend_button,
|
||||
spacing = dpi(30),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
margins = dpi(0),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
nil,
|
||||
expand = "none",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
layout = wibox.layout.align.vertical
|
||||
nil,
|
||||
layout = wibox.layout.align.vertical,
|
||||
expand = "none"
|
||||
},
|
||||
spacing = dpi(50),
|
||||
{
|
||||
profile_name,
|
||||
margins = dpi(0),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
nil
|
||||
}
|
||||
nil,
|
||||
expand = "none",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
{
|
||||
nil,
|
||||
{
|
||||
{
|
||||
shutdown_button,
|
||||
reboot_button,
|
||||
logout_button,
|
||||
lock_button,
|
||||
suspend_button,
|
||||
spacing = dpi(30),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
margins = dpi(0),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
nil,
|
||||
expand = "none",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
layout = wibox.layout.align.vertical
|
||||
},
|
||||
nil
|
||||
}
|
||||
|
||||
-- Container for the widget, covers the entire screen
|
||||
local powermenu_container = wibox {
|
||||
widget = powermenu,
|
||||
screen = s,
|
||||
type = "splash",
|
||||
visible = false,
|
||||
ontop = true,
|
||||
bg = "#21212188",
|
||||
height = s.geometry.height,
|
||||
width = s.geometry.width,
|
||||
x = s.geometry.x,
|
||||
y = s.geometry.y
|
||||
}
|
||||
-- Container for the widget, covers the entire screen
|
||||
local powermenu_container = wibox {
|
||||
widget = powermenu,
|
||||
screen = s,
|
||||
type = "splash",
|
||||
visible = false,
|
||||
ontop = true,
|
||||
bg = "#21212188",
|
||||
height = s.geometry.height,
|
||||
width = s.geometry.width,
|
||||
x = s.geometry.x,
|
||||
y = s.geometry.y
|
||||
}
|
||||
|
||||
-- Close on rightclick
|
||||
powermenu_container:buttons(
|
||||
gears.table.join(
|
||||
awful.button(
|
||||
{},
|
||||
3,
|
||||
function()
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
-- Close on Escape
|
||||
local powermenu_keygrabber = awful.keygrabber {
|
||||
autostart = false,
|
||||
stop_event = 'release',
|
||||
keypressed_callback = function(self, mod, key, command)
|
||||
if key == 'Escape' then
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
-- Signals
|
||||
awesome.connect_signal(
|
||||
"module::powermenu:show",
|
||||
-- Close on rightclick
|
||||
powermenu_container:buttons(
|
||||
gears.table.join(
|
||||
awful.button(
|
||||
{},
|
||||
3,
|
||||
function()
|
||||
if s == mouse.screen then
|
||||
powermenu_container.visible = true
|
||||
powermenu_keygrabber:start()
|
||||
end
|
||||
end
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
awesome.connect_signal(
|
||||
"module::powermenu:hide",
|
||||
function()
|
||||
powermenu_keygrabber:stop()
|
||||
powermenu_container.visible = false
|
||||
end
|
||||
)
|
||||
-- Close on Escape
|
||||
local powermenu_keygrabber = awful.keygrabber {
|
||||
autostart = false,
|
||||
stop_event = 'release',
|
||||
keypressed_callback = function(self, mod, key, command)
|
||||
if key == 'Escape' then
|
||||
awesome.emit_signal("module::powermenu:hide")
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
-- Signals
|
||||
awesome.connect_signal(
|
||||
"module::powermenu:show",
|
||||
function()
|
||||
if s == mouse.screen then
|
||||
powermenu_container.visible = true
|
||||
powermenu_keygrabber:start()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
awesome.connect_signal(
|
||||
"module::powermenu:hide",
|
||||
function()
|
||||
powermenu_keygrabber:stop()
|
||||
powermenu_container.visible = false
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
@@ -17,235 +17,236 @@ awful.titlebar.enable_tooltip = true
|
||||
awful.titlebar.fallback_name = 'Client'
|
||||
|
||||
local double_click_event_handler = function(double_click_event)
|
||||
if double_click_timer then
|
||||
double_click_timer:stop()
|
||||
double_click_timer = nil
|
||||
double_click_event()
|
||||
return
|
||||
end
|
||||
double_click_timer = gears.timer.start_new(
|
||||
0.20,
|
||||
function()
|
||||
double_click_timer = nil
|
||||
return false
|
||||
end
|
||||
)
|
||||
if double_click_timer then
|
||||
double_click_timer:stop()
|
||||
double_click_timer = nil
|
||||
double_click_event()
|
||||
return
|
||||
end
|
||||
double_click_timer = gears.timer.start_new(
|
||||
0.20,
|
||||
function()
|
||||
double_click_timer = nil
|
||||
return false
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
local create_click_events = function(c)
|
||||
local buttons = gears.table.join(
|
||||
awful.button(
|
||||
{},
|
||||
1,
|
||||
function()
|
||||
double_click_event_handler(function()
|
||||
if c.floating then
|
||||
c.float = false
|
||||
return
|
||||
end
|
||||
c.maximized = not c.maximized
|
||||
c:raise()
|
||||
end)
|
||||
c:activate { context = 'titlebar', action = 'mouse_move' }
|
||||
end
|
||||
),
|
||||
awful.button(
|
||||
{},
|
||||
3,
|
||||
function()
|
||||
c:activate { context = 'titlebar', action = 'mouse_resize' }
|
||||
end
|
||||
)
|
||||
local buttons = gears.table.join(
|
||||
awful.button(
|
||||
{},
|
||||
1,
|
||||
function()
|
||||
double_click_event_handler(function()
|
||||
if c.floating then
|
||||
c.float = false
|
||||
return
|
||||
end
|
||||
c.maximized = not c.maximized
|
||||
c:raise()
|
||||
end)
|
||||
c:activate { context = 'titlebar', action = 'mouse_move' }
|
||||
end
|
||||
),
|
||||
awful.button(
|
||||
{},
|
||||
3,
|
||||
function()
|
||||
c:activate { context = 'titlebar', action = 'mouse_resize' }
|
||||
end
|
||||
)
|
||||
return buttons
|
||||
)
|
||||
return buttons
|
||||
end
|
||||
|
||||
local create_titlebar = function(c, bg, size)
|
||||
local titlebar = awful.titlebar(c, {
|
||||
position = "left",
|
||||
bg = bg,
|
||||
size = size
|
||||
})
|
||||
local titlebar = awful.titlebar(c, {
|
||||
position = "left",
|
||||
bg = bg,
|
||||
size = size
|
||||
})
|
||||
|
||||
titlebar:setup {
|
||||
titlebar:setup {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
awful.titlebar.widget.closebutton(c),
|
||||
widget = wibox.container.background,
|
||||
bg = color["Red200"],
|
||||
shape = function(cr, height, width)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
id = "closebutton"
|
||||
},
|
||||
{
|
||||
awful.titlebar.widget.maximizedbutton(c),
|
||||
widget = wibox.container.background,
|
||||
bg = color["Yellow200"],
|
||||
shape = function(cr, height, width)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
id = "maximizebutton"
|
||||
},
|
||||
{
|
||||
awful.titlebar.widget.minimizebutton(c),
|
||||
widget = wibox.container.background,
|
||||
bg = color["Green200"],
|
||||
shape = function(cr, height, width)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
id = "minimizebutton"
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
id = "spacing"
|
||||
},
|
||||
margins = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
id = "margin"
|
||||
awful.titlebar.widget.closebutton(c),
|
||||
widget = wibox.container.background,
|
||||
bg = color["Red200"],
|
||||
shape = function(cr, height, width)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
id = "closebutton"
|
||||
},
|
||||
{
|
||||
buttons = create_click_events(c),
|
||||
layout = wibox.layout.flex.vertical
|
||||
awful.titlebar.widget.maximizedbutton(c),
|
||||
widget = wibox.container.background,
|
||||
bg = color["Yellow200"],
|
||||
shape = function(cr, height, width)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
id = "maximizebutton"
|
||||
},
|
||||
{
|
||||
{
|
||||
widget = awful.widget.clienticon(c)
|
||||
},
|
||||
margins = dpi(5),
|
||||
widget = wibox.container.margin
|
||||
awful.titlebar.widget.minimizebutton(c),
|
||||
widget = wibox.container.background,
|
||||
bg = color["Green200"],
|
||||
shape = function(cr, height, width)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
id = "minimizebutton"
|
||||
},
|
||||
layout = wibox.layout.align.vertical,
|
||||
id = "main"
|
||||
}
|
||||
Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"])
|
||||
Hover_signal(titlebar.main.margin.spacing.maximizebutton, color["Yellow200"])
|
||||
Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"])
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
id = "spacing"
|
||||
},
|
||||
margins = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
id = "margin"
|
||||
},
|
||||
{
|
||||
buttons = create_click_events(c),
|
||||
layout = wibox.layout.flex.vertical
|
||||
},
|
||||
{
|
||||
{
|
||||
widget = awful.widget.clienticon(c)
|
||||
},
|
||||
margins = dpi(5),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
layout = wibox.layout.align.vertical,
|
||||
id = "main"
|
||||
}
|
||||
Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"])
|
||||
Hover_signal(titlebar.main.margin.spacing.maximizebutton, color["Yellow200"])
|
||||
Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"])
|
||||
end
|
||||
|
||||
local create_titlebar_dialog = function(c, bg, size)
|
||||
local titlebar = awful.titlebar(c, {
|
||||
position = "left",
|
||||
bg = bg,
|
||||
size = size
|
||||
})
|
||||
local titlebar = awful.titlebar(c, {
|
||||
position = "left",
|
||||
bg = bg,
|
||||
size = size
|
||||
})
|
||||
|
||||
titlebar:setup {
|
||||
titlebar:setup {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
awful.titlebar.widget.closebutton(c),
|
||||
widget = wibox.container.background,
|
||||
bg = color["Red200"],
|
||||
shape = function(cr, height, width)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
id = "closebutton"
|
||||
},
|
||||
{
|
||||
awful.titlebar.widget.minimizebutton(c),
|
||||
widget = wibox.container.background,
|
||||
bg = color["Green200"],
|
||||
shape = function(cr, height, width)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
id = "minimizebutton"
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
id = "spacing"
|
||||
},
|
||||
margins = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
id = "margin"
|
||||
awful.titlebar.widget.closebutton(c),
|
||||
widget = wibox.container.background,
|
||||
bg = color["Red200"],
|
||||
shape = function(cr, height, width)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
id = "closebutton"
|
||||
},
|
||||
{
|
||||
buttons = create_click_events(c),
|
||||
layout = wibox.layout.flex.vertical
|
||||
awful.titlebar.widget.minimizebutton(c),
|
||||
widget = wibox.container.background,
|
||||
bg = color["Green200"],
|
||||
shape = function(cr, height, width)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
id = "minimizebutton"
|
||||
},
|
||||
{
|
||||
{
|
||||
widget = awful.widget.clienticon(c)
|
||||
},
|
||||
margins = dpi(5),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
layout = wibox.layout.align.vertical,
|
||||
id = "main"
|
||||
}
|
||||
Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"])
|
||||
Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"])
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
id = "spacing"
|
||||
},
|
||||
margins = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
id = "margin"
|
||||
},
|
||||
{
|
||||
buttons = create_click_events(c),
|
||||
layout = wibox.layout.flex.vertical
|
||||
},
|
||||
{
|
||||
{
|
||||
widget = awful.widget.clienticon(c)
|
||||
},
|
||||
margins = dpi(5),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
layout = wibox.layout.align.vertical,
|
||||
id = "main"
|
||||
}
|
||||
Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"])
|
||||
Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"])
|
||||
end
|
||||
|
||||
local draw_titlebar = function(c)
|
||||
if c.type == 'normal' and not c.requests_no_titlebar then
|
||||
if c.class == 'Firefox' then
|
||||
create_titlebar(c, '#121212AA', 35)
|
||||
elseif c.name == "Steam" then
|
||||
create_titlebar(c, '#121212AA', 0)
|
||||
elseif c.name == "Settings" then
|
||||
create_titlebar(c, '#121212AA', 0)
|
||||
elseif c.class == "gcr-prompter" or c.class == "Gcr-prompter" then
|
||||
create_titlebar(c, '#121212AA', 0)
|
||||
else
|
||||
create_titlebar(c, '#121212AA', 35)
|
||||
end
|
||||
elseif c.type == 'dialog' then
|
||||
create_titlebar_dialog(c, '#121212AA', 35)
|
||||
if c.type == 'normal' and not c.requests_no_titlebar then
|
||||
if c.class == 'Firefox' then
|
||||
create_titlebar(c, '#121212AA', 35)
|
||||
elseif c.name == "Steam" then
|
||||
create_titlebar(c, '#121212AA', 0)
|
||||
elseif c.name == "Settings" then
|
||||
create_titlebar(c, '#121212AA', 0)
|
||||
elseif c.class == "gcr-prompter" or c.class == "Gcr-prompter" then
|
||||
create_titlebar(c, '#121212AA', 0)
|
||||
else
|
||||
create_titlebar(c, '#121212AA', 35)
|
||||
end
|
||||
elseif c.type == 'dialog' then
|
||||
create_titlebar_dialog(c, '#121212AA', 35)
|
||||
end
|
||||
end
|
||||
|
||||
client.connect_signal(
|
||||
"property::maximized",
|
||||
function(c)
|
||||
if c.maximized then
|
||||
Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg"
|
||||
Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg"
|
||||
Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg"
|
||||
elseif not c.minimized then
|
||||
Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg"
|
||||
Theme.titlebar_maximized_button_active = icondir .. "maximize.svg"
|
||||
Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg"
|
||||
end
|
||||
end
|
||||
"property::maximized",
|
||||
function(c)
|
||||
if c.maximized then
|
||||
Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg"
|
||||
Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg"
|
||||
Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg"
|
||||
elseif not c.minimized then
|
||||
Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg"
|
||||
Theme.titlebar_maximized_button_active = icondir .. "maximize.svg"
|
||||
Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg"
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
client.connect_signal(
|
||||
"request::titlebars",
|
||||
function(c)
|
||||
if c.maximized then
|
||||
Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg"
|
||||
Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg"
|
||||
Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg"
|
||||
elseif not c.minimized then
|
||||
Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg"
|
||||
Theme.titlebar_maximized_button_active = icondir .. "maximize.svg"
|
||||
Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg"
|
||||
end
|
||||
draw_titlebar(c)
|
||||
if not c.floating or c.maximized then
|
||||
awful.titlebar.hide(c, 'left')
|
||||
awful.titlebar.hide(c, 'right')
|
||||
awful.titlebar.hide(c, 'top')
|
||||
awful.titlebar.hide(c, 'bottom')
|
||||
end
|
||||
end
|
||||
"request::titlebars",
|
||||
function(c)
|
||||
if c.maximized then
|
||||
Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg"
|
||||
Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg"
|
||||
Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg"
|
||||
draw_titlebar(c)
|
||||
elseif not c.minimized then
|
||||
Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg"
|
||||
Theme.titlebar_maximized_button_active = icondir .. "maximize.svg"
|
||||
Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg"
|
||||
draw_titlebar(c)
|
||||
end
|
||||
if not c.floating or c.maximized then
|
||||
awful.titlebar.hide(c, 'left')
|
||||
awful.titlebar.hide(c, 'right')
|
||||
awful.titlebar.hide(c, 'top')
|
||||
awful.titlebar.hide(c, 'bottom')
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
client.connect_signal(
|
||||
'property::floating',
|
||||
function(c)
|
||||
if c.floating or (c.floating and c.maximized) then
|
||||
awful.titlebar.show(c, 'left')
|
||||
awful.titlebar.hide(c, 'right')
|
||||
awful.titlebar.hide(c, 'top')
|
||||
awful.titlebar.hide(c, 'bottom')
|
||||
else
|
||||
awful.titlebar.hide(c, 'left')
|
||||
awful.titlebar.hide(c, 'right')
|
||||
awful.titlebar.hide(c, 'top')
|
||||
awful.titlebar.hide(c, 'bottom')
|
||||
end
|
||||
end
|
||||
'property::floating',
|
||||
function(c)
|
||||
if c.floating or (c.floating and c.maximized) then
|
||||
awful.titlebar.show(c, 'left')
|
||||
awful.titlebar.hide(c, 'right')
|
||||
awful.titlebar.hide(c, 'top')
|
||||
awful.titlebar.hide(c, 'bottom')
|
||||
else
|
||||
awful.titlebar.hide(c, 'left')
|
||||
awful.titlebar.hide(c, 'right')
|
||||
awful.titlebar.hide(c, 'top')
|
||||
awful.titlebar.hide(c, 'bottom')
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
792
awesome/src/modules/volume_controller.lua
Normal file
792
awesome/src/modules/volume_controller.lua
Normal file
@@ -0,0 +1,792 @@
|
||||
-----------------------------------
|
||||
-- This is the volume controller --
|
||||
-----------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
require("src.core.signals")
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = awful.util.getdir("config") .. "src/assets/icons/audio/"
|
||||
|
||||
-- Returns the volume controller
|
||||
return function(s)
|
||||
|
||||
local function create_device(name, node, sink)
|
||||
local device = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
image = "",
|
||||
id = "icon",
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
{
|
||||
text = name,
|
||||
id = "node",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
id = "device_layout",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
id = "device_margin",
|
||||
margins = dpi(5),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "background",
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
margins = dpi(5),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
if sink == true then
|
||||
device:connect_signal(
|
||||
"button::press",
|
||||
function()
|
||||
awful.spawn.spawn("./.config/awesome/src/scripts/vol.sh set_sink " .. node)
|
||||
|
||||
awesome.emit_signal("update::background:vol", node)
|
||||
end
|
||||
)
|
||||
|
||||
--#region Signal Functions
|
||||
local old_wibox, old_cursor, old_bg, old_fg
|
||||
local bg = ""
|
||||
local fg = ""
|
||||
local mouse_enter = function()
|
||||
if bg then
|
||||
old_bg = device.background.bg
|
||||
device.background.bg = bg .. 'dd'
|
||||
end
|
||||
if fg then
|
||||
old_fg = device.background.fg
|
||||
device.background.fg = fg
|
||||
end
|
||||
local w = mouse.current_wibox
|
||||
if w then
|
||||
old_cursor, old_wibox = w.cursor, w
|
||||
w.cursor = "hand1"
|
||||
end
|
||||
end
|
||||
|
||||
local button_press = function()
|
||||
if bg then
|
||||
if bg then
|
||||
if string.len(bg) == 7 then
|
||||
device.background.bg = bg .. 'bb'
|
||||
else
|
||||
device.background.bg = bg
|
||||
end
|
||||
end
|
||||
end
|
||||
if fg then
|
||||
device.background.fg = fg
|
||||
end
|
||||
end
|
||||
|
||||
local button_release = function()
|
||||
if bg then
|
||||
if bg then
|
||||
if string.len(bg) == 7 then
|
||||
device.background.bg = bg .. 'dd'
|
||||
else
|
||||
device.background.bg = bg
|
||||
end
|
||||
end
|
||||
end
|
||||
if fg then
|
||||
device.background.fg = fg
|
||||
end
|
||||
end
|
||||
|
||||
local mouse_leave = function()
|
||||
if bg then
|
||||
device.background.bg = old_bg
|
||||
end
|
||||
if fg then
|
||||
device.background.fg = old_fg
|
||||
end
|
||||
if old_wibox then
|
||||
old_wibox.cursor = old_cursor
|
||||
old_wibox = nil
|
||||
end
|
||||
end
|
||||
|
||||
device:connect_signal(
|
||||
"mouse::enter",
|
||||
mouse_enter
|
||||
)
|
||||
|
||||
device:connect_signal(
|
||||
"button::press",
|
||||
button_press
|
||||
)
|
||||
|
||||
device:connect_signal(
|
||||
"button::release",
|
||||
button_release
|
||||
)
|
||||
|
||||
device:connect_signal(
|
||||
"mouse::leave",
|
||||
mouse_leave
|
||||
)
|
||||
--#endregion
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::background:vol",
|
||||
function(new_node)
|
||||
if node == new_node then
|
||||
old_bg = color["Purple200"]
|
||||
old_fg = color["Grey900"]
|
||||
bg = color["Purple200"]
|
||||
fg = color["Grey900"]
|
||||
device.background:set_bg(color["Purple200"])
|
||||
device.background:set_fg(color["Grey900"])
|
||||
else
|
||||
fg = color["Purple200"]
|
||||
bg = color["Grey700"]
|
||||
device.background:set_fg(color["Purple200"])
|
||||
device.background:set_bg(color["Grey700"])
|
||||
end
|
||||
end
|
||||
)
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[[ pactl get-default-sink ]],
|
||||
function(stdout)
|
||||
local node_active = stdout:gsub("\n", "")
|
||||
if node == node_active then
|
||||
bg = color["Purple200"]
|
||||
fg = color["Grey900"]
|
||||
device.background:set_bg(color["Purple200"])
|
||||
device.background:set_fg(color["Grey900"])
|
||||
else
|
||||
fg = color["Purple200"]
|
||||
bg = color["Grey700"]
|
||||
device.background:set_fg(color["Purple200"])
|
||||
device.background:set_bg(color["Grey700"])
|
||||
end
|
||||
end
|
||||
)
|
||||
else
|
||||
|
||||
device:connect_signal(
|
||||
"button::press",
|
||||
function()
|
||||
awful.spawn.spawn("./.config/awesome/src/scripts/mic.sh set_source " .. node)
|
||||
|
||||
awesome.emit_signal("update::background:mic", node)
|
||||
end
|
||||
)
|
||||
|
||||
--#region Signal Functions
|
||||
local old_wibox, old_cursor, old_bg, old_fg
|
||||
local bg = ""
|
||||
local fg = ""
|
||||
local mouse_enter = function()
|
||||
if bg then
|
||||
old_bg = device.background.bg
|
||||
device.background.bg = bg .. 'dd'
|
||||
end
|
||||
if fg then
|
||||
old_fg = device.background.fg
|
||||
device.background.fg = fg
|
||||
end
|
||||
local w = mouse.current_wibox
|
||||
if w then
|
||||
old_cursor, old_wibox = w.cursor, w
|
||||
w.cursor = "hand1"
|
||||
end
|
||||
end
|
||||
|
||||
local button_press = function()
|
||||
if bg then
|
||||
if bg then
|
||||
if string.len(bg) == 7 then
|
||||
device.background.bg = bg .. 'bb'
|
||||
else
|
||||
device.background.bg = bg
|
||||
end
|
||||
end
|
||||
end
|
||||
if fg then
|
||||
device.background.fg = fg
|
||||
end
|
||||
end
|
||||
|
||||
local button_release = function()
|
||||
if bg then
|
||||
if bg then
|
||||
if string.len(bg) == 7 then
|
||||
device.background.bg = bg .. 'dd'
|
||||
else
|
||||
device.background.bg = bg
|
||||
end
|
||||
end
|
||||
end
|
||||
if fg then
|
||||
device.background.fg = fg
|
||||
end
|
||||
end
|
||||
|
||||
local mouse_leave = function()
|
||||
if bg then
|
||||
device.background.bg = old_bg
|
||||
end
|
||||
if fg then
|
||||
device.background.fg = old_fg
|
||||
end
|
||||
if old_wibox then
|
||||
old_wibox.cursor = old_cursor
|
||||
old_wibox = nil
|
||||
end
|
||||
end
|
||||
|
||||
device:connect_signal(
|
||||
"mouse::enter",
|
||||
mouse_enter
|
||||
)
|
||||
|
||||
device:connect_signal(
|
||||
"button::press",
|
||||
button_press
|
||||
)
|
||||
|
||||
device:connect_signal(
|
||||
"button::release",
|
||||
button_release
|
||||
)
|
||||
|
||||
device:connect_signal(
|
||||
"mouse::leave",
|
||||
mouse_leave
|
||||
)
|
||||
--#endregion
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::background:mic",
|
||||
function(new_node)
|
||||
if node == new_node then
|
||||
old_bg = color["Blue200"]
|
||||
old_fg = color["Grey900"]
|
||||
bg = color["Blue200"]
|
||||
fg = color["Grey900"]
|
||||
device.background:set_bg(color["Blue200"])
|
||||
device.background:set_fg(color["Grey900"])
|
||||
else
|
||||
fg = color["Blue200"]
|
||||
bg = color["Grey700"]
|
||||
device.background:set_fg(color["Blue200"])
|
||||
device.background:set_bg(color["Grey700"])
|
||||
end
|
||||
end
|
||||
)
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[[ pactl get-default-source ]],
|
||||
function(stdout)
|
||||
local node_active = stdout:gsub("\n", "")
|
||||
if node == node_active then
|
||||
bg = color["Blue200"]
|
||||
fg = color["Grey900"]
|
||||
device.background:set_bg(color["Blue200"])
|
||||
device.background:set_fg(color["Grey900"])
|
||||
else
|
||||
fg = color["Blue200"]
|
||||
bg = color["Grey700"]
|
||||
device.background:set_fg(color["Blue200"])
|
||||
device.background:set_bg(color["Grey700"])
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
return device
|
||||
end
|
||||
|
||||
local dropdown_list_volume = wibox.widget {
|
||||
{
|
||||
{
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
id = "volume_device_list"
|
||||
},
|
||||
id = "volume_device_background",
|
||||
bg = color["Grey800"],
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, 4)
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
left = dpi(10),
|
||||
right = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
local dropdown_list_microphone = wibox.widget {
|
||||
{
|
||||
{
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
id = "volume_device_list"
|
||||
},
|
||||
id = "volume_device_background",
|
||||
bg = color["Grey800"],
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, 4)
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
left = dpi(10),
|
||||
right = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
local volume_controller = wibox.widget {
|
||||
{
|
||||
{
|
||||
-- Audio Device selector
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
resize = false,
|
||||
image = gears.color.recolor_image(icondir .. "menu-down.svg", color["Purple200"]),
|
||||
widget = wibox.widget.imagebox,
|
||||
id = "icon"
|
||||
},
|
||||
id = "center",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
{
|
||||
{
|
||||
text = "Output Device",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "device_name"
|
||||
},
|
||||
margins = dpi(5),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "audio_volume",
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
id = "audio_bg",
|
||||
bg = color["Grey800"],
|
||||
fg = color["Purple200"],
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
id = "audio_selector_margin",
|
||||
left = dpi(10),
|
||||
right = dpi(10),
|
||||
top = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
{
|
||||
id = "volume_list",
|
||||
widget = dropdown_list_volume,
|
||||
visible = false
|
||||
},
|
||||
-- Microphone selector
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
resize = false,
|
||||
image = gears.color.recolor_image(icondir .. "menu-down.svg", color["LightBlueA200"]),
|
||||
widget = wibox.widget.imagebox,
|
||||
id = "icon",
|
||||
},
|
||||
id = "center",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
{
|
||||
{
|
||||
text = "Input Device",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "device_name"
|
||||
},
|
||||
margins = dpi(5),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "mic_volume",
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
id = "mic_bg",
|
||||
bg = color["Grey800"],
|
||||
fg = color["LightBlueA200"],
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
id = "mic_selector_margin",
|
||||
left = dpi(10),
|
||||
right = dpi(10),
|
||||
top = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
{
|
||||
id = "mic_list",
|
||||
widget = dropdown_list_microphone,
|
||||
visible = false
|
||||
},
|
||||
-- Audio volume slider
|
||||
{
|
||||
{
|
||||
{
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox,
|
||||
image = gears.color.recolor_image(icondir .. "volume-high.svg", color["Purple200"]),
|
||||
id = "icon",
|
||||
},
|
||||
{
|
||||
{
|
||||
bar_shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end,
|
||||
bar_height = dpi(5),
|
||||
bar_color = color["Grey800"],
|
||||
bar_active_color = color["Purple200"],
|
||||
handle_color = color["Purple200"],
|
||||
handle_shape = gears.shape.circle,
|
||||
handle_border_color = color["Purple200"],
|
||||
handle_width = dpi(15),
|
||||
maximum = 100,
|
||||
forced_height = dpi(26),
|
||||
widget = wibox.widget.slider,
|
||||
id = "slider"
|
||||
},
|
||||
bottom = dpi(12),
|
||||
left = dpi(5),
|
||||
id = "slider_margin",
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "audio_volume",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
id = "audio_volume_margin",
|
||||
top = dpi(10),
|
||||
left = dpi(10),
|
||||
right = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
-- Microphone volume slider
|
||||
{
|
||||
{
|
||||
{
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox,
|
||||
image = gears.color.recolor_image(icondir .. "microphone.svg", color["Blue200"]),
|
||||
id = "icon"
|
||||
},
|
||||
{
|
||||
{
|
||||
bar_shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end,
|
||||
bar_height = dpi(5),
|
||||
bar_color = color["Grey800"],
|
||||
bar_active_color = color["Blue200"],
|
||||
handle_color = color["Blue200"],
|
||||
handle_shape = gears.shape.circle,
|
||||
handle_border_color = color["Blue200"],
|
||||
handle_width = dpi(15),
|
||||
maximum = 100,
|
||||
forced_height = dpi(26),
|
||||
widget = wibox.widget.slider,
|
||||
id = "slider"
|
||||
},
|
||||
left = dpi(5),
|
||||
id = "slider_margin",
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "mic_volume",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
id = "mic_volume_margin",
|
||||
left = dpi(10),
|
||||
right = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "controller_layout",
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
id = "controller_margin",
|
||||
margins = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = color["Grey900"],
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(4),
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 12)
|
||||
end,
|
||||
forced_width = dpi(400),
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
-- Variables for easier access and better readability
|
||||
local audio_selector_margin = volume_controller:get_children_by_id("audio_selector_margin")[1]
|
||||
local volume_list = volume_controller:get_children_by_id("volume_list")[1]
|
||||
local audio_bg = volume_controller:get_children_by_id("audio_bg")[1]
|
||||
local audio_volume = volume_controller:get_children_by_id("audio_volume")[1].center
|
||||
|
||||
-- Click event for the audio dropdown
|
||||
audio_selector_margin:connect_signal(
|
||||
"button::press",
|
||||
function()
|
||||
volume_list.visible = not volume_list.visible
|
||||
if volume_list.visible then
|
||||
audio_bg.shape = function(cr, width, height)
|
||||
gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, 4)
|
||||
end
|
||||
audio_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-up.svg", color["Teal200"]))
|
||||
else
|
||||
audio_bg.shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end
|
||||
audio_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-down.svg", color["Teal200"]))
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
-- Variables for easier access and better readability
|
||||
local mic_selector_margin = volume_controller:get_children_by_id("mic_selector_margin")[1]
|
||||
local mic_list = volume_controller:get_children_by_id("mic_list")[1]
|
||||
local mic_bg = volume_controller:get_children_by_id("mic_bg")[1]
|
||||
local mic_volume = volume_controller:get_children_by_id("mic_volume")[1].center
|
||||
|
||||
-- Click event for the microphone dropdown
|
||||
mic_selector_margin:connect_signal(
|
||||
"button::press",
|
||||
function()
|
||||
mic_list.visible = not mic_list.visible
|
||||
if mic_list.visible then
|
||||
mic_selector_margin.mic_bg.shape = function(cr, width, height)
|
||||
gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, 4)
|
||||
end
|
||||
mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-up.svg", color["Teal200"]))
|
||||
else
|
||||
mic_bg.shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 4)
|
||||
end
|
||||
mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-down.svg", color["Teal200"]))
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local audio_slider_margin = volume_controller:get_children_by_id("audio_volume_margin")[1].audio_volume.slider_margin.slider
|
||||
|
||||
-- Volume slider change event
|
||||
audio_slider_margin:connect_signal(
|
||||
"property::value",
|
||||
function()
|
||||
local volume = audio_slider_margin.value
|
||||
awful.spawn("pactl set-sink-volume @DEFAULT_SINK@ " .. tonumber(volume) .. "%")
|
||||
end
|
||||
)
|
||||
|
||||
local mic_slider_margin = volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.slider_margin.slider
|
||||
|
||||
-- Microphone slider change event
|
||||
mic_slider_margin:connect_signal(
|
||||
"property::value",
|
||||
function()
|
||||
local volume = mic_slider_margin.value
|
||||
awful.spawn("pactl set-source-volume @DEFAULT_SOURCE@ " .. tonumber(volume) .. "%")
|
||||
awesome.emit_signal("get::mic_volume", volume)
|
||||
end
|
||||
)
|
||||
|
||||
-- Main container
|
||||
local volume_controller_container = awful.popup {
|
||||
widget = wibox.container.background,
|
||||
ontop = true,
|
||||
bg = color["Grey900"],
|
||||
stretch = false,
|
||||
visible = false,
|
||||
screen = s,
|
||||
placement = function(c) awful.placement.align(c, { position = "top_right", margins = { right = dpi(305), top = dpi(60) } }) end,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 12)
|
||||
end
|
||||
}
|
||||
|
||||
-- Get all audio devices from all sinks
|
||||
local function get_devices()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[[ pactl list sinks | grep -E 'node.name|alsa.card_name' | awk '{gsub(/"/, ""); for(i = 3;i < NF;i++) printf $i " "; print $NF}' ]],
|
||||
|
||||
function(stdout)
|
||||
local i, j = 1, 1
|
||||
local device_list = { layout = wibox.layout.fixed.vertical }
|
||||
|
||||
local node_names, alsa_names = {}, {}
|
||||
for node_name in stdout:gmatch("[^\n]+") do
|
||||
if (i % 2) == 0 then
|
||||
table.insert(node_names, node_name)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
for alsa_name in stdout:gmatch("[^\n]+") do
|
||||
if (j % 2) == 1 then
|
||||
table.insert(alsa_names, alsa_name)
|
||||
end
|
||||
j = j + 1
|
||||
end
|
||||
|
||||
for k = 1, #alsa_names, 1 do
|
||||
device_list[#device_list + 1] = create_device(alsa_names[k], node_names[k], true)
|
||||
end
|
||||
dropdown_list_volume.volume_device_background.volume_device_list.children = device_list
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
get_devices()
|
||||
|
||||
-- Get all input devices from all sources
|
||||
local function get_input_devices()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[[ pactl list sources | grep -E "node.name|alsa.card_name" | awk '{gsub(/"/, ""); for(i = 3;i < NF;i++) printf $i " "; print $NF}' ]],
|
||||
|
||||
function(stdout)
|
||||
local i, j = 1, 1
|
||||
local device_list = { layout = wibox.layout.fixed.vertical }
|
||||
|
||||
local node_names, alsa_names = {}, {}
|
||||
for node_name in stdout:gmatch("[^\n]+") do
|
||||
if (i % 2) == 0 then
|
||||
table.insert(node_names, node_name)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
for alsa_name in stdout:gmatch("[^\n]+") do
|
||||
if (j % 2) == 1 then
|
||||
table.insert(alsa_names, alsa_name)
|
||||
end
|
||||
j = j + 1
|
||||
end
|
||||
|
||||
for k = 1, #alsa_names, 1 do
|
||||
device_list[#device_list + 1] = create_device(alsa_names[k], node_names[k], false)
|
||||
end
|
||||
dropdown_list_microphone.volume_device_background.volume_device_list.children = device_list
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
get_input_devices()
|
||||
|
||||
-- Get microphone volume
|
||||
local function get_mic_volume()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"./.config/awesome/src/scripts/mic.sh volume",
|
||||
function(stdout)
|
||||
local volume = stdout:gsub("%%", ""):gsub("\n", "")
|
||||
volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.slider_margin.slider:set_value(tonumber(volume))
|
||||
if volume > 0 then
|
||||
volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir .. "microphone.svg", color["LightBlue200"]))
|
||||
else
|
||||
volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir .. "microphone-off.svg", color["LightBlue200"]))
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
get_mic_volume()
|
||||
|
||||
-- Check if microphone is muted
|
||||
local function get_mic_mute()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"./.config/awesome/src/scripts/mic.sh mute",
|
||||
function(stdout)
|
||||
if stdout:match("yes") then
|
||||
volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.slider_margin.slider:set_value(tonumber(0))
|
||||
volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir .. "microphone-off.svg", color["LightBlue200"]))
|
||||
else
|
||||
get_mic_volume()
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
get_mic_mute()
|
||||
|
||||
volume_controller_container:setup {
|
||||
volume_controller,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
|
||||
-- Global signal called from src.widgets.audio.lua
|
||||
awesome.connect_signal(
|
||||
"get::volume",
|
||||
function(volume)
|
||||
volume = tonumber(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
|
||||
|
||||
volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.slider_margin.slider:set_value(volume)
|
||||
volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.icon:set_image(gears.color.recolor_image(icon .. ".svg", color["Purple200"]))
|
||||
end
|
||||
)
|
||||
|
||||
-- Global signal called from src.widgets.audio.lua
|
||||
awesome.connect_signal(
|
||||
"get::volume_mute",
|
||||
function(mute)
|
||||
if mute then
|
||||
volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.icon:set_image(gears.color.recolor_image(icondir .. "volume-mute.svg", color["Purple200"]))
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
awesome.connect_signal(
|
||||
"get::mic_volume",
|
||||
function(volume)
|
||||
if volume > 0 then
|
||||
volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "microphone.svg", color["LightBlue200"]))
|
||||
else
|
||||
volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "microphone-off.svg", color["LightBlue200"]))
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
-- Toggle container visibility
|
||||
awesome.connect_signal(
|
||||
"volume_controller::toggle",
|
||||
function(scr)
|
||||
if scr == s then
|
||||
volume_controller_container.visible = not volume_controller_container.visible
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user