From 2bf4ff9f13f879aa3cb513feb834cc829d1523ca Mon Sep 17 00:00:00 2001 From: Rene Kievits Date: Fri, 28 Apr 2023 01:23:13 +0200 Subject: [PATCH] fix applauncher for duoscreen --- .vscode/settings.json | 18 +++++ awesome/src/core/setup.lua | 9 ++- awesome/src/modules/app_launcher/init.lua | 5 +- awesome/src/modules/init.lua | 2 +- awesome/src/tools/config.lua | 90 ----------------------- 5 files changed, 25 insertions(+), 99 deletions(-) create mode 100644 .vscode/settings.json delete mode 100644 awesome/src/tools/config.lua diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a7a335e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,18 @@ +{ + "Lua.diagnostics.disable": [ + "undefined-field", + "undefined-doc-name", + "deprecated" + ], + "Lua.diagnostics.globals": [ + "awesome", + "mouse", + "mousegrabber", + "client", + "screen", + "selection", + "tag", + "root", + "vim" + ] +} diff --git a/awesome/src/core/setup.lua b/awesome/src/core/setup.lua index 40839d9..8dba323 100644 --- a/awesome/src/core/setup.lua +++ b/awesome/src/core/setup.lua @@ -1,8 +1,8 @@ -local setmetatable = setmetatable -local pairs = pairs local ipairs = ipairs -local table = table local math = math +local pairs = pairs +local setmetatable = setmetatable +local table = table --Awesome Libs local abutton = require('awful.button') @@ -11,9 +11,10 @@ local apopup = require('awful.popup') local aspawn = require('awful.spawn') local atooltip = require('awful.tooltip') local beautiful = require('beautiful') -local dpi = require('beautiful').xresources.apply_dpi +local dpi = beautiful.xresources.apply_dpi local gcolor = require('gears.color') local gfilesystem = require('gears.filesystem') +local gshape = require('gears.shape') local gtable = require('gears.table') local wibox = require('wibox') diff --git a/awesome/src/modules/app_launcher/init.lua b/awesome/src/modules/app_launcher/init.lua index 6d2823a..8935de7 100644 --- a/awesome/src/modules/app_launcher/init.lua +++ b/awesome/src/modules/app_launcher/init.lua @@ -43,8 +43,6 @@ local launcher = gobject {} --- 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() @@ -344,7 +342,7 @@ end local instance = nil if not instance then instance = setmetatable(launcher, { - __call = function(self, screen) + __call = function(self) self.app_table = {} self.cursor = { x = 1, @@ -531,7 +529,6 @@ if not instance then ontop = true, visible = true, stretch = false, - screen = screen, placement = aplacement.centered, bg = beautiful.colorscheme.bg, border_color = beautiful.colorscheme.border_color, diff --git a/awesome/src/modules/init.lua b/awesome/src/modules/init.lua index 31c6ede..7207116 100644 --- a/awesome/src/modules/init.lua +++ b/awesome/src/modules/init.lua @@ -27,8 +27,8 @@ if not instance then end require('src.modules.notification-center') { screen = s } require('src.modules.window_switcher')(s) - require('src.modules.app_launcher')(s) end) + require('src.modules.app_launcher')() require('src.modules.powermenu')() end, }) diff --git a/awesome/src/tools/config.lua b/awesome/src/tools/config.lua deleted file mode 100644 index 7458d8e..0000000 --- a/awesome/src/tools/config.lua +++ /dev/null @@ -1,90 +0,0 @@ -local assert = assert -local error = error -local io = io -local pairs = pairs - --- Awesome libs -local aspawn = require('awful.spawn') -local gfilesystem = require('gears.filesystem') -local gobject = require('gears.object') -local gtable = require('gears.table') - --- Third party libs -local json = require('src.lib.json-lua.json-lua') - -local config = {} - ----Takes a file path and puts the content into the callback ----@param path string file path, caller has to make sure it exists ----@return string|nil file_content -config.read = function(path) - local handler = io.open(path, 'r') - if not handler then error('Invalid path') return end - - local content = handler:read('*all') - handler:close() - return content -end - ----Writes a string to a file ----@param path string file path, caller has to make sure it exists ----@param content string content to write -config.write = function(path, content) - local handler = io.open(path, 'w') - if not handler then error('Invalid path') return end - - handler:write(content) - handler:close() -end - -config.read_json = function(path) - local handler = io.open(path, 'r') - if not handler then error('Invalid path') return end - - local content = handler:read('*all') - handler:close() - - local json_content = json:decode(content) or {} - assert(type(json_content) == 'table', 'json is not a table') - return json_content -end - -config.write_json = function(path, content) - local json_content = json:encode(content) - assert(type(json_content) == 'string', 'json is not a string') - - local handler = io.open(path, 'w') - if not handler then error('Invalid path') return end - - handler:write(json_content) - handler:close() -end - -local instance = nil -if not instance then - instance = setmetatable(config, { - __call = function() - local ret = gobject {} - - gtable.crush(ret, config, true) - - -- Create config files if they don't exist - for _, file in pairs { 'floating.json', 'dock.json', 'desktop.json', 'applications.json' } do - if not gfilesystem.file_readable(gfilesystem.get_configuration_dir() .. 'src/config/' .. file) then - aspawn('touch ' .. gfilesystem.get_configuration_dir() .. 'src/config/' .. file) - end - end - - -- Create config directories if they don't exist - for _, dir in pairs { 'files/desktop/icons' } do - if not gfilesystem.dir_readable(gfilesystem.get_configuration_dir() .. 'src/config/' .. dir) then - gfilesystem.make_directories(gfilesystem.get_configuration_dir() .. 'src/config/' .. dir) - end - end - - return ret - end, - }) -end - -return instance