Some fixes
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
local ipairs = ipairs
|
||||
local math = math
|
||||
local pairs = pairs
|
||||
local setmetatable = setmetatable
|
||||
local table = table
|
||||
|
||||
-- Awesome Libs
|
||||
local Gio = require('lgi').Gio
|
||||
local abutton = require('awful.button')
|
||||
local akey = require('awful.key')
|
||||
local akeygrabber = require('awful.keygrabber')
|
||||
@@ -5,22 +13,22 @@ local aplacement = require('awful.placement')
|
||||
local apopup = require('awful.popup')
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gobject = require('gears.object')
|
||||
local gtable = require('gears.table')
|
||||
local gtimer = require('gears.timer')
|
||||
local wibox = require('wibox')
|
||||
local gobject = require('gears.object')
|
||||
local Gio = require('lgi').Gio
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gcolor = require('gears.color')
|
||||
|
||||
-- Third Party Libs
|
||||
local fzy = require('fzy')
|
||||
|
||||
local hover = require('src.tools.hover')
|
||||
local inputbox = require('src.modules.inputbox')
|
||||
-- Local Libs
|
||||
local context_menu = require('src.modules.context_menu')
|
||||
local config = require('src.tools.config')
|
||||
local icon_lookup = require('src.tools.gio_icon_lookup')
|
||||
local dock = require('src.modules.crylia_bar.dock')
|
||||
local hover = require('src.tools.hover')
|
||||
local icon_lookup = require('src.tools.gio_icon_lookup')
|
||||
local inputbox = require('src.modules.inputbox')
|
||||
|
||||
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/context_menu/'
|
||||
|
||||
@@ -31,6 +39,12 @@ local capi = {
|
||||
|
||||
local launcher = gobject {}
|
||||
|
||||
--- Fetches all applications and their information from Gio.AppInfo.get_all()
|
||||
--- and generates a wibox widget for each application, containing the application's icon, name and launch command.
|
||||
--- The generated wibox widget also includes a context menu that allows the user to launch,
|
||||
--- add to desktop, or pin the application to the dock.
|
||||
--- @param self The launcher table.
|
||||
---
|
||||
function launcher:fetch_apps()
|
||||
for _, app in ipairs(Gio.AppInfo.get_all()) do
|
||||
local app_id = app:get_id()
|
||||
@@ -190,54 +204,15 @@ function launcher:fetch_apps()
|
||||
end
|
||||
end
|
||||
|
||||
local function levenshtein_distance(str1, str2)
|
||||
local len1 = string.len(str1)
|
||||
local len2 = string.len(str2)
|
||||
local matrix = {}
|
||||
local cost = 0
|
||||
|
||||
if (len1 == 0) then
|
||||
return len2
|
||||
elseif (len2 == 0) then
|
||||
return len1
|
||||
elseif (str1 == str2) then
|
||||
return 0
|
||||
end
|
||||
|
||||
for i = 0, len1, 1 do
|
||||
matrix[i] = {}
|
||||
matrix[i][0] = i
|
||||
end
|
||||
for j = 0, len2, 1 do
|
||||
matrix[0][j] = j
|
||||
end
|
||||
|
||||
for i = 1, len1, 1 do
|
||||
for j = 1, len2, 1 do
|
||||
if str1:byte(i) == str2:byte(j) then
|
||||
cost = 0
|
||||
else
|
||||
cost = 1
|
||||
end
|
||||
|
||||
matrix[i][j] = math.min(
|
||||
matrix[i - 1][j] + 1,
|
||||
matrix[i][j - 1] + 1,
|
||||
matrix[i - 1][j - 1] + cost
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
return matrix[len1][len2]
|
||||
end
|
||||
|
||||
---Reset the grid and add all apps that match to a filter using fzy scoring
|
||||
---@param filter string Filter for the name, category and keywords
|
||||
function launcher:filter_apps(filter)
|
||||
filter = filter or ''
|
||||
self.grid:reset()
|
||||
local app_list = {}
|
||||
for _, app in pairs(self.app_table) do
|
||||
if filter == ''
|
||||
or fzy.has_match(filter, app.name)
|
||||
or fzy.has_match(filter, app.name or '')
|
||||
or fzy.has_match(filter, app.category or '')
|
||||
or fzy.has_match(filter, app.keywords or '')
|
||||
then
|
||||
@@ -245,17 +220,22 @@ function launcher:filter_apps(filter)
|
||||
end
|
||||
end
|
||||
table.sort(app_list, function(a, b)
|
||||
return a.name < b.name
|
||||
end)
|
||||
--sort by lowest levenshtein distance
|
||||
table.sort(app_list, function(a, b)
|
||||
return levenshtein_distance(filter, a.name) < levenshtein_distance(filter, b.name)
|
||||
local score_a = fzy.score(filter, a.name)
|
||||
local score_b = fzy.score(filter, b.name)
|
||||
|
||||
if score_a ~= score_b then
|
||||
return score_a > score_b
|
||||
else
|
||||
return a.name < b.name
|
||||
end
|
||||
end)
|
||||
for _, app in ipairs(app_list) do
|
||||
self.grid:add(app)
|
||||
end
|
||||
end
|
||||
|
||||
--- Toggle the visibility of the application launcher popup window.
|
||||
--- @param screen number The screen where the launcher will be displayed.
|
||||
function launcher:toggle(screen)
|
||||
if not self.popup.visible then
|
||||
self.popup.screen = screen
|
||||
@@ -268,13 +248,20 @@ function launcher:toggle(screen)
|
||||
x = 1, y = 1,
|
||||
}
|
||||
self.popup.visible = false
|
||||
collectgarbage('collect')
|
||||
end
|
||||
end
|
||||
|
||||
---Reset the border color of a widget at x,y
|
||||
---@param x number Grid column
|
||||
---@param y number Grid row
|
||||
function launcher:selection_remove(x, y)
|
||||
self.grid:get_widgets_at(y, x)[1].border_color = beautiful.colorscheme.border_color
|
||||
end
|
||||
|
||||
---Update the border color of a widget at x,y
|
||||
---@param x number Grid column
|
||||
---@param y number Grid row
|
||||
function launcher:selection_update(x, y)
|
||||
local w_old = self.grid:get_widgets_at(y, x)[1]
|
||||
local w_new = self.grid:get_widgets_at(self.cursor.y, self.cursor.x)[1]
|
||||
@@ -282,7 +269,10 @@ function launcher:selection_update(x, y)
|
||||
w_new.border_color = beautiful.colorscheme.bg_teal
|
||||
end
|
||||
|
||||
-- Offset to know when to scroll up/down
|
||||
local up_offset = 0
|
||||
|
||||
--- Move the cursor down
|
||||
function launcher:move_down()
|
||||
local row, _ = self.grid:get_dimension()
|
||||
if self.cursor.y < row then
|
||||
@@ -303,6 +293,7 @@ function launcher:move_down()
|
||||
end
|
||||
end
|
||||
|
||||
--- Move the cursor up
|
||||
function launcher:move_up()
|
||||
local row, _ = self.grid:get_dimension()
|
||||
if self.cursor.y > 1 then
|
||||
@@ -320,6 +311,7 @@ function launcher:move_up()
|
||||
end
|
||||
end
|
||||
|
||||
--- Move the cursor left
|
||||
function launcher:move_left()
|
||||
if self.cursor.x > 1 then
|
||||
self.cursor.x = self.cursor.x - 1
|
||||
@@ -327,6 +319,7 @@ function launcher:move_left()
|
||||
end
|
||||
end
|
||||
|
||||
--- Move the cursor right
|
||||
function launcher:move_right()
|
||||
local _, col = self.grid:get_dimension()
|
||||
if self.cursor.x < col then
|
||||
@@ -336,11 +329,13 @@ function launcher:move_right()
|
||||
end
|
||||
end
|
||||
|
||||
--- Wrapper to focus the searchbar
|
||||
function launcher:focus_searchbar()
|
||||
self.searchbar:focus()
|
||||
self.popup.widget:get_children_by_id('searchbar_bg')[1].border_color = beautiful.colorscheme.bg_teal
|
||||
end
|
||||
|
||||
--- Wrapper to unfocus the searchbar
|
||||
function launcher:unfocus_searchbar()
|
||||
self.searchbar:unfocus()
|
||||
self.popup.widget:get_children_by_id('searchbar_bg')[1].border_color = beautiful.colorscheme.border_color
|
||||
@@ -450,6 +445,7 @@ if not instance then
|
||||
self:toggle(capi.mouse.screen)
|
||||
self.grid:get_widgets_at(self.cursor.x, self.cursor.y)[1].execute()
|
||||
self:filter_apps('')
|
||||
self.searchbar:set_text('')
|
||||
elseif key == 'Down' then
|
||||
if not (self.keygrabber.running == akeygrabber.current_instance) then
|
||||
self:selection_update(1, 1)
|
||||
|
||||
@@ -15,7 +15,7 @@ local lgi = require('lgi')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Own libs
|
||||
local context_menu = require('src.modules.context_menu.init')
|
||||
local context_menu = require('src.modules.context_menu')
|
||||
local hover = require('src.tools.hover')
|
||||
local input = require('src.modules.inputbox')
|
||||
|
||||
|
||||
@@ -413,84 +413,6 @@ function bluetooth.new(args)
|
||||
widget = wibox.container.margin,
|
||||
}
|
||||
|
||||
assert(type(ret) == 'table', 'bluetooth_controller: ret is not a table')
|
||||
|
||||
-- Get a reference to the dnd button
|
||||
local dnd = ret:get_children_by_id('dnd')[1]:get_widget()
|
||||
|
||||
-- Toggle bluetooth on or off
|
||||
dnd:connect_signal('dnd::toggle', function()
|
||||
ret:toggle()
|
||||
end)
|
||||
|
||||
gtable.crush(ret, bluetooth, true)
|
||||
|
||||
--#region Bluetooth Proxies
|
||||
-- Create a proxy for the freedesktop ObjectManager
|
||||
ret._private.ObjectManager = dbus_proxy.Proxy:new {
|
||||
bus = dbus_proxy.Bus.SYSTEM,
|
||||
name = 'org.bluez',
|
||||
interface = 'org.freedesktop.DBus.ObjectManager',
|
||||
path = '/',
|
||||
}
|
||||
|
||||
-- Create a proxy for the bluez Adapter1 interface
|
||||
ret._private.Adapter1 = dbus_proxy.Proxy:new {
|
||||
bus = dbus_proxy.Bus.SYSTEM,
|
||||
name = 'org.bluez',
|
||||
interface = 'org.bluez.Adapter1',
|
||||
path = '/org/bluez/hci0',
|
||||
}
|
||||
|
||||
if not ret._private.Adapter1.Powered then return end
|
||||
|
||||
-- Create a proxy for the bluez Adapter1 Properties interface
|
||||
ret._private.Adapter1Properties = dbus_proxy.Proxy:new {
|
||||
bus = dbus_proxy.Bus.SYSTEM,
|
||||
name = 'org.bluez',
|
||||
interface = 'org.freedesktop.DBus.Properties',
|
||||
path = '/org/bluez/hci0',
|
||||
}
|
||||
|
||||
-- Connect to the ObjectManager's InterfacesAdded signal
|
||||
ret._private.ObjectManager:connect_signal(function(_, interface)
|
||||
ret:get_device_info(interface)
|
||||
end, 'InterfacesAdded')
|
||||
|
||||
-- Connect to the ObjectManager's InterfacesRemoved signal
|
||||
ret._private.ObjectManager:connect_signal(function(_, interface)
|
||||
ret:remove_device(interface)
|
||||
end, 'InterfacesRemoved')
|
||||
|
||||
-- Connect to the Adapter1's PropertiesChanged signal
|
||||
ret._private.Adapter1Properties:connect_signal(function(_, _, data)
|
||||
if data.Powered ~= nil then
|
||||
send_state_notification(data.Powered)
|
||||
if data.Powered then
|
||||
dnd:set_enabled()
|
||||
ret:scan()
|
||||
else
|
||||
dnd:set_disabled()
|
||||
end
|
||||
ret:emit_signal('bluetooth::status', data.Powered)
|
||||
end
|
||||
end, 'PropertiesChanged')
|
||||
|
||||
gtimer.delayed_call(function()
|
||||
for path, _ in pairs(ret._private.ObjectManager:GetManagedObjects()) do
|
||||
ret:get_device_info(path)
|
||||
end
|
||||
if ret._private.Adapter1.Powered then
|
||||
dnd:set_enabled()
|
||||
ret:scan()
|
||||
else
|
||||
dnd:set_disabled()
|
||||
end
|
||||
ret:emit_signal('bluetooth::status', ret._private.Adapter1.Powered)
|
||||
send_state_notification(ret._private.Adapter1.Powered)
|
||||
end)
|
||||
--#endregion
|
||||
|
||||
--#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]
|
||||
@@ -626,6 +548,14 @@ function bluetooth.new(args)
|
||||
end)
|
||||
--#endregion
|
||||
|
||||
-- Get a reference to the dnd button
|
||||
local dnd = ret:get_children_by_id('dnd')[1]:get_widget()
|
||||
|
||||
-- Toggle bluetooth on or off
|
||||
dnd:connect_signal('dnd::toggle', function()
|
||||
ret:toggle()
|
||||
end)
|
||||
|
||||
-- Add buttons to the scan button
|
||||
ret:get_children_by_id('scan')[1]:buttons {
|
||||
abutton({}, 1, function()
|
||||
@@ -637,6 +567,74 @@ function bluetooth.new(args)
|
||||
hover.bg_hover { widget = connected_margin.connected_bg }
|
||||
hover.bg_hover { widget = discovered_bg }
|
||||
|
||||
gtable.crush(ret, bluetooth, true)
|
||||
|
||||
--#region Bluetooth Proxies
|
||||
-- Create a proxy for the freedesktop ObjectManager
|
||||
ret._private.ObjectManager = dbus_proxy.Proxy:new {
|
||||
bus = dbus_proxy.Bus.SYSTEM,
|
||||
name = 'org.bluez',
|
||||
interface = 'org.freedesktop.DBus.ObjectManager',
|
||||
path = '/',
|
||||
}
|
||||
|
||||
-- Create a proxy for the bluez Adapter1 interface
|
||||
ret._private.Adapter1 = dbus_proxy.Proxy:new {
|
||||
bus = dbus_proxy.Bus.SYSTEM,
|
||||
name = 'org.bluez',
|
||||
interface = 'org.bluez.Adapter1',
|
||||
path = '/org/bluez/hci0',
|
||||
}
|
||||
|
||||
if not ret._private.Adapter1.Powered then return ret end
|
||||
|
||||
-- Create a proxy for the bluez Adapter1 Properties interface
|
||||
ret._private.Adapter1Properties = dbus_proxy.Proxy:new {
|
||||
bus = dbus_proxy.Bus.SYSTEM,
|
||||
name = 'org.bluez',
|
||||
interface = 'org.freedesktop.DBus.Properties',
|
||||
path = '/org/bluez/hci0',
|
||||
}
|
||||
|
||||
-- Connect to the Adapter1's PropertiesChanged signal
|
||||
ret._private.Adapter1Properties:connect_signal(function(_, _, data)
|
||||
if data.Powered ~= nil then
|
||||
send_state_notification(data.Powered)
|
||||
if data.Powered then
|
||||
dnd:set_enabled()
|
||||
ret:scan()
|
||||
else
|
||||
dnd:set_disabled()
|
||||
end
|
||||
ret:emit_signal('bluetooth::status', data.Powered)
|
||||
end
|
||||
end, 'PropertiesChanged')
|
||||
|
||||
-- Connect to the ObjectManager's InterfacesAdded signal
|
||||
ret._private.ObjectManager:connect_signal(function(_, interface)
|
||||
ret:get_device_info(interface)
|
||||
end, 'InterfacesAdded')
|
||||
|
||||
-- Connect to the ObjectManager's InterfacesRemoved signal
|
||||
ret._private.ObjectManager:connect_signal(function(_, interface)
|
||||
ret:remove_device(interface)
|
||||
end, 'InterfacesRemoved')
|
||||
|
||||
gtimer.delayed_call(function()
|
||||
for path, _ in pairs(ret._private.ObjectManager:GetManagedObjects()) do
|
||||
ret:get_device_info(path)
|
||||
end
|
||||
if ret._private.Adapter1.Powered then
|
||||
dnd:set_enabled()
|
||||
ret:scan()
|
||||
else
|
||||
dnd:set_disabled()
|
||||
end
|
||||
ret:emit_signal('bluetooth::status', ret._private.Adapter1.Powered)
|
||||
send_state_notification(ret._private.Adapter1.Powered)
|
||||
end)
|
||||
--#endregion
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
|
||||
@@ -478,12 +478,14 @@ function calendar:create_calendar_widget()
|
||||
task_popup.x = capi.mouse.coords().x
|
||||
task_popup.y = capi.mouse.coords().y
|
||||
task_popup.visible = not task_popup.visible
|
||||
collectgarbage('collect')
|
||||
end)
|
||||
)
|
||||
)
|
||||
|
||||
tw:connect_signal('mouse::leave', function()
|
||||
task_popup.visible = false
|
||||
collectgarbage('collect')
|
||||
end)
|
||||
|
||||
hover.bg_hover { widget = tw }
|
||||
@@ -754,7 +756,7 @@ function calendar.new(args)
|
||||
{
|
||||
widget = wibox.widget.imagebox,
|
||||
resize = false,
|
||||
image = gcolor.recolor_image(icondir .. 'add_ical.svg', beautiful.colorscheme.bg_red),
|
||||
image = gcolor.recolor_image(icondir .. 'add_ical.svg', beautiful.colorscheme.bg),
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
},
|
||||
@@ -883,7 +885,7 @@ function calendar.new(args)
|
||||
border_width = dpi(2),
|
||||
border_strategy = 'inner',
|
||||
fg = beautiful.colorscheme.fg,
|
||||
shape = beautiful.shape,
|
||||
shape = beautiful.shape[12],
|
||||
})
|
||||
|
||||
ret:get_tasks()
|
||||
|
||||
@@ -104,7 +104,7 @@ function context_menu:make_entries(wtemplate, entries, spacing)
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = beautiful.colorscheme.bg,
|
||||
fg = beautiful.colorscheme.bg_red,
|
||||
fg = beautiful.colorscheme.fg,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
|
||||
@@ -74,27 +74,24 @@ function dock:toggle()
|
||||
self.popup.visible = not self.popup.visible
|
||||
end
|
||||
|
||||
function dock:write_elements_to_file_async(callback)
|
||||
function dock:write_elements_to_file_async()
|
||||
--create a local copy of the elements["pinned"] table and only set the desktop_file key from its children
|
||||
local elements_copy = { pinned = {} }
|
||||
for _, element in ipairs(elements['pinned']) do
|
||||
table.insert(elements_copy['pinned'], { desktop_file = element.desktop_file })
|
||||
end
|
||||
config.write_json(gfilesystem.get_configuration_dir() .. 'src/config/dock_' .. self.screen.index .. '.json', elements_copy['pinned'], callback)
|
||||
|
||||
config.write_json(gfilesystem.get_configuration_dir() .. 'src/config/dock_' .. self.screen.index .. '.json', elements_copy['pinned'])
|
||||
end
|
||||
|
||||
---Read the content of dock.json and get the content as a table
|
||||
---@param callback function Called after the elements have been set, no values are passed
|
||||
function dock:read_elements_from_file_async(callback)
|
||||
function dock:read_elements_from_file_async()
|
||||
local data = config.read_json(gfilesystem.get_configuration_dir() .. 'src/config/dock_' .. self.screen.index .. '.json')
|
||||
-- Make sure to not set the running key to nil on accident
|
||||
for _, v in ipairs(data) do
|
||||
local w = self:get_element_widget(v.desktop_file)
|
||||
table.insert(elements['pinned'], w)
|
||||
end
|
||||
if callback then
|
||||
callback()
|
||||
end
|
||||
end
|
||||
|
||||
---Creates a pinned widget for the dock and adds it into the elements table
|
||||
@@ -135,6 +132,7 @@ function dock:get_element_widget(desktop_file)
|
||||
bg = beautiful.colorscheme.bg1,
|
||||
shape = beautiful.shape[8],
|
||||
widget = wibox.container.background,
|
||||
desktop_file = desktop_file,
|
||||
}
|
||||
|
||||
local action_entries = {}
|
||||
|
||||
@@ -11,7 +11,7 @@ local wibox = require('wibox')
|
||||
|
||||
local config = require('src.tools.config')
|
||||
local element = require('src.modules.desktop.element')
|
||||
local cm = require('src.modules.context_menu.init')
|
||||
local cm = require('src.modules.context_menu')
|
||||
|
||||
local capi = {
|
||||
mouse = mouse,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local tinsert = table.insert
|
||||
local load = load
|
||||
local ipairs = ipairs
|
||||
local load = load
|
||||
local tinsert = table.insert
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require('awful')
|
||||
@@ -20,12 +20,16 @@ if not instance then
|
||||
awful.tag({ '1', '2', '3', '4', '5', '6', '7', '8', '9' }, s, layouts[1])
|
||||
|
||||
require('src.modules.desktop.desktop') { screen = s }
|
||||
require('src.modules.crylia_bar')(s)
|
||||
--require('src.modules.crylia_wibox.init')(s)
|
||||
if beautiful.user_config.crylia_bar then
|
||||
require('src.modules.crylia_bar')(s)
|
||||
else
|
||||
require('src.modules.crylia_wibox.init')(s)
|
||||
end
|
||||
require('src.modules.notification-center') { screen = s }
|
||||
--require('src.modules.window_switcher.init') { screen = s }
|
||||
require('src.modules.application_launcher') { screen = s }
|
||||
require('src.modules.window_switcher')(s)
|
||||
require('src.modules.app_launcher')(s)
|
||||
end)
|
||||
require('src.modules.powermenu')()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ 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 cm = require('src.modules.context_menu')
|
||||
local hover = require('src.tools.hover')
|
||||
|
||||
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/network/'
|
||||
@@ -268,7 +268,7 @@ function access_point.new(args)
|
||||
ret.NetworkManagerAccessPointProperties:connect_signal(function(_, properties, data)
|
||||
if data.Strength then
|
||||
awesome.emit_signal('NM::AccessPointStrength', data.Strength)
|
||||
if ret.is_ap_active(ret.NetworkManagerAccessPoint.object_path) then
|
||||
if ret.is_ap_active(ret.NetworkManagerAccessPoint) then
|
||||
ret:get_children_by_id('icon')[1].image = gcolor.recolor_image(
|
||||
icondir .. 'wifi-strength-' .. math.floor(data.Strength / 25) + 1 .. '.svg',
|
||||
beautiful.colorscheme.bg)
|
||||
|
||||
@@ -43,7 +43,7 @@ function ap_form.new(args)
|
||||
{
|
||||
widget = wibox.widget.textbox,
|
||||
text = NM.utils_ssid_to_utf8(args.NetworkManagerAccessPoint.Ssid),
|
||||
font = beautiful.user_config.font.specify .. ',extra bold 16',
|
||||
font = beautiful.user_config.font .. ' extra bold 16',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
},
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
-------------------------------------
|
||||
-- This is the notification-center --
|
||||
-------------------------------------
|
||||
local os = os
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome Libs
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local wibox = require('wibox')
|
||||
local naughty = require('naughty')
|
||||
local gtimer = require('gears.timer')
|
||||
local abutton = require('awful.button')
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gtable = require('gears.table')
|
||||
local abutton = require('awful.button')
|
||||
local gtimer = require('gears.timer')
|
||||
local naughty = require('naughty')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Local Libs
|
||||
local hover = require('src.tools.hover')
|
||||
|
||||
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/notifications/'
|
||||
|
||||
return setmetatable({}, {
|
||||
local instance = nil
|
||||
instance = setmetatable({}, {
|
||||
__call = function()
|
||||
local ret = wibox.widget {
|
||||
layout = require('src.lib.overflow_widget.overflow').vertical,
|
||||
@@ -61,13 +62,13 @@ return setmetatable({}, {
|
||||
notification = n,
|
||||
widget = naughty.widget.title,
|
||||
markup = [[<span foreground="]] ..
|
||||
beautiful.colorscheme.bg .. [[" font="JetBrainsMono Nerd Font, Bold 16">]] .. (n.app_name or
|
||||
'Unknown App') .. [[</span> | <span font="JetBrainsMono Nerd Font, Regular 16">]] .. (n.title or 'System Notification') .. [[</span>]],
|
||||
beautiful.colorscheme.bg .. [[" font="]] .. beautiful.user_config.font .. ' bold 12' .. [[">]] .. (n.app_name or
|
||||
'Unknown App') .. [[</span> | <span font="]] .. beautiful.user_config.font .. ' regular 12' .. [[">]] .. (n.title or 'System Notification') .. [[</span>]],
|
||||
halign = 'left',
|
||||
valign = 'center',
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(430),
|
||||
width = dpi(250),
|
||||
height = dpi(35),
|
||||
strategy = 'max',
|
||||
},
|
||||
@@ -83,7 +84,7 @@ return setmetatable({}, {
|
||||
{ -- Clock
|
||||
widget = wibox.widget.textbox,
|
||||
test = 'now',
|
||||
font = 'JetBrainsMono Nerd Font, Bold 12',
|
||||
font = beautiful.user_config.font .. ' bold 12',
|
||||
fg = beautiful.colorscheme.bg,
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
@@ -159,7 +160,7 @@ return setmetatable({}, {
|
||||
{
|
||||
notification = n,
|
||||
widget = naughty.widget.message,
|
||||
font = 'JetBrainsMono Nerd Font, Regular 10',
|
||||
font = beautiful.user_config.font .. ' regular 10',
|
||||
halign = 'left',
|
||||
valign = 'center',
|
||||
},
|
||||
@@ -170,15 +171,6 @@ return setmetatable({}, {
|
||||
spacing = dpi(15),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
{ -- Spacer
|
||||
{
|
||||
widget = wibox.container.background,
|
||||
bg = beautiful.colorscheme.bg,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
strategy = 'exact',
|
||||
height = dpi(2),
|
||||
},
|
||||
spacing = dpi(15),
|
||||
id = 'main_layout',
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
@@ -244,3 +236,4 @@ return setmetatable({}, {
|
||||
return ret
|
||||
end,
|
||||
})
|
||||
return instance
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
--------------------------------
|
||||
-- This is the network widget --
|
||||
--------------------------------
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome Libs
|
||||
local abutton = require('awful.button')
|
||||
@@ -106,110 +104,106 @@ end
|
||||
|
||||
function powermenu:toggle()
|
||||
self.keygrabber:start()
|
||||
self.visible = not self.visible
|
||||
end
|
||||
|
||||
function powermenu.new()
|
||||
local w = wibox {
|
||||
widget = {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
image = icondir .. 'defaultpfp.svg',
|
||||
resize = true,
|
||||
clip_shape = beautiful.shape[30],
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(200),
|
||||
height = dpi(200),
|
||||
strategy = 'exact',
|
||||
},
|
||||
{
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
font = 'JetBrains Mono Bold 30',
|
||||
id = 'text_role',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(50),
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
},
|
||||
{
|
||||
{
|
||||
get_button('shutdown'),
|
||||
get_button('reboot'),
|
||||
get_button('logout'),
|
||||
get_button('lock'),
|
||||
get_button('suspend'),
|
||||
spacing = dpi(30),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
spacing = dpi(50),
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
screen = capi.screen.primary,
|
||||
type = 'splash',
|
||||
visible = false,
|
||||
ontop = true,
|
||||
bg = beautiful.colorscheme.bg .. '88',
|
||||
height = capi.screen.primary.geometry.height,
|
||||
width = capi.screen.primary.geometry.width,
|
||||
x = capi.screen.primary.geometry.x,
|
||||
y = capi.screen.primary.geometry.y,
|
||||
}
|
||||
|
||||
gtable.crush(w, powermenu, true)
|
||||
|
||||
w:buttons { gtable.join(
|
||||
abutton({}, 3, function()
|
||||
w:toggle()
|
||||
w.keygrabber:stop()
|
||||
end)
|
||||
), }
|
||||
|
||||
w.keygrabber = akeygrabber {
|
||||
autostart = false,
|
||||
stop_event = 'release',
|
||||
stop_key = 'Escape',
|
||||
keybindings = {
|
||||
akey {
|
||||
modifiers = {},
|
||||
key = 'Escape',
|
||||
on_press = function()
|
||||
w:toggle()
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- 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
|
||||
aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userPfp'", function(stdout)
|
||||
if stdout then
|
||||
w:get_children_by_id('icon_role')[1].image = stdout:gsub('\n', '')
|
||||
else
|
||||
w:get_children_by_id('icon_role')[1].image = icondir .. 'defaultpfp.svg'
|
||||
end
|
||||
end)
|
||||
|
||||
aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userName' '" .. beautiful.user_config.namestyle .. "'", function(stdout)
|
||||
w:get_children_by_id('text_role')[1].text = stdout:gsub('\n', '')
|
||||
end)
|
||||
|
||||
return w
|
||||
self.w.visible = not self.w.visible
|
||||
end
|
||||
|
||||
if instance == nil then
|
||||
instance = powermenu.new()
|
||||
instance = setmetatable(powermenu, {
|
||||
__call = function(self)
|
||||
self.w = wibox {
|
||||
widget = {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
image = icondir .. 'defaultpfp.svg',
|
||||
resize = true,
|
||||
clip_shape = beautiful.shape[30],
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(200),
|
||||
height = dpi(200),
|
||||
strategy = 'exact',
|
||||
},
|
||||
{
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
font = 'JetBrains Mono Bold 30',
|
||||
id = 'text_role',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(50),
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
},
|
||||
{
|
||||
{
|
||||
get_button('shutdown'),
|
||||
get_button('reboot'),
|
||||
get_button('logout'),
|
||||
get_button('lock'),
|
||||
get_button('suspend'),
|
||||
spacing = dpi(30),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
spacing = dpi(50),
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
screen = capi.screen.primary,
|
||||
type = 'splash',
|
||||
visible = false,
|
||||
ontop = true,
|
||||
bg = beautiful.colorscheme.bg .. '88',
|
||||
height = capi.screen.primary.geometry.height,
|
||||
width = capi.screen.primary.geometry.width,
|
||||
x = capi.screen.primary.geometry.x,
|
||||
y = capi.screen.primary.geometry.y,
|
||||
}
|
||||
|
||||
self.w:buttons { gtable.join(
|
||||
abutton({}, 3, function()
|
||||
self:toggle()
|
||||
self.keygrabber:stop()
|
||||
end)
|
||||
), }
|
||||
|
||||
self.keygrabber = akeygrabber {
|
||||
autostart = false,
|
||||
stop_event = 'release',
|
||||
stop_key = 'Escape',
|
||||
keybindings = {
|
||||
akey {
|
||||
modifiers = {},
|
||||
key = 'Escape',
|
||||
on_press = function()
|
||||
self:toggle()
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- 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
|
||||
aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userPfp'", function(stdout)
|
||||
if stdout then
|
||||
self.w:get_children_by_id('icon_role')[1].image = stdout:gsub('\n', '')
|
||||
else
|
||||
self.w:get_children_by_id('icon_role')[1].image = icondir .. 'defaultpfp.svg'
|
||||
end
|
||||
end)
|
||||
|
||||
aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userName' '" .. beautiful.user_config.namestyle .. "'", function(stdout)
|
||||
self.w:get_children_by_id('text_role')[1].text = stdout:gsub('\n', '')
|
||||
end)
|
||||
end,
|
||||
})
|
||||
end
|
||||
return instance
|
||||
|
||||
@@ -17,139 +17,117 @@ local base = require('wibox.widget.base')
|
||||
local gtimer = require('gears.timer')
|
||||
local cairo = require('lgi').cairo
|
||||
local awidget = require('awful.widget')
|
||||
|
||||
local capi = {
|
||||
awesome = awesome,
|
||||
client = client,
|
||||
mouse = mouse,
|
||||
}
|
||||
|
||||
--local window_elements = require("src.modules.window_switcher.window_elements")()
|
||||
|
||||
--[[ return function(s)
|
||||
|
||||
local window_switcher_list = wibox.widget {
|
||||
window_elements,
|
||||
margins = dpi(20),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
local window_switcher_container = awful.popup {
|
||||
widget = wibox.container.background,
|
||||
ontop = true,
|
||||
visible = false,
|
||||
stretch = false,
|
||||
screen = s,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(12))
|
||||
end,
|
||||
placement = awful.placement.centered,
|
||||
bg = beautiful.colorscheme.bg,
|
||||
border_color = beautiful.colorscheme.border_color,
|
||||
border_width = dpi(2)
|
||||
}
|
||||
|
||||
window_switcher_container:setup {
|
||||
window_switcher_list,
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
capi.awesome.connect_signal(
|
||||
"toggle_window_switcher",
|
||||
function()
|
||||
if capi.mouse.screen == s then
|
||||
window_switcher_container.visible = not window_switcher_container.visible
|
||||
end
|
||||
end
|
||||
)
|
||||
end ]]
|
||||
local ascreenshot = require('awful.screenshot')
|
||||
local wtemplate = require('wibox.template')
|
||||
local akeygrabber = require('awful.keygrabber')
|
||||
local akey = require('awful.key')
|
||||
local abutton = require('awful.button')
|
||||
local aclient = require('awful.client')
|
||||
local awful = require('awful')
|
||||
|
||||
local client_preview = {}
|
||||
|
||||
local instance = nil
|
||||
if not instance then
|
||||
instance = setmetatable(client_preview, {
|
||||
__call = function(self, s)
|
||||
|
||||
function client_preview:toggle()
|
||||
self.visible = not self.visible
|
||||
end
|
||||
|
||||
return setmetatable(client_preview, {
|
||||
__call = function(...)
|
||||
local args = ...
|
||||
|
||||
local w = gobject {}
|
||||
|
||||
gtable.crush(w, client_preview, true)
|
||||
|
||||
--[[ local tl = awidget.tasklist {
|
||||
screen = 1,
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
filter = awidget.tasklist.filter.alltags,
|
||||
update_function = function(widget, _, _, _, clients)
|
||||
widget:reset()
|
||||
|
||||
for _, c in ipairs(clients) do
|
||||
local tw = wibox.widget {
|
||||
self.popup = apopup {
|
||||
widget = awidget.tasklist {
|
||||
screen = 1,
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
filter = awidget.tasklist.filter.alltags,
|
||||
style = {
|
||||
font = beautiful.user_config.font .. ' regular 12',
|
||||
},
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
widget = wibox.widget.imagebox,
|
||||
resize = true,
|
||||
id = c.instance,
|
||||
{
|
||||
{ -- icon and text
|
||||
{
|
||||
{
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
id = 'icon_role',
|
||||
},
|
||||
{
|
||||
widget = wibox.widget.textbox,
|
||||
id = 'text_role',
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
height = dpi(32),
|
||||
width = dpi(256),
|
||||
},
|
||||
{ -- preview
|
||||
id = 'screenshot',
|
||||
width = dpi(256),
|
||||
widget = wibox.container.constraint,
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
height = dpi(256),
|
||||
strategy = 'exact',
|
||||
widget = wibox.container.margin,
|
||||
margins = dpi(20),
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
widget = wibox.container.background,
|
||||
border_color = beautiful.colorscheme.border_color,
|
||||
id = 'border',
|
||||
border_width = dpi(2),
|
||||
bg = beautiful.colorscheme.bg1,
|
||||
shape = beautiful.shape[8],
|
||||
},
|
||||
widget = wibox.container.margin,
|
||||
margins = dpi(20),
|
||||
},
|
||||
bg = beautiful.colorscheme.bg,
|
||||
widget = wibox.container.background,
|
||||
bg = '#414141',
|
||||
id = c.pid,
|
||||
shape = gshape.rounded_rect,
|
||||
}
|
||||
|
||||
gtimer {
|
||||
timeout = 1 / 24,
|
||||
autostart = true,
|
||||
callback = function()
|
||||
local content = gsurface(c.content)
|
||||
local cr = cairo.Context(content)
|
||||
local x, y, w, h = cr:clip_extents()
|
||||
local img = cairo.ImageSurface.create(cairo.Format.ARGB32, w - x, h - y)
|
||||
cr = cairo.Context(img)
|
||||
cr:set_source_surface(content, 0, 0)
|
||||
cr.operator = cairo.Operator.SOURCE
|
||||
cr:paint()
|
||||
local cont = tw:get_children_by_id('icon_role')[1]
|
||||
if cont then
|
||||
cont.image = gsurface.load(img)
|
||||
return
|
||||
create_callback = function(sself, c)
|
||||
local ss = ascreenshot {
|
||||
client = c,
|
||||
}
|
||||
ss:refresh()
|
||||
local ib = ss.content_widget
|
||||
ib.clip_shape = beautiful.shape[12]
|
||||
ib.valign = 'center'
|
||||
ib.halign = 'center'
|
||||
sself:get_widget():get_children_by_id('screenshot')[1].widget = ib
|
||||
end,
|
||||
update_callback = function(sself, c)
|
||||
if c.active and self.popup.visible then
|
||||
local ss = ascreenshot {
|
||||
client = c,
|
||||
}
|
||||
ss:refresh()
|
||||
local ib = ss.content_widget
|
||||
ib.clip_shape = beautiful.shape[12]
|
||||
ib.valign = 'center'
|
||||
ib.halign = 'center'
|
||||
sself:get_widget():get_children_by_id('screenshot')[1].widget = ib
|
||||
sself:get_widget():get_children_by_id('border')[1].border_color = beautiful.colorscheme.bg_purple
|
||||
else
|
||||
sself:get_widget():get_children_by_id('border')[1].border_color = beautiful.colorscheme.border_color
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
widget:add(tw)
|
||||
end
|
||||
|
||||
return widget
|
||||
end,
|
||||
} ]]
|
||||
|
||||
w.popup = apopup {
|
||||
widget = {},
|
||||
ontop = true,
|
||||
visible = true,
|
||||
screen = args.screen,
|
||||
placement = aplacement.centered,
|
||||
bg = beautiful.colorscheme.bg,
|
||||
border_color = beautiful.colorscheme.border_color,
|
||||
border_width = dpi(2),
|
||||
}
|
||||
|
||||
|
||||
return w
|
||||
end,
|
||||
})
|
||||
},
|
||||
},
|
||||
ontop = true,
|
||||
visible = false,
|
||||
screen = s,
|
||||
bg = beautiful.colorscheme.bg,
|
||||
border_color = beautiful.colorscheme.border_color,
|
||||
border_width = dpi(2),
|
||||
placement = aplacement.centered,
|
||||
}
|
||||
end,
|
||||
})
|
||||
end
|
||||
return instance
|
||||
|
||||
@@ -1,252 +0,0 @@
|
||||
---------------------------------
|
||||
-- This is the window_switcher --
|
||||
---------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require('awful')
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local gears = require('gears')
|
||||
local wibox = require('wibox')
|
||||
|
||||
local color = require('src.lib.color')
|
||||
local rubato = require('src.lib.rubato')
|
||||
|
||||
local capi = {
|
||||
awesome = awesome,
|
||||
client = client,
|
||||
}
|
||||
|
||||
return function()
|
||||
|
||||
local elements = wibox.widget {
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
spacing = dpi(20),
|
||||
id = 'switcher',
|
||||
}
|
||||
|
||||
local selected = 0
|
||||
|
||||
local function create_elements(fn)
|
||||
fn = fn or ''
|
||||
|
||||
elements:reset()
|
||||
|
||||
local clients = capi.client.get()
|
||||
local clients_sorted = {}
|
||||
|
||||
if capi.client.focus then
|
||||
clients_sorted[1] = capi.client.focus
|
||||
end
|
||||
|
||||
for _, client in ipairs(clients) do
|
||||
if client ~= clients_sorted[1] then
|
||||
table.insert(clients_sorted, client)
|
||||
end
|
||||
end
|
||||
|
||||
selected = selected
|
||||
|
||||
for _, client in ipairs(clients_sorted) do
|
||||
local window_element = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{ -- Icon
|
||||
{
|
||||
id = 'icon',
|
||||
--!ADD FALLBACK ICON!--
|
||||
image = gears.surface(client.icon),
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
width = dpi(100),
|
||||
height = dpi(100),
|
||||
id = 'icon_const',
|
||||
strategy = 'exact',
|
||||
widget = wibox.container.constraint,
|
||||
},
|
||||
{
|
||||
{
|
||||
text = client.name,
|
||||
id = 'label',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
id = 'place',
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
id = 'layout1',
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
},
|
||||
id = 'box',
|
||||
width = dpi(150),
|
||||
height = dpi(150),
|
||||
strategy = 'exact',
|
||||
widget = wibox.container.constraint,
|
||||
},
|
||||
id = 'margin',
|
||||
margins = dpi(20),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
shape = beautiful.shape[12],
|
||||
border_color = beautiful.colorscheme.border_color,
|
||||
border_width = dpi(2),
|
||||
bg = beautiful.colorscheme.bg,
|
||||
fg = beautiful.colorscheme.bg_green,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
elements:add(window_element)
|
||||
end
|
||||
|
||||
if fn == 'next' then
|
||||
if selected >= #clients_sorted then
|
||||
selected = 1
|
||||
else
|
||||
selected = selected + 1
|
||||
end
|
||||
|
||||
for i, element in ipairs(elements.children) do
|
||||
|
||||
-- Background rubato init
|
||||
local r_timed_bg = rubato.timed { duration = 0.5 }
|
||||
local g_timed_bg = rubato.timed { duration = 0.5 }
|
||||
local b_timed_bg = rubato.timed { duration = 0.5 }
|
||||
|
||||
-- starting color
|
||||
r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(beautiful.colorscheme.bg)
|
||||
|
||||
|
||||
-- Foreground rubato init
|
||||
local r_timed_fg = rubato.timed { duration = 0.5 }
|
||||
local g_timed_fg = rubato.timed { duration = 0.5 }
|
||||
local b_timed_fg = rubato.timed { duration = 0.5 }
|
||||
|
||||
-- starting color
|
||||
r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(beautiful.colorscheme.bg_green)
|
||||
|
||||
-- Border rubato init
|
||||
local r_timed_border = rubato.timed { duration = 0.5 }
|
||||
local g_timed_border = rubato.timed { duration = 0.5 }
|
||||
local b_timed_border = rubato.timed { duration = 0.5 }
|
||||
|
||||
-- starting color
|
||||
r_timed_border.pos, g_timed_border.pos, b_timed_border.pos = color.utils.hex_to_rgba(beautiful.colorscheme
|
||||
.border_color)
|
||||
|
||||
local function set_bg(newbg)
|
||||
r_timed_bg.target, g_timed_bg.target, b_timed_bg.target = color.utils.hex_to_rgba(newbg)
|
||||
end
|
||||
|
||||
local function set_fg(newfg)
|
||||
r_timed_fg.target, g_timed_fg.target, b_timed_fg.target = color.utils.hex_to_rgba(newfg)
|
||||
end
|
||||
|
||||
local function set_border(newborder)
|
||||
r_timed_border.target, g_timed_border.target, b_timed_border.target = color.utils.hex_to_rgba(newborder)
|
||||
end
|
||||
|
||||
local function update_bg()
|
||||
element:set_bg('#' .. color.utils.rgba_to_hex { r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos })
|
||||
end
|
||||
|
||||
local function update_fg()
|
||||
element:set_fg('#' .. color.utils.rgba_to_hex { r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos })
|
||||
end
|
||||
|
||||
local function update_border()
|
||||
element.border_color = '#' ..
|
||||
color.utils.rgba_to_hex { r_timed_border.pos, g_timed_border.pos, b_timed_border.pos }
|
||||
end
|
||||
|
||||
-- Subscribe to the function bg and fg
|
||||
r_timed_bg:subscribe(update_bg)
|
||||
g_timed_bg:subscribe(update_bg)
|
||||
b_timed_bg:subscribe(update_bg)
|
||||
r_timed_fg:subscribe(update_fg)
|
||||
g_timed_fg:subscribe(update_fg)
|
||||
b_timed_fg:subscribe(update_fg)
|
||||
r_timed_border:subscribe(update_border)
|
||||
g_timed_border:subscribe(update_border)
|
||||
b_timed_border:subscribe(update_border)
|
||||
|
||||
if i == selected then
|
||||
r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(beautiful.colorscheme.bg)
|
||||
r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(beautiful.colorscheme.bg_green)
|
||||
r_timed_border.pos, g_timed_border.pos, b_timed_border.pos = color.utils.hex_to_rgba(beautiful.colorscheme.border_color)
|
||||
set_border(beautiful.colorscheme.bg_purple)
|
||||
set_fg(beautiful.colorscheme.fg)
|
||||
set_bg(beautiful.colorscheme.bg1)
|
||||
elseif i == selected - 1 or (selected == 1 and i == #clients_sorted) then
|
||||
r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(beautiful.colorscheme.bg1)
|
||||
r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(beautiful.colorscheme.fg)
|
||||
r_timed_border.pos, g_timed_border.pos, b_timed_border.pos = color.utils.hex_to_rgba(beautiful.colorscheme.bg_purple)
|
||||
set_border(beautiful.colorscheme.border_color)
|
||||
set_fg(beautiful.colorscheme.bg_green)
|
||||
set_bg(beautiful.colorscheme.bg)
|
||||
else
|
||||
r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(beautiful.colorscheme.bg)
|
||||
r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(beautiful.colorscheme.bg_green)
|
||||
r_timed_border.pos, g_timed_border.pos, b_timed_border.pos = color.utils.hex_to_rgba(beautiful.colorscheme.border_color)
|
||||
set_border(beautiful.colorscheme.border_color)
|
||||
set_fg(beautiful.colorscheme.bg_green)
|
||||
set_bg(beautiful.colorscheme.bg)
|
||||
end
|
||||
end
|
||||
elseif fn == 'raise' then
|
||||
local c = clients_sorted[selected]
|
||||
if not c:isvisible() and c.first_tag then
|
||||
c.first_tag:view_only()
|
||||
end
|
||||
c:emit_signal('request::activate')
|
||||
c:raise()
|
||||
|
||||
--reset selected
|
||||
selected = 0
|
||||
end
|
||||
return elements
|
||||
end
|
||||
|
||||
elements = create_elements()
|
||||
|
||||
capi.awesome.connect_signal(
|
||||
'window_switcher::select_next',
|
||||
function()
|
||||
elements = create_elements('next')
|
||||
end
|
||||
)
|
||||
|
||||
capi.awesome.connect_signal(
|
||||
'window_switcher::raise',
|
||||
function()
|
||||
elements = create_elements('raise')
|
||||
end
|
||||
)
|
||||
|
||||
capi.client.connect_signal(
|
||||
'manage',
|
||||
function()
|
||||
elements = create_elements()
|
||||
end
|
||||
)
|
||||
|
||||
capi.client.connect_signal(
|
||||
'unmanage',
|
||||
function()
|
||||
elements = create_elements()
|
||||
end
|
||||
)
|
||||
|
||||
capi.awesome.connect_signal(
|
||||
'window_switcher::update',
|
||||
function()
|
||||
elements = create_elements()
|
||||
end
|
||||
)
|
||||
|
||||
return elements
|
||||
end
|
||||
Reference in New Issue
Block a user