VimUnDofJBt@:P6<)"}bci_ibJ-- Lua script to launch applications using dmenu with custom configuration-- Custom dmenu configurationlocal dmenu_cmd = { "dmenu_run", "-fn", "Fira Code-10", -- font "-nb", "#1e1e1e", -- normbgcolor "-nf", "#cccccc", -- normfgcolor "-sb", "#2472c8", -- selbgcolor "-sf", "#e5e5e5", -- selfgcolor "-l",- "10", -- number of lines in the dmenu}--- Function to get the list of .desktop files"local function get_desktop_files() local desktop_files = {}^ local dirs = { os.getenv("HOME") .. "/.local/share/applications", "/usr/share/applications" } for _, dir in ipairs(dirs) do@ local pfile = io.popen("find " .. dir .. ' -name "*.desktop"') for file in pfile:lines() do$ table.insert(desktop_files, file) end pfile:close() end return desktop_filesendP-- Function to extract the application name and exec command from a desktop file.local function extract_info_from_desktop(file)( local app_name, exec_command = nil, nil for line in io.lines(file) do if line:match("^Name=") then app_name = line:sub(6)" elseif line:match("^Exec=") then exec_command = line:sub(6) end# if app_name and exec_command then break end end return app_name, exec_commandendD-- Function to escape special characters (spaces, parentheses, etc.)1local function escape_special_characters(command)6 -- Escape spaces and parentheses for proper execution* return command:gsub("([%s%(%)])", "\\%1")end.-- Function to run the application using dmenu#local function launch_application()* local desktop_files = get_desktop_files() local app_list = {} local app_commands = {}! -- Gather app names and commands( for _, file in ipairs(desktop_files) do@ local app_name, exec_command = extract_info_from_desktop(file)# if app_name and exec_command then# table.insert(app_list, app_name)( app_commands[app_name] = exec_command end end if #app_list == 0 then! print("No applications found.") return end5 -- Join the app names into a single string for dmenu* local apps = table.concat(app_list, "\n")& -- Use dmenu to select an applicationQ local handle = io.popen(table.concat(dmenu_cmd, " ") .. " <<< '" .. apps .. "'")7 local selected_app = handle:read("*a"):gsub("\n$", "") handle:close(): if selected_app ~= "" and app_commands[selected_app] thenC -- Escape any special characters in the command before running itN local command_to_run = escape_special_characters(app_commands[selected_app])" -- Run the corresponding command os.execute(command_to_run) endend-- Main executionlaunch_application()5b 5_i5[ 5_\ibbJ-- Lua script to launch applications using dmenu with custom configuration-- Custom dmenu configurationlocal dmenu_cmd = { "dmenu_run", "-fn", "Fira Code-10", -- font "-nb", "#1e1e1e", -- normbgcolor "-nf", "#cccccc", -- normfgcolor "-sb", "#2472c8", -- selbgcolor "-sf", "#e5e5e5", -- selfgcolor "-l",& "10", -- number of lines in the dmenu}--- Function to get the list of .desktop files"local function get_desktop_files() local desktop_files = {}^ local dirs = { os.getenv("HOME") .. "/.local/share/applications", "/usr/share/applications" } for _, dir in ipairs(dirs) do@ local pfile = io.popen("find " .. dir .. ' -name "*.desktop"') for file in pfile:lines() do$ table.insert(desktop_files, file) end pfile:close() end return desktop_filesendP-- Function to extract the application name and exec command from a desktop file.local function extract_info_from_desktop(file)( local app_name, exec_command = nil, nil for line in io.lines(file) do if line:match("^Name=") then app_name = line:sub(6)" elseif line:match("^Exec=") then exec_command = line:sub(6) end# if app_name and exec_command then break end end return app_name, exec_commandendD-- Function to escape special characters (spaces, parentheses, etc.)1local function escape_special_characters(command)6 -- Escape spaces and parentheses for proper execution* return command:gsub("([%s%(%)])", "\\%1")end.-- Function to run the application using dmenu#local function launch_application()* local desktop_files = get_desktop_files() local app_list = {} local app_commands = {}! -- Gather app names and commands( for _, file in ipairs(desktop_files) do@ local app_name, exec_command = extract_info_from_desktop(file)# if app_name and exec_command then# table.insert(app_list, app_name)( app_commands[app_name] = exec_command end end if #app_list == 0 then! print("No applications found.") return end5 -- Join the app names into a single string for dmenu* local apps = table.concat(app_list, "\n")& -- Use dmenu to select an applicationQ local handle = io.popen(table.concat(dmenu_cmd, " ") .. " <<< '" .. apps .. "'")7 local selected_app = handle:read("*a"):gsub("\n$", "") handle:close(): if selected_app ~= "" and app_commands[selected_app] thenC -- Escape any special characters in the command before running itN local command_to_run = escape_special_characters(app_commands[selected_app])" -- Run the corresponding command os.execute(command_to_run) endend-- Main executionlaunch_application()_\T "dmenu_run",# "-fn", "Fira Code-10", -- font% "-nb", "#1e1e1e", -- normbgcolor% "-nf", "#cccccc", -- normfgcolor$ "-sb", "#2472c8", -- selbgcolor$ "-sf", "#e5e5e5", -- selfgcolor/ "-l", "10" -- number of lines in the dmenu}--- Function to get the list of .desktop files"local function get_desktop_files() local desktop_files = {}_ local dirs = {os.getenv("HOME") .. "/.local/share/applications", "/usr/share/applications"} ! for _, dir in ipairs(dirs) doF local pfile = io.popen('find ' .. dir .. ' -name "*.desktop"')$ for file in pfile:lines() do- table.insert(desktop_files, file) end pfile:close() end return desktop_filesendP-- Function to extract the application name and exec command from a desktop file.local function extract_info_from_desktop(file)+ local app_name, exec_command = nil, nil! for line in io.lines(file) do$ if line:match("^Name=") then" app_name = line:sub(6)( elseif line:match("^Exec=") then& exec_command = line:sub(6) end) if app_name and exec_command then break end end! return app_name, exec_commandendD-- Function to escape special characters (spaces, parentheses, etc.)1local function escape_special_characters(command)9 -- Escape spaces and parentheses for proper execution- return command:gsub("([%s%(%)])", "\\%1")end.-- Function to run the application using dmenu#local function launch_application()- local desktop_files = get_desktop_files() local app_list = {} local app_commands = {}$ -- Gather app names and commands+ for _, file in ipairs(desktop_files) doF local app_name, exec_command = extract_info_from_desktop(file)) if app_name and exec_command then, table.insert(app_list, app_name)1 app_commands[app_name] = exec_command end end if #app_list == 0 then' print("No applications found.") return end8 -- Join the app names into a single string for dmenu- local apps = table.concat(app_list, "\n")) -- Use dmenu to select an applicationT local handle = io.popen(table.concat(dmenu_cmd, " ") .. " <<< '" .. apps .. "'"): local selected_app = handle:read("*a"):gsub("\n$", "") handle:close()= if selected_app ~= "" and app_commands[selected_app] thenI -- Escape any special characters in the command before running itT local command_to_run = escape_special_characters(app_commands[selected_app])( -- Run the corresponding command" os.execute(command_to_run) end5SY~P G ab  b 5