This commit is contained in:
Rene Kievits
2022-12-08 16:06:16 +01:00
parent 675ab6692d
commit 42a888c311
68 changed files with 732 additions and 2238 deletions

View File

@@ -134,7 +134,7 @@ function device.new(args)
inputbox,
widget = wibox.container.constraint,
strategy = "exact",
width = dpi(400),
width = dpi(300),
id = "const"
},
spacing = dpi(10),

View File

@@ -6,7 +6,7 @@
local abutton = require("awful.button")
local aspawn = require("awful.spawn")
local base = require("wibox.widget.base")
local dbus_proxy = require("dbus_proxy")
local dbus_proxy = require("src.lib.lua-dbus_proxy.src.dbus_proxy")
local dpi = require("beautiful").xresources.apply_dpi
local gcolor = require("gears").color
local gfilesystem = require("gears").filesystem
@@ -249,167 +249,159 @@ end
function bluetooth.new(args)
args = args or {}
local ret = base.make_widget_from_value(wibox.widget {
-- For some reason the first widget isn't read so the first container is a duplicate
local ret = base.make_widget_from_value({
{
{
{
{
{
{
{
resize = false,
image = gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.connected_icon_color),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
id = "icon"
},
{
{
text = "Paired Devices",
valign = "center",
halign = "center",
widget = wibox.widget.textbox,
},
margins = dpi(5),
widget = wibox.container.margin
},
id = "connected",
layout = wibox.layout.fixed.horizontal
},
bg = Theme_config.bluetooth_controller.connected_bg,
fg = Theme_config.bluetooth_controller.connected_fg,
shape = Theme_config.bluetooth_controller.connected_shape,
widget = wibox.container.background
},
id = "connected_margin",
widget = wibox.container.margin
},
{
{
{
step = dpi(50),
spacing = dpi(10),
layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0,
id = "connected_device_list"
},
id = "margin",
margins = dpi(10),
widget = wibox.container.margin
},
border_color = Theme_config.bluetooth_controller.con_device_border_color,
border_width = Theme_config.bluetooth_controller.con_device_border_width,
shape = Theme_config.bluetooth_controller.con_device_shape,
widget = wibox.container.background,
forced_height = 0,
id = "connected_list",
},
{
{
{
{
resize = false,
image = gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.discovered_icon_color),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
id = "icon",
},
{
{
text = "Nearby Devices",
valign = "center",
halign = "center",
widget = wibox.widget.textbox,
},
margins = dpi(5),
widget = wibox.container.margin
},
id = "discovered",
layout = wibox.layout.fixed.horizontal
},
id = "discovered_bg",
bg = Theme_config.bluetooth_controller.discovered_bg,
fg = Theme_config.bluetooth_controller.discovered_fg,
shape = Theme_config.bluetooth_controller.discovered_shape,
widget = wibox.container.background
},
id = "discovered_margin",
top = dpi(10),
widget = wibox.container.margin
},
{
{
{
id = "discovered_device_list",
spacing = dpi(10),
step = dpi(50),
layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0,
},
margins = dpi(10),
widget = wibox.container.margin
},
border_color = Theme_config.bluetooth_controller.con_device_border_color,
border_width = Theme_config.bluetooth_controller.con_device_border_width,
shape = Theme_config.bluetooth_controller.con_device_shape,
widget = wibox.container.background,
forced_height = 0,
id = "discovered_list",
},
{
{ -- action buttons
{
dnd_widget {
color = Theme_config.bluetooth_controller.power_bg,
size = dpi(40)
},
id = "dnd",
widget = wibox.container.place,
resize = false,
image = gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.connected_icon_color),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center"
halign = "center",
id = "connected_icon"
},
nil,
{ -- refresh
{
{
{
image = gcolor.recolor_image(icondir .. "refresh.svg",
Theme_config.bluetooth_controller.refresh_icon_color),
resize = false,
valign = "center",
halign = "center",
widget = wibox.widget.imagebox,
},
widget = wibox.container.margin,
margins = dpi(5),
text = "Paired Devices",
valign = "center",
halign = "center",
widget = wibox.widget.textbox,
},
shape = Theme_config.bluetooth_controller.refresh_shape,
bg = Theme_config.bluetooth_controller.refresh_bg,
id = "scan",
widget = wibox.container.background
margins = dpi(5),
widget = wibox.container.margin
},
layout = wibox.layout.align.horizontal
layout = wibox.layout.fixed.horizontal
},
widget = wibox.container.margin,
top = dpi(10),
bg = Theme_config.bluetooth_controller.connected_bg,
fg = Theme_config.bluetooth_controller.connected_fg,
shape = Theme_config.bluetooth_controller.connected_shape,
widget = wibox.container.background,
id = "connected_bg"
},
layout = wibox.layout.fixed.vertical
id = "connected_margin",
widget = wibox.container.margin
},
margins = dpi(15),
widget = wibox.container.margin
{
{
{
step = dpi(50),
spacing = dpi(10),
layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0,
id = "connected_device_list"
},
id = "margin",
margins = dpi(10),
widget = wibox.container.margin
},
border_color = Theme_config.bluetooth_controller.con_device_border_color,
border_width = Theme_config.bluetooth_controller.con_device_border_width,
shape = Theme_config.bluetooth_controller.con_device_shape,
widget = wibox.container.background,
forced_height = 0,
id = "connected_list",
},
{
{
{
{
resize = false,
image = gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.discovered_icon_color),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
id = "discovered_icon",
},
{
{
text = "Nearby Devices",
valign = "center",
halign = "center",
widget = wibox.widget.textbox,
},
margins = dpi(5),
widget = wibox.container.margin
},
layout = wibox.layout.fixed.horizontal
},
id = "discovered_bg",
bg = Theme_config.bluetooth_controller.discovered_bg,
fg = Theme_config.bluetooth_controller.discovered_fg,
shape = Theme_config.bluetooth_controller.discovered_shape,
widget = wibox.container.background
},
id = "discovered_margin",
top = dpi(10),
widget = wibox.container.margin
},
{
{
{
id = "discovered_device_list",
spacing = dpi(10),
step = dpi(50),
layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0,
},
margins = dpi(10),
widget = wibox.container.margin
},
border_color = Theme_config.bluetooth_controller.con_device_border_color,
border_width = Theme_config.bluetooth_controller.con_device_border_width,
shape = Theme_config.bluetooth_controller.con_device_shape,
widget = wibox.container.background,
forced_height = 0,
id = "discovered_list",
},
{
{ -- action buttons
{
dnd_widget {
color = Theme_config.bluetooth_controller.power_bg,
size = dpi(40)
},
id = "dnd",
widget = wibox.container.place,
valign = "center",
halign = "center"
},
nil,
{ -- refresh
{
{
image = gcolor.recolor_image(icondir .. "refresh.svg",
Theme_config.bluetooth_controller.refresh_icon_color),
resize = false,
valign = "center",
halign = "center",
widget = wibox.widget.imagebox,
},
widget = wibox.container.margin,
margins = dpi(5),
},
shape = Theme_config.bluetooth_controller.refresh_shape,
bg = Theme_config.bluetooth_controller.refresh_bg,
id = "scan",
widget = wibox.container.background
},
layout = wibox.layout.align.horizontal
},
widget = wibox.container.margin,
top = dpi(10),
},
layout = wibox.layout.fixed.vertical
},
shape = Theme_config.bluetooth_controller.shape,
border_color = Theme_config.bluetooth_controller.container_border_color,
border_width = Theme_config.bluetooth_controller.container_border_width,
bg = Theme_config.bluetooth_controller.container_bg,
widget = wibox.container.background
margins = dpi(15),
widget = wibox.container.margin,
},
width = dpi(400),
strategy = "exact",
widget = wibox.container.constraint
margins = dpi(15),
widget = wibox.container.margin,
})
-- Get a reference to the dnd button
@@ -489,7 +481,7 @@ function bluetooth.new(args)
--#region Dropdown logic
local connected_margin = ret:get_children_by_id("connected_margin")[1]
local connected_list = ret:get_children_by_id("connected_list")[1]
local connected = ret:get_children_by_id("connected")[1].center
local connected_icon = ret:get_children_by_id("connected_icon")[1]
connected_margin:connect_signal(
"button::press",
@@ -503,21 +495,23 @@ function bluetooth.new(args)
end
}
if connected_list.forced_height == 0 then
local size = (#ret:get_paired_devices() * 60) + 1
local size = (#ret:get_paired_devices() * 60)
if size < 210 then
rubato_timer.target = dpi(size)
end
connected_margin.connected_bg.shape = function(cr, width, height)
gshape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4))
if size > 0 then
connected_margin.connected_bg.shape = function(cr, width, height)
gshape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4))
end
connected_icon:set_image(gcolor.recolor_image(icondir .. "menu-up.svg",
Theme_config.bluetooth_controller.connected_icon_color))
end
connected.icon:set_image(gcolor.recolor_image(icondir .. "menu-up.svg",
Theme_config.bluetooth_controller.connected_icon_color))
else
rubato_timer.target = 0
connected_margin.connected_bg.shape = function(cr, width, height)
gshape.rounded_rect(cr, width, height, 4)
end
connected.icon:set_image(gcolor.recolor_image(icondir .. "menu-down.svg",
connected_icon:set_image(gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.connected_icon_color))
end
end
@@ -526,7 +520,7 @@ function bluetooth.new(args)
local discovered_margin = ret:get_children_by_id("discovered_margin")[1]
local discovered_list = ret:get_children_by_id("discovered_list")[1]
local discovered_bg = ret:get_children_by_id("discovered_bg")[1]
local discovered = ret:get_children_by_id("discovered")[1].center
local discovered_icon = ret:get_children_by_id("discovered_icon")[1]
discovered_margin:connect_signal(
"button::press",
@@ -541,22 +535,24 @@ function bluetooth.new(args)
}
if discovered_list.forced_height == 0 then
local size = (#ret:get_discovered_devices() * 60) + 1
local size = (#ret:get_discovered_devices() * 60)
if size > 210 then
size = 210
end
rubato_timer.target = dpi(size)
discovered_margin.discovered_bg.shape = function(cr, width, height)
gshape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4))
if size > 0 then
rubato_timer.target = dpi(size)
discovered_margin.discovered_bg.shape = function(cr, width, height)
gshape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4))
end
discovered_icon:set_image(gcolor.recolor_image(icondir .. "menu-up.svg",
Theme_config.bluetooth_controller.discovered_icon_color))
end
discovered.icon:set_image(gcolor.recolor_image(icondir .. "menu-up.svg",
Theme_config.bluetooth_controller.discovered_icon_color))
else
rubato_timer.target = 0
discovered_bg.shape = function(cr, width, height)
gshape.rounded_rect(cr, width, height, 4)
end
discovered.icon:set_image(gcolor.recolor_image(icondir .. "menu-down.svg",
discovered_icon:set_image(gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.discovered_icon_color))
end
end

View File

@@ -15,7 +15,7 @@ return function(s)
elseif widget == "Battery" then
table.insert(widget_table, require("src.widgets.battery")(User_config.battery_kind))
elseif widget == "Bluetooth" then
table.insert(widget_table, require("src.widgets.bluetooth")())
table.insert(widget_table, require("src.widgets.bluetooth")(s))
elseif widget == "Clock" then
table.insert(widget_table, require("src.widgets.clock")())
elseif widget == "Cpu Frequency" then

View File

@@ -16,7 +16,8 @@ local cm = require("src.modules.context_menu.init")
local capi = {
mouse = mouse,
awesome = awesome
awesome = awesome,
screen = screen,
}
local icondir = gfilesystem.get_configuration_dir() .. "src/assets/icons/desktop/"
@@ -46,7 +47,7 @@ function desktop:save_layout()
}
end
local dir = gfilesystem.get_configuration_dir() .. "src/config"
dir = gfilesystem.get_configuration_dir() .. "src/config"
gfilesystem.make_directories(dir)
if not gfilesystem.file_readable(dir .. "/desktop.json") then
os.execute("touch " .. dir .. "/desktop.json")
@@ -214,6 +215,9 @@ function desktop:add_element(args, pos)
cm_popup.visible = false
end)
local cols = math.floor(self.args.screen.geometry.width / (args.icon_size * 1.75 * (4 / 3)))
local rows = math.floor((self.args.screen.geometry.height - 75 + 95) / (args.icon_size * 1.75))
print(cols, rows)
-- While the mouse is down, remove the element from the grid and add it to manual then move it
-- until the mouse is released and then add it back to the grid.
e:connect_signal("button::press", function(_, _, _, b)
@@ -221,8 +225,8 @@ function desktop:add_element(args, pos)
if not mousegrabber.isrunning() then
local width = args.icon_size * 1.75 * (4 / 3)
local height = args.icon_size * 1.75
local width = (self.args.screen.geometry.width - 20 - ((cols - 1) * 10)) / cols
local height = (self.args.screen.geometry.height - 170 - 20) / rows
local dnd_widget = element {
icon = args.icon,
@@ -291,33 +295,39 @@ function desktop:add_element(args, pos)
end
function desktop:draw_selector()
local start_pos = mouse.coords()
local start_pos = capi.mouse.coords()
if not mousegrabber.isrunning() then
local selector = wibox.widget {
widget = wibox.container.background,
bg = gcolor("#0ffff088"),
border_color = gcolor("#0ffff0"),
border_width = dpi(2),
width = 100,
height = 100,
forced_width = 0,
forced_height = 0,
x = start_pos.x,
y = start_pos.y,
visible = true,
shape = function(cr, w, h)
gshape.rounded_rect(cr, w, h, dpi(10))
end
}
local coords = capi.mouse.coords()
selector.point = { x = coords.x, y = coords.y }
selector.point = { x = start_pos.x, y = start_pos.y }
self.widget.manual:add(selector)
mousegrabber.run(function(m)
if m.buttons[1] then
selector.visible = true
end
if not m.buttons[1] then
print("stop")
mousegrabber.stop()
selector.visible = false
self.widget.manual:reset()
end
selector.forced_width = selector.forced_width + ((start_pos.x - m.x) * -1)
selector.forced_height = selector.forced_width + ((start_pos.y - m.y) * -1)
print(selector.forced_width, selector.forced_height)
return m.buttons[1]
end, "left_ptr")
end
end
@@ -341,18 +351,10 @@ end
function desktop.new(args)
args = args or {}
args.screen = args.screen or awful.screen.focused()
local icon_size = args.icon_size or dpi(96)
-- calculate the row and column count based on the screen size and icon size and aspect ratio of 16:9
local screen_width = awful.screen.focused().geometry.width
local screen_height = awful.screen.focused().geometry.height
local aspect_ratio = 4 / 3
local cols = math.floor(screen_width / (icon_size * 1.75 * aspect_ratio))
local rows = math.floor((screen_height - (dpi(75 + 95))) / (icon_size * 1.75))
local cols = math.floor(args.screen.geometry.width / (icon_size * 1.75 * (4 / 3)))
local rows = math.floor((args.screen.geometry.height - 75 + 95) / (icon_size * 1.75))
--[[
The wibox has a stacked layout with a manual layout over a grid.
@@ -371,15 +373,15 @@ function desktop.new(args)
x = 0,
y = 0,
bg = gcolor.transparent,
width = 1920,
height = 1080,
width = args.screen.geometry.width,
height = args.screen.geometry.height,
screen = args.screen,
widget = wibox.widget {
{
{
layout = grid,
homogeneous = true,
spacing = dpi(10),
spacing = 10,
expand = true,
orientation = "horizontal",
forced_num_cols = cols,
@@ -401,6 +403,8 @@ function desktop.new(args)
}
}
w.args = args
local cm_popup = cm {
widget_template = wibox.widget {
{
@@ -563,29 +567,19 @@ function desktop.new(args)
}
}
w.widget.manual:buttons(
gtable.join(
awful.button(
{},
1,
function()
cm_popup.visible = false
if capi.mouse.current_widgets[4] == w.widget.manual then
--w:draw_selector()
end
end
),
awful.button(
{},
3,
function()
if capi.mouse.current_widgets[4] == w.widget.manual then
cm_popup:toggle()
end
end
)
)
)
w.widget.manual:buttons(gtable.join(
awful.button({}, 1, function()
cm_popup.visible = false
if capi.mouse.current_widgets[4] == w.widget.manual then
w:draw_selector()
end
end),
awful.button({}, 3, function()
if capi.mouse.current_widgets[4] == w.widget.manual then
cm_popup:toggle()
end
end)
))
gtable.crush(w, desktop, true)

View File

@@ -39,10 +39,10 @@ function element:on_hover()
self.border_color = "#0ffff099"
end)
self:connect_signal("mouse::leave", function()
--[[ self:connect_signal("mouse::leave", function()
self.bg = gcolor.transparent
self.border_color = gcolor.transparent
end)
end) ]]
self:connect_signal("button::press", function()
self.bg = "#0ffff088"

View File

@@ -4,31 +4,22 @@
-- Awesome Libs
local awful = require("awful")
awful.screen.connect_for_each_screen(
-- For each screen this function is called once
-- If you want to change the modules per screen use the indices
-- e.g. 1 would be the primary screen and 2 the secondary screen.
function(s)
-- Create 9 tags
awful.layout.append_default_layouts(User_config.layouts)
awful.tag(
{ "1", "2", "3", "4", "5", "6", "7", "8", "9" },
s,
User_config.layouts[1]
)
awful.screen.connect_for_each_screen(function(s)
-- Create 9 tags
awful.layout.append_default_layouts(User_config.layouts)
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, User_config.layouts[1])
require("src.modules.desktop.desktop") { screen = s }
require("src.modules.powermenu.powermenu")(s)
require("src.modules.audio.volume_osd") { screen = s }
--require("src.modules.audio.volume_controller") { screen = s }
require("src.modules.brightness.brightness_osd")(s)
require("src.modules.titlebar.titlebar")
require("src.modules.crylia_bar.init")(s)
--require("src.modules.crylia_wibox.init")(s)
require("src.modules.notification-center.init")(s)
require("src.modules.window_switcher.init")(s)
require("src.modules.application_launcher.init") { screen = s }
--require("src.modules.calendar.init") { screen = s }
require("src.modules.network_controller.init") { screen = s }
end
)
require("src.modules.desktop.desktop") { screen = s }
require("src.modules.powermenu.powermenu")(s)
require("src.modules.audio.volume_osd") { screen = s }
--require("src.modules.audio.volume_controller") { screen = s }
require("src.modules.brightness.brightness_osd") { screen = s }
require("src.lib.nice") { titlebar_font = User_config.font.bold,
titlebar_items = { left = { "icon" }, right = { "minimize", "maximize", "close" } } }
require("src.modules.crylia_bar.init")(s)
--require("src.modules.crylia_wibox.init")(s)
require("src.modules.notification-center.init")(s)
require("src.modules.window_switcher.init")(s)
require("src.modules.application_launcher.init") { screen = s }
require("src.modules.network_controller.init") { screen = s }
end)

View File

@@ -3,22 +3,152 @@
------------------------------------
-- Awesome Libs
local awful = require("awful")
local abutton = require("awful.button")
local awidget = require("awful.widget")
local dpi = require("beautiful").xresources.apply_dpi
local gtable = require("gears").table
local gfilesystem = require("gears").filesystem
local gobject = require("gears").object
local gcolor = require("gears").color
local lgi = require("lgi")
local wibox = require("wibox")
local base = require("wibox.widget.base")
local NM = require("lgi").NM
local NM = lgi.NM
-- Third party libs
local dbus_proxy = require("src.lib.lua-dbus_proxy.src.dbus_proxy")
-- Own libs
local ap_form = require("src.modules.network_controller.ap_form")
local cm = require("src.modules.context_menu.init")
local icondir = gfilesystem.get_configuration_dir() .. "src/assets/icons/network/"
local access_point = { mt = {} }
local function flags_to_security(flags, wpa_flags, rsn_flags)
local str = ""
if flags == 1 and wpa_flags == 0 and rsn_flags == 0 then
str = str .. " WEP"
end
if wpa_flags ~= 0 then
str = str .. " WPA1"
end
if not rsn_flags ~= 0 then
str = str .. " WPA2"
end
if wpa_flags == 512 or rsn_flags == 512 then
str = str .. " 802.1X"
end
return (str:gsub("^%s", ""))
end
function access_point:get_access_point_connections(ssid)
local cn = {}
local connections = self.NetworkManagerSettings:ListConnections()
for _, connection_path in ipairs(connections) do
local NetworkManagerSettingsConnection = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = "org.freedesktop.NetworkManager",
interface = "org.freedesktop.NetworkManager.Settings.Connection",
path = connection_path
}
if NetworkManagerSettingsConnection.Filename:find(ssid) then
table.insert(cn, NetworkManagerSettingsConnection)
end
end
return cn
end
function access_point:create_profile(ap, password, auto_connect)
local s_wsec = {}
local security = flags_to_security(ap.Flags, ap.WpaFlags, ap.RsnFlags)
if security ~= "" then
if security:match("WPA") then
s_wsec["key-mgmt"] = lgi.GLib.Variant("s", "wpa-psk")
s_wsec["auth-alg"] = lgi.GLib.Variant("s", "open")
s_wsec["psk"] = lgi.GLib.Variant("s", password)
else
s_wsec["key-mgmt"] = lgi.GLib.Variant("s", "None")
s_wsec["wep-key-type"] = lgi.GLib.Variant("s", NM.WepKeyType.PASSPHRASE)
s_wsec["wep-key0"] = lgi.GLib.Variant("s", password)
end
end
return {
["connection"] = {
-- ["interface-name"] = lgi.GLib.Variant("s", ap.device_interface),
["uuid"] = lgi.GLib.Variant("s", string.gsub('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', '[xy]', function(c)
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
return string.format('%x', v)
end)),
["id"] = lgi.GLib.Variant("s", NM.utils_ssid_to_utf8(ap.Ssid)),
["type"] = lgi.GLib.Variant("s", "802-11-wireless"),
["autoconnect"] = lgi.GLib.Variant("b", auto_connect),
},
["ipv4"] = {
["method"] = lgi.GLib.Variant("s", "auto")
},
["ipv6"] = {
["method"] = lgi.GLib.Variant("s", "auto"),
},
["802-11-wireless"] = {
["mode"] = lgi.GLib.Variant("s", "infrastructure"),
},
["802-11-wireless-security"] = s_wsec
}
end
function access_point:disconnect_ap()
self.NetworkManager:DeactivateConnection(self.NetworkManagerDevice.ActiveConnection)
end
function access_point:connect(ap, password, auto_connect)
local connections = self:get_access_point_connections(NM.utils_ssid_to_utf8(ap.Ssid))
local profile = self:create_profile(self.NetworkManagerAccessPoint, password, auto_connect)
if #connections == 0 then
self.NetworkManager:AddAndActivateConnectionAsync(function(proxy, context, success, fail)
if fail ~= nil then
print("Error: " .. tostring(fail), tostring(fail.code))
self:emit_signal("NetworkManager::failed", tostring(fail), tostring(fail.code))
return
end
self:emit_signal("NetworkManager::connected", success)
end, { call_id = "my-id" }, profile, self.NetworkManagerDevice.object_path,
self.NetworkManagerAccessPoint.object_path)
--88ALYLNxo9Kk*RwRxMfN
else
connections[1]:Update(profile)
self.NetworkManager:ActivateConnectionAsync(function(proxy, context, success, failure)
if failure then
self:emit_signal("NM::AccessPointFailed", tostring(failure))
return
end
self:emit_signal("NM::AccessPointConnected", NM.utils_ssid_to_utf8(ap.Ssid))
end,
{ call_id = "my-id" }, connections[1].object_path, self.NetworkManagerDevice.object_path,
self.NetworkManagerAccessPoint.object_path)
end
end
function access_point:toggle_access_point(ap, password, auto_connect)
if self:is_ap_active(ap) then
self:disconnect_ap()
else
self:connect_ap(ap, password, auto_connect)
end
end
function access_point:is_ap_active(ap)
return ap.path == self.NetworkManagerDeviceWireless.ActiveAccessPoint
end
function access_point.new(args)
args = args or {}
@@ -32,6 +162,13 @@ function access_point.new(args)
Theme_config.network_manager.access_point.icon_color2
end ]]
local ssid_text = awidget.inputbox {
text = NM.utils_ssid_to_utf8(args.NetworkManagerAccessPoint.Ssid) or
args.NetworkManagerAccessPoint.hw_address or "Unknown",
halign = "left",
valign = "center",
}
local ret = base.make_widget_from_value(wibox.widget {
{
{
@@ -57,21 +194,11 @@ function access_point.new(args)
},
{
{
{
text = NM.utils_ssid_to_utf8(args.NetworkManagerAccessPoint.Ssid) or
args.NetworkManagerAccessPoint.hw_address or "Unknown",
id = "alias",
widget = wibox.widget.textbox
},
{
text = "Connecting...",
id = "connecting",
visible = false,
font = User_config.font.specify .. ", regular 10",
widget = wibox.widget.textbox
},
id = "alias_container",
layout = wibox.layout.fixed.horizontal
ssid_text,
widget = wibox.container.constraint,
strategy = "exact",
width = dpi(300),
id = "alias"
},
width = dpi(260),
height = dpi(40),
@@ -130,21 +257,92 @@ function access_point.new(args)
gtable.crush(ret, access_point, true)
ret.NetworkManagerAccessPoint = args.NetworkManagerAccessPoint
ret.NetworkManagerSettings = args.NetworkManagerSettings
ret.NetworkManagerDeviceWireless = args.NetworkManagerDeviceWireless
ret.NetworkManagerDevice = args.NetworkManagerDevice
ret.NetworkManager = args.NetworkManager
ret.ap_form = ap_form { screen = args.screen, ssid = NM.utils_ssid_to_utf8(ret.NetworkManagerAccessPoint.Ssid) }
ret.ap_form = ap_form {
screen = args.screen,
NetworkManagerAccessPoint = args.NetworkManagerAccessPoint,
ap = ret
}
ret:buttons(
gtable.join(
awful.button(
{},
1,
nil,
function()
ret.ap_form:popup_toggle()
ret.cm = cm {
widget_template = wibox.widget {
{
{
{
{
widget = wibox.widget.imagebox,
resize = true,
valign = "center",
halign = "center",
id = "icon_role",
},
widget = wibox.container.constraint,
stragety = "exact",
width = dpi(24),
height = dpi(24),
id = "const"
},
{
widget = wibox.widget.textbox,
valign = "center",
halign = "left",
id = "text_role"
},
layout = wibox.layout.fixed.horizontal
},
widget = wibox.container.margin
},
widget = wibox.container.background,
}, spacing = dpi(10),
entries = {
{ -- Connect/Disconnect a device
name = "ret.device.Connected" and "Disconnect" or "Connect",
icon = gcolor.recolor_image("ret.device.Connected" and icondir .. "link-off.svg" or
icondir .. "link.svg",
Theme_config.network_manager.access_point.icon_color),
callback = function()
ret:toggle_access_point()
end,
id = "connected"
},
{ -- Rename a device
name = "Rename",
icon = gcolor.recolor_image(icondir .. "edit.svg", Theme_config.network_manager.icon_color),
callback = function()
ssid_text:focus()
ssid_text:connect_signal("submit", function(text)
text = text:get_text()
ssid_text.markup = ret:rename(text)
end)
end
)
},
{ -- Remove a device
name = "Remove",
icon = gcolor.recolor_image(icondir .. "delete.svg", Theme_config.network_manager.icon_color),
callback = function()
end
}
}
}
ret:buttons(gtable.join(
abutton({}, 1, nil,
function()
--TODO:Check if there are any connection details, else open the popup
ret.ap_form:popup_toggle()
end
),
abutton({}, 3, nil,
function()
ret.cm:toggle()
end
)
)
))
ret:get_children_by_id("con")[1].image = gcolor.recolor_image(
icondir .. "link.svg", icon_color)

View File

@@ -1,16 +1,20 @@
local awful = require("awful")
local abutton = require("awful.button")
local aplacement = require("awful.placement")
local apopup = require("awful.popup")
local awidget = require("awful.widget")
local dpi = require("beautiful").xresources.apply_dpi
local gtable = require("gears.table")
local gobject = require("gears.object")
local gcolor = require("gears.color")
local gshape = require("gears.shape")
local gfilesystem = require("gears.filesystem")
local NM = require("lgi").NM
local wibox = require("wibox")
local icondir = gfilesystem.get_configuration_dir() .. "src/assets/icons/network/"
local capi = {
awesome = awesome,
mouse = mouse,
mousegrabber = mousegrabber
}
@@ -22,47 +26,11 @@ end
function ap_form.new(args)
args = args or {}
args.screen = args.screen or awful.screen.preferred()
args.screen = args.screen
local settigns_form = {
password = awful.widget.inputbox {
widget_template = wibox.template {
widget = wibox.widget {
{
{
{
widget = wibox.widget.textbox,
halign = "left",
valign = "center",
id = "text_role",
},
widget = wibox.container.margin,
margins = 5,
id = "marg"
},
widget = wibox.container.constraint,
strategy = "exact",
width = 400,
height = 50,
id = "const"
},
widget = wibox.container.background,
bg = "#212121",
fg = "#F0F0F0",
border_color = "#414141",
border_width = 2,
shape = gshape.rounded_rect,
forced_width = 300,
forced_height = 50,
},
update_callback = function(template_widget, args)
template_widget.widget.const.marg.text_role.markup = args.text
end
}
},
}
local password = awidget.inputbox { hint_text = "Password..." }
local ret = awful.popup {
local ret = apopup {
widget = {
{
{ -- Header
@@ -71,7 +39,7 @@ function ap_form.new(args)
{
{
widget = wibox.widget.textbox,
text = args.ssid,
text = NM.utils_ssid_to_utf8(args.NetworkManagerAccessPoint.Ssid),
font = User_config.font.specify .. ",extra bold 16",
halign = "center",
valign = "center",
@@ -115,7 +83,30 @@ function ap_form.new(args)
right = dpi(20),
},
-- Change to inputtextbox container
settigns_form.password,
{
{
{
password,
widget = wibox.container.margin,
margins = 5,
id = "marg"
},
widget = wibox.container.constraint,
strategy = "exact",
width = 400,
height = 50,
id = "const"
},
widget = wibox.container.background,
bg = "#212121",
fg = "#F0F0F0",
border_color = "#414141",
border_width = 2,
shape = gshape.rounded_rect,
forced_width = 300,
forced_height = 50,
id = "password_container"
},
layout = wibox.layout.align.horizontal
},
{ -- Actions
@@ -181,7 +172,7 @@ function ap_form.new(args)
widget = wibox.container.margin,
margins = dpi(10)
},
placement = awful.placement.centered,
placement = aplacement.centered,
ontop = true,
visible = false,
width = dpi(600),
@@ -195,6 +186,30 @@ function ap_form.new(args)
screen = args.screen,
}
local password_container = ret.widget:get_children_by_id("password_container")[1]
-- Focus the searchbar when its left clicked
password_container:buttons(gtable.join {
abutton({}, 1, function()
password:focus()
end)
})
--#region Hover signals to change the cursor to a text cursor
local old_cursor, old_wibox
password_container:connect_signal("mouse::enter", function()
local wid = capi.mouse.current_wibox
if wid then
old_cursor, old_wibox = wid.cursor, wid
wid.cursor = "xterm"
end
end)
password_container:connect_signal("mouse::leave", function()
old_wibox.cursor = old_cursor
old_wibox = nil
end)
--#endregion
gtable.crush(ret, ap_form, true)
local checkbox = ret.widget:get_children_by_id("checkbox")[1]
@@ -210,13 +225,10 @@ function ap_form.new(args)
local connect_button = ret.widget:get_children_by_id("connect_button")[1]
connect_button:connect_signal("button::press", function()
ret:emit_signal("ap_form::connect", {
ssid = args.ssid,
password = settigns_form.password:get_text(),
auto_connect = ret.widget:get_children_by_id("checkbox")[1].checked
})
print("Connect to " .. args.ssid:get_text(), "\nPassword: " .. settigns_form.password:get_text(),
"\nAuto connect: " .. tostring(ret.widget:get_children_by_id("checkbox")[1].checked))
password:stop()
args.ap:connect(args.NetworkManagerAccessPoint, password:get_text(),
ret.widget:get_children_by_id("checkbox")[1].checked)
ret:popup_toggle()
end)
Hover_signal(connect_button)

View File

@@ -4,12 +4,11 @@
-- Awesome Libs
local awful = require("awful")
local dbus_proxy = require("dbus_proxy")
local dbus_proxy = require("src.lib.lua-dbus_proxy.src.dbus_proxy")
local dpi = require("beautiful").xresources.apply_dpi
local gtable = require("gears").table
local gtimer = require("gears").timer
local gshape = require("gears").shape
local gobject = require("gears").object
local gcolor = require("gears").color
local gears = require("gears")
local lgi = require("lgi")
@@ -24,11 +23,6 @@ local dnd_widget = require("awful.widget.toggle_widget")
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/network/"
local capi = {
awesome = awesome,
}
local network = { mt = {} }
network.NMState = {
@@ -63,31 +57,6 @@ network.DeviceState = {
FAILED = 120
}
local function flags_to_security(flags, wpa_flags, rsn_flags)
local str = ""
if flags == 1 and wpa_flags == 0 and rsn_flags == 0 then
str = str .. " WEP"
end
if wpa_flags ~= 0 then
str = str .. " WPA1"
end
if not rsn_flags ~= 0 then
str = str .. " WPA2"
end
if wpa_flags == 512 or rsn_flags == 512 then
str = str .. " 802.1X"
end
return (str:gsub("^%s", ""))
end
local function generate_uuid()
return string.gsub('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', '[xy]', function(c)
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
return string.format('%x', v)
end)
end
function network:get_wifi_proxy()
local devices = self._private.NetworkManager:GetDevices()
for _, path in ipairs(devices) do
@@ -146,74 +115,16 @@ function network.device_state_to_string(state)
return device_state_to_string[state]
end
function network:get_access_point_connections(ssid)
local cn = {}
local connections = self._private.NetworkManagerSettings:ListConnections()
for _, connection_path in ipairs(connections) do
local NetworkManagerSettingsConnection = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = "org.freedesktop.NetworkManager",
interface = "org.freedesktop.NetworkManager.Settings.Connection",
path = connection_path
}
if NetworkManagerSettingsConnection.Filename:find(ssid) then
table.insert(cn, NetworkManagerSettingsConnection)
end
end
return cn
end
function network:create_profile(ap, password, auto_connect)
local s_wsec = {}
if ap.security ~= "" then
if ap.security:match("WPA") then
s_wsec["key-mgmt"] = lgi.GLib.Variant("s", "wpa-psk")
s_wsec["auth-alg"] = lgi.GLib.Variant("s", "open")
--s_wsec["psk"] = lgi.GLib.Variant("s", helpers.string.trim(password))
else
s_wsec["key-mgmt"] = lgi.GLib.Variant("s", "None")
s_wsec["wep-key-type"] = lgi.GLib.Variant("s", NM.WepKeyType.PASSPHRASE)
--s_wsec["wep-key0"] = lgi.GLib.Variant("s", helpers.string.trim(password))
end
end
return {
["connection"] = {
-- ["interface-name"] = lgi.GLib.Variant("s", ap.device_interface),
["uuid"] = lgi.GLib.Variant("s", generate_uuid()),
["id"] = lgi.GLib.Variant("s", ap.ssid),
["type"] = lgi.GLib.Variant("s", "802-11-wireless"),
["autoconnect"] = lgi.GLib.Variant("b", auto_connect),
},
["ipv4"] = {
["method"] = lgi.GLib.Variant("s", "auto")
},
["ipv6"] = {
["method"] = lgi.GLib.Variant("s", "auto"),
},
["802-11-wireless"] = {
["mode"] = lgi.GLib.Variant("s", "infrastructure"),
},
["802-11-wireless-security"] = s_wsec
}
end
---Scan for access points and create a widget for each one.
function network:scan_access_points()
local ap_list = self:get_children_by_id("wifi_ap_list")[1]
ap_list:reset()
self._private.NetworkManagerDeviceWireless:RequestScanAsync(function(proxy, context, success, failure)
if failure then
-- Send an error notification
print("AP Scan failed: ", failure)
return
end
-- Get every access point even those who hide their ssid
print(#self._private.NetworkManagerDeviceWireless:GetAllAccessPoints())
for _, ap in ipairs(self._private.NetworkManagerDeviceWireless:GetAllAccessPoints()) do
-- Create a new proxy for every ap
@@ -223,69 +134,27 @@ function network:scan_access_points()
interface = "org.freedesktop.NetworkManager.AccessPoint",
path = ap
}
--[[ for _, ap2 in ipairs(ap_list.children) do
if ap2.NetworkManagerAccessPoint.HwAddress:match(ap.HwAddress or "") then
goto continue
end
end ]]
print("AP Found: ", NetworkManagerAccessPoint.HwAddress, NM.utils_ssid_to_utf8(NetworkManagerAccessPoint.Ssid),
NetworkManagerAccessPoint.Strength)
-- We are only interested in those with a ssid
if NetworkManagerAccessPoint.Ssid then
ap_list:add(access_point { NetworkManagerAccessPoint = NetworkManagerAccessPoint })
ap_list:add(access_point {
NetworkManagerAccessPoint = NetworkManagerAccessPoint,
NetworkManagerDevice = self._private.NetworkManagerDevice,
NetworkManagerSettings = self._private.NetworkManagerSettings,
NetworkManager = self._private.NetworkManager,
NetworkManagerDeviceWireless = self._private.NetworkManagerDeviceWireless
})
end
end
table.sort(ap_list, function(a, b)
return a.NetworkManagerAccessPoint.Strength > b.NetworkManagerAccessPoint.Strength
end)
print("AP_Anzahl: ", #ap_list.children)
end, { call_id = "my-id" }, {})
end
function network:is_ap_active(ap)
return ap.path == self._private.wifi_proxy.ActiveAccessPoint
end
function network:disconnect_ap()
self._private.NetworkManager:DeactivateConnection(self._private.NetworkManagerDevice.ActiveConnection)
end
function network:connect_ap(ap, pw, auto_connect)
local connections = self:get_access_point_connections(ap.ssid)
local profile = self:create_profile(ap, pw, auto_connect)
if #connections == 0 then
self._private.NetworkManager:AddAndActivateConnectionAsync(function(proxy, context, success, failure)
if failure then
self:emit_signal("NM::AccessPointFailed", tostring(failure))
return
end
self:emit_signal("NM::AccessPointConnected", ap.ssid)
end, { call_id = "my-id", profile, ap.device_proxy_path, ap.path })
else
connections[1]:Update(profile)
self._private.NetworkManager:ActivateConnectionAsync(function(proxy, context, success, failure)
if failure then
self:emit_signal("NM::AccessPointFailed", tostring(failure))
return
end
self:emit_signal("NM::AccessPointConnected", ap.ssid)
end, { call_id = "my-id", connections[1].object_path, ap.device_proxy_path, ap.path })
end
end
function network:toggle_access_point(ap, password, auto_connect)
if self:is_ap_active(ap) then
self:disconnect_ap()
else
self:connect_ap(ap, password, auto_connect)
end
return ap.path == self._private.NetworkManagerDeviceWireless.ActiveAccessPoint
end
---Toggles networking on or off

View File

@@ -1,447 +0,0 @@
-----------------------------------
-- This is the titlebar module --
-----------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local capi = {
awesome = awesome,
client = client
}
-- Icon directory path
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/titlebar/"
awful.titlebar.enable_tooltip = true
awful.titlebar.fallback_name = 'Client'
-- Normal AND Focus(active/inactive) have to be set or errors will appear in stdout
Theme.titlebar_close_button_normal = icondir .. "close.svg"
Theme.titlebar_close_button_focus = icondir .. "close.svg"
Theme.titlebar_minimize_button_normal = icondir .. "minimize.svg"
Theme.titlebar_minimize_button_focus = icondir .. "minimize.svg"
Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg"
Theme.titlebar_maximized_button_active = icondir .. "maximize.svg"
Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg"
local create_buttons = function(c)
local buttons = gears.table.join(
awful.button(
{},
1,
function()
c:activate { context = 'titlebar', action = 'mouse_move' }
end
),
awful.button(
{},
3,
function()
c:activate { context = 'titlebar', action = 'mouse_resize' }
end
)
)
return buttons
end
local create_titlebar = function(c, size, position)
local close_button = awful.titlebar.widget.closebutton(c)
local minimize_button = awful.titlebar.widget.minimizebutton(c)
local maximize_button = awful.titlebar.widget.maximizedbutton(c)
local tb
if position == "left" then
local titlebar = awful.titlebar(c, {
position = "left",
bg = Theme_config.titlebar.bg,
size = size
})
tb = wibox.widget {
{
{
{
close_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.close_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "closebutton"
},
{
maximize_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.maximize_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "maximizebutton"
},
{
minimize_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.minimize_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "minimizebutton"
},
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
id = "spacing"
},
margins = dpi(5),
widget = wibox.container.margin,
id = "margin"
},
{
buttons = create_buttons(c),
layout = wibox.layout.flex.vertical
},
{
awful.titlebar.widget.iconwidget(c),
margins = dpi(5),
widget = wibox.container.margin
},
layout = wibox.layout.align.vertical,
id = "main"
}
titlebar:setup { tb, layout = wibox.layout.fixed.horizontal }
elseif position == "top" then
local titlebar = awful.titlebar(c, {
position = "top",
bg = Theme_config.titlebar.bg,
size = size
})
tb = wibox.widget {
{
awful.titlebar.widget.iconwidget(c),
margins = dpi(5),
widget = wibox.container.margin
},
{
{
awful.titlebar.widget.titlewidget(c),
valign = "center",
halign = "center",
layout = wibox.container.place,
},
buttons = create_buttons(c),
fill_space = true,
layout = wibox.layout.stack
},
{
{
{
minimize_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.minimize_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "minimizebutton"
},
{
maximize_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.maximize_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "maximizebutton"
},
{
close_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.close_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "closebutton"
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
id = "spacing"
},
margins = dpi(5),
widget = wibox.container.margin,
id = "margin"
},
layout = wibox.layout.align.horizontal,
id = "main"
}
titlebar:setup { tb, layout = wibox.layout.fixed.vertical }
end
if not tb then return end
close_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.close_button.hover_border
local cb = tb:get_children_by_id("closebutton")[1]
cb.border_color = Theme_config.titlebar.close_button.hover_border
cb.bg = Theme_config.titlebar.close_button.hover_bg
end
)
close_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local cb = tb:get_children_by_id("closebutton")[1]
cb.border_color = Theme_config.titlebar.close_button.border_color
cb.bg = Theme_config.titlebar.close_button.bg
end
)
minimize_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.minimize_button.hover_border
local mb = tb:get_children_by_id("minimizebutton")[1]
mb.border_color = Theme_config.titlebar.minimize_button.hover_border
mb.bg = Theme_config.titlebar.minimize_button.hover_bg
end
)
minimize_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local mb = tb:get_children_by_id("minimizebutton")[1]
mb.border_color = Theme_config.titlebar.minimize_button.border_color
mb.bg = Theme_config.titlebar.minimize_button.bg
end
)
maximize_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.maximize_button.hover_border
local mb = tb:get_children_by_id("maximizebutton")[1]
mb.border_color = Theme_config.titlebar.maximize_button.hover_border
mb.bg = Theme_config.titlebar.maximize_button.hover_bg
end
)
maximize_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local mb = tb:get_children_by_id("maximizebutton")[1]
mb.border_color = Theme_config.titlebar.maximize_button.border_color
mb.bg = Theme_config.titlebar.maximize_button.bg
end
)
end
local create_titlebar_dialog_modal = function(c, size, position)
local close_button = awful.titlebar.widget.closebutton(c)
local minimize_button = awful.titlebar.widget.minimizebutton(c)
local maximize_button = awful.titlebar.widget.maximizedbutton(c)
local tb
if position == "left" then
local titlebar = awful.titlebar(c, {
position = "left",
bg = Theme_config.titlebar.bg,
size = size
})
tb = wibox.widget {
{
{
close_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.close_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "closebutton"
},
margins = dpi(5),
widget = wibox.container.margin,
id = "margin"
},
{
buttons = create_buttons(c),
layout = wibox.layout.flex.vertical
},
{
awful.titlebar.widget.iconwidget(c),
margins = dpi(5),
widget = wibox.container.margin
},
layout = wibox.layout.align.vertical,
id = "main"
}
titlebar:setup { tb, layout = wibox.layout.fixed.horizontal }
elseif position == "top" then
local titlebar = awful.titlebar(c, {
position = "top",
bg = Theme_config.titlebar.bg,
size = size
})
tb = wibox.widget {
{
awful.titlebar.widget.iconwidget(c),
margins = dpi(5),
widget = wibox.container.margin
},
{
{
awful.titlebar.widget.titlewidget(c),
valign = "center",
halign = "center",
layout = wibox.container.place,
},
buttons = create_buttons(c),
fill_space = true,
layout = wibox.layout.stack
},
{
{
close_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.close_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "closebutton"
},
margins = dpi(5),
widget = wibox.container.margin,
id = "margin"
},
layout = wibox.layout.align.horizontal,
id = "main"
}
titlebar:setup { tb, layout = wibox.layout.fixed.vertical }
end
if not tb then return end
close_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.close_button.hover_border
local cb = tb:get_children_by_id("closebutton")[1]
cb.border_color = Theme_config.titlebar.close_button.hover_border
cb.bg = Theme_config.titlebar.close_button.hover_bg
end
)
close_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local cb = tb:get_children_by_id("closebutton")[1]
cb.border_color = Theme_config.titlebar.close_button.border_color
cb.bg = Theme_config.titlebar.close_button.bg
end
)
minimize_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.minimize_button.hover_border
local mb = tb:get_children_by_id("minimizebutton")[1]
mb.border_color = Theme_config.titlebar.minimize_button.hover_border
mb.bg = Theme_config.titlebar.minimize_button.hover_bg
end
)
minimize_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local mb = tb:get_children_by_id("minimizebutton")[1]
mb.border_color = Theme_config.titlebar.minimize_button.border_color
mb.bg = Theme_config.titlebar.minimize_button.bg
end
)
maximize_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.maximize_button.hover_border
local mb = tb:get_children_by_id("maximizebutton")[1]
mb.border_color = Theme_config.titlebar.maximize_button.hover_border
mb.bg = Theme_config.titlebar.maximize_button.hover_bg
end
)
maximize_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local mb = tb:get_children_by_id("maximizebutton")[1]
mb.border_color = Theme_config.titlebar.maximize_button.border_color
mb.bg = Theme_config.titlebar.maximize_button.bg
end
)
end
capi.client.connect_signal(
"request::titlebars",
function(c)
if c.type == "dialog" then
create_titlebar_dialog_modal(c, dpi(35), User_config.titlebar_position)
elseif c.type == "modal" then
create_titlebar_dialog_modal(c, dpi(35), User_config.titlebar_position)
else
create_titlebar(c, dpi(35), User_config.titlebar_position)
end
if not c.floating or c.maximized or c.fullscreen then
if User_config.titlebar_position == "left" then
awful.titlebar.hide(c, "left")
elseif User_config.titlebar_position == "top" then
awful.titlebar.hide(c, "top")
end
end
end
)
capi.client.connect_signal(
"property::floating",
function(c)
if c.floating and not (c.maximized or c.fullscreen) then
if User_config.titlebar_position == "left" then
awful.titlebar.show(c, "left")
elseif User_config.titlebar_position == "top" then
awful.titlebar.show(c, "top")
end
else
if User_config.titlebar_position == "left" then
awful.titlebar.hide(c, "left")
elseif User_config.titlebar_position == "top" then
awful.titlebar.hide(c, "top")
end
end
end
)