bling/widget/app_launcher/init.lua

477 lines
18 KiB
Lua
Raw Normal View History

App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
local Gio = require("lgi").Gio
local awful = require("awful")
local gobject = require("gears.object")
local gtable = require("gears.table")
local gtimer = require("gears.timer")
local wibox = require("wibox")
local beautiful = require("beautiful")
local text_input_widget = require(... .. ".text_input")
local rofi_grid_widget = require(... .. ".rofi_grid")
2023-03-13 02:45:12 +01:00
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
local dpi = beautiful.xresources.apply_dpi
local string = string
local table = table
local math = math
More app launcher improvements (#132) * Make sure there is always a default icon * Use get_example_icon_path to get the default icon * Refactor scrolling to add support for left and right scrolling * fixup! Make sure there is always a default icon * Fix calculation happening at the wrong time * Fix default icons again * Where did that come from? * Fix calculation happening at the wrong time for scroll_up as well * Fix error on scroll right when scrolling to page where amount of rows is smaller than the selected row * Sort search results by string similarity * Don't sort by similarity when the search string is empty * Add hover effects * try_to_keep_index_after_searching should be false by default * This should only trigger for lmb * Add an option to hide the app launcher when clicked with lmb/rmb outside of it * Use gtk-launch so terminal apps spawn correctly * Use get_executable instead of get_commandline * Add an option to set the hover colors * Further improvements for the spawn function * Fix scrolling/searching errors when there app list is empty * This should never be nil anyway * whitespace * Refactor show, hide and toggle method + remove support for manually setting x an y (use placement) * Add arguements for custom icon_theme (defaults to the selected system gtk theme) and icon_size (defaults to 48) * Pass the app table instead of individual keys to create_app_widget * Add an arguement to pass the default terminal for terminal apps as gtk-launch only uses xterm * Reformating * Rename 'mark_app' and 'unmark_app' to 'select_app' and 'unselect_app' * Call :hide() from app.spawn() to avoid calling hide() twice on some cases * Fix escape not closing the launcher after b7e44ec4 * Reduce code duplication and only reset the launcher when the animation is over (if not nil) * Set active_widget to nil when the grid is empty to prevent from spawning the wrong app * Override the default exe_callback * Override the default behaviour for 'Return' via hooks instead because overriding only exe_callback still doesn't stop it from pausing the prompt keygrabber * Set active_widget to nil on unselect * Unselect previous app on search to avoid from spawning it when the grid is empty * Use double quotes for everything
2021-11-05 04:38:54 +01:00
local ipairs = ipairs
local capi = { screen = screen, mouse = mouse }
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
local app_launcher = { mt = {} }
2023-03-07 12:20:28 +01:00
local AWESOME_SENSIBLE_TERMINAL_SCRIPT_PATH = debug.getinfo(1).source:match("@?(.*/)") .. "awesome-sensible-terminal"
local RUN_AS_ROOT_SCRIPT_PATH = debug.getinfo(1).source:match("@?(.*/)") .. "run-as-root.sh"
More app launcher improvements (#132) * Make sure there is always a default icon * Use get_example_icon_path to get the default icon * Refactor scrolling to add support for left and right scrolling * fixup! Make sure there is always a default icon * Fix calculation happening at the wrong time * Fix default icons again * Where did that come from? * Fix calculation happening at the wrong time for scroll_up as well * Fix error on scroll right when scrolling to page where amount of rows is smaller than the selected row * Sort search results by string similarity * Don't sort by similarity when the search string is empty * Add hover effects * try_to_keep_index_after_searching should be false by default * This should only trigger for lmb * Add an option to hide the app launcher when clicked with lmb/rmb outside of it * Use gtk-launch so terminal apps spawn correctly * Use get_executable instead of get_commandline * Add an option to set the hover colors * Further improvements for the spawn function * Fix scrolling/searching errors when there app list is empty * This should never be nil anyway * whitespace * Refactor show, hide and toggle method + remove support for manually setting x an y (use placement) * Add arguements for custom icon_theme (defaults to the selected system gtk theme) and icon_size (defaults to 48) * Pass the app table instead of individual keys to create_app_widget * Add an arguement to pass the default terminal for terminal apps as gtk-launch only uses xterm * Reformating * Rename 'mark_app' and 'unmark_app' to 'select_app' and 'unselect_app' * Call :hide() from app.spawn() to avoid calling hide() twice on some cases * Fix escape not closing the launcher after b7e44ec4 * Reduce code duplication and only reset the launcher when the animation is over (if not nil) * Set active_widget to nil when the grid is empty to prevent from spawning the wrong app * Override the default exe_callback * Override the default behaviour for 'Return' via hooks instead because overriding only exe_callback still doesn't stop it from pausing the prompt keygrabber * Set active_widget to nil on unselect * Unselect previous app on search to avoid from spawning it when the grid is empty * Use double quotes for everything
2021-11-05 04:38:54 +01:00
local function default_value(value, default)
if value == nil then
return default
else
return value
end
end
local function has_value(tab, val)
for _, value in ipairs(tab) do
if val:lower():find(value:lower(), 1, true) then
return true
end
end
return false
end
local function build_widget(self)
local widget_template = self.widget_template
if widget_template == nil then
widget_template = wibox.widget
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
{
layout = rofi_grid_widget,
widget_template = wibox.widget {
widget = wibox.container.margin,
margins = dpi(15),
{
layout = wibox.layout.fixed.vertical,
spacing = dpi(15),
{
widget = text_input_widget,
id = "text_input_role",
forced_width = dpi(650),
forced_height = dpi(60),
text_color = self.text_input_text_color,
2023-03-12 23:58:38 +01:00
selection_bg = self.text_input_selection_bg,
reset_on_stop = self.reset_on_hide,
placeholder = self.text_input_placeholder,
widget_template = wibox.widget {
widget = wibox.container.background,
bg = self.text_input_bg_color,
{
widget = wibox.container.margin,
margins = dpi(15),
{
layout = wibox.layout.stack,
{
widget = wibox.widget.textbox,
id = "placeholder_role",
text = "Search: "
},
{
widget = wibox.widget.textbox,
id = "text_role"
},
}
}
}
},
2023-02-20 02:39:42 +01:00
{
layout = wibox.layout.fixed.horizontal,
spacing = dpi(10),
{
layout = wibox.layout.grid,
id = "grid_role",
orientation = "horizontal",
homogeneous = true,
2023-03-12 11:32:14 +01:00
spacing = dpi(15),
forced_num_cols = self.apps_per_column,
forced_num_rows = self.apps_per_row,
},
2023-02-20 02:39:42 +01:00
{
layout = wibox.container.rotate,
direction = 'west',
{
widget = wibox.widget.slider,
id = "scrollbar_role",
forced_width = dpi(5),
forced_height = dpi(10),
minimum = 1,
value = 1,
bar_height= 3,
bar_color = "#00000000",
bar_active_color = "#00000000",
handle_width = dpi(50),
handle_color = beautiful.bg_normal,
handle_color = beautiful.fg_normal
}
}
}
}
},
entry_template = function(app)
local widget = wibox.widget
{
widget = wibox.container.background,
forced_width = dpi(300),
forced_height = dpi(120),
bg = self.app_normal_color,
{
widget = wibox.container.margin,
margins = dpi(10),
{
layout = wibox.layout.fixed.vertical,
spacing = dpi(10),
{
widget = wibox.container.place,
halign = "center",
valign = "center",
{
widget = wibox.widget.imagebox,
id = "icon_role",
forced_width = dpi(70),
forced_height = dpi(70),
image = app.icon
},
},
{
widget = wibox.container.place,
halign = "center",
valign = "center",
{
widget = wibox.widget.textbox,
id = "name_role",
markup = string.format("<span foreground='%s'>%s</span>", self.app_name_normal_color, app.name)
}
}
2023-02-20 02:39:42 +01:00
}
}
}
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
widget:connect_signal("mouse::enter", function()
local widget = capi.mouse.current_wibox
if widget then
widget.cursor = "hand2"
end
end)
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
widget:connect_signal("mouse::leave", function()
local widget = capi.mouse.current_wibox
if widget then
widget.cursor = "left_ptr"
end
end)
More app launcher improvements (#132) * Make sure there is always a default icon * Use get_example_icon_path to get the default icon * Refactor scrolling to add support for left and right scrolling * fixup! Make sure there is always a default icon * Fix calculation happening at the wrong time * Fix default icons again * Where did that come from? * Fix calculation happening at the wrong time for scroll_up as well * Fix error on scroll right when scrolling to page where amount of rows is smaller than the selected row * Sort search results by string similarity * Don't sort by similarity when the search string is empty * Add hover effects * try_to_keep_index_after_searching should be false by default * This should only trigger for lmb * Add an option to hide the app launcher when clicked with lmb/rmb outside of it * Use gtk-launch so terminal apps spawn correctly * Use get_executable instead of get_commandline * Add an option to set the hover colors * Further improvements for the spawn function * Fix scrolling/searching errors when there app list is empty * This should never be nil anyway * whitespace * Refactor show, hide and toggle method + remove support for manually setting x an y (use placement) * Add arguements for custom icon_theme (defaults to the selected system gtk theme) and icon_size (defaults to 48) * Pass the app table instead of individual keys to create_app_widget * Add an arguement to pass the default terminal for terminal apps as gtk-launch only uses xterm * Reformating * Rename 'mark_app' and 'unmark_app' to 'select_app' and 'unselect_app' * Call :hide() from app.spawn() to avoid calling hide() twice on some cases * Fix escape not closing the launcher after b7e44ec4 * Reduce code duplication and only reset the launcher when the animation is over (if not nil) * Set active_widget to nil when the grid is empty to prevent from spawning the wrong app * Override the default exe_callback * Override the default behaviour for 'Return' via hooks instead because overriding only exe_callback still doesn't stop it from pausing the prompt keygrabber * Set active_widget to nil on unselect * Unselect previous app on search to avoid from spawning it when the grid is empty * Use double quotes for everything
2021-11-05 04:38:54 +01:00
widget:connect_signal("button::press", function(_, __, __, button)
if button == 1 then
widget:select_or_exec()
end
end)
widget:connect_signal("select", function()
widget.bg = self.app_selected_color
local name_widget = widget:get_children_by_id("name_role")[1]
name_widget.markup = string.format("<span foreground='%s'>%s</span>", self.app_name_selected_color, name_widget.text)
end)
widget:connect_signal("unselect", function()
widget.bg = self.app_normal_color
local name_widget = widget:get_children_by_id("name_role")[1]
name_widget.markup = string.format("<span foreground='%s'>%s</span>", self.app_name_normal_color, name_widget.text)
end)
return widget
end
}
end
self._private.widget = awful.popup
{
screen = self.screen,
type = self.type,
visible = false,
ontop = true,
placement = self.placement,
border_width = self.border_width,
border_color = self.border_color,
shape = self.shape,
bg = self.bg,
widget = widget_template
}
widget_template:set_search_fn(function(text, app)
2023-03-13 02:42:09 +01:00
local matched_groups = Gio.DesktopAppInfo.search(text:lower())
for _, matched_group in ipairs(matched_groups) do
for _, app_id in ipairs(matched_group) do
if app.id == app_id then
return true
end
end
2023-02-25 02:17:40 +01:00
end
end)
local app_launcher = self
widget_template:connect_signal("entry_widget::add", function(_, widget, app)
function widget:exec()
if app.terminal == true then
local pid = awful.spawn.with_shell(AWESOME_SENSIBLE_TERMINAL_SCRIPT_PATH .. " -e " .. app.exec)
local class = app.startup_wm_class or app.name
awful.spawn.with_shell(string.format(
[[xdotool search --sync --all --pid %s --name '.*' set_window --classname "%s" set_window --class "%s"]],
pid,
class,
class
))
else
app:launch()
end
if app_launcher.hide_on_launch then
app_launcher:hide()
end
end
function widget:exec_as_root()
if app.terminal == true then
local pid = awful.spawn.with_shell(
AWESOME_SENSIBLE_TERMINAL_SCRIPT_PATH .. " -e " ..
RUN_AS_ROOT_SCRIPT_PATH .. " " ..
app.exec
)
local class = app.startup_wm_class or app.name
awful.spawn.with_shell(string.format(
[[xdotool search --sync --all --pid %s --name '.*' set_window --classname "%s" set_window --class "%s"]],
pid,
class,
class
))
else
awful.spawn(RUN_AS_ROOT_SCRIPT_PATH .. " " .. app.exec)
end
if app_launcher.hide_on_launch then
app_launcher:hide()
end
end
end)
2023-02-25 02:17:40 +01:00
self:get_text_input():connect_signal("key::press", function(_, mod, key, cmd)
if key == "Escape" then
app_launcher:hide()
end
end)
self:get_text_input():connect_signal("key::release", function(_, mod, key, cmd)
if key == "Return" then
if app_launcher:get_rofi_grid():get_selected_widget() ~= nil then
app_launcher:get_rofi_grid():get_selected_widget():exec()
end
end
end)
end
local function generate_apps(self)
local entries = {}
2023-03-12 17:28:26 +01:00
local app_launcher = self
local app_info = Gio.AppInfo
local apps = app_info.get_all()
for _, app in ipairs(apps) do
2023-02-21 04:01:16 +01:00
if app:should_show() then
local id = app:get_id()
local desktop_app_info = Gio.DesktopAppInfo.new(id)
local name = desktop_app_info:get_string("Name")
local exec = desktop_app_info:get_string("Exec")
-- Check if this app should be skipped, depanding on the skip_names / skip_commands table
2023-02-21 04:01:16 +01:00
if not has_value(self.skip_names, name) and not has_value(self.skip_commands, exec) then
-- Check if this app should be skipped becuase it's iconless depanding on skip_empty_icons
2023-02-21 04:01:16 +01:00
local icon = helpers.icon_theme.get_gicon_path(app_info.get_icon(app), self.icon_theme, self.icon_size)
if icon ~= "" or self.skip_empty_icons == false then
if icon == "" then
if self.default_app_icon_name ~= nil then
2023-02-14 01:26:18 +01:00
icon = helpers.icon_theme.get_icon_path(self.default_app_icon_name, self.icon_theme, self.icon_size)
elseif self.default_app_icon_path ~= nil then
icon = self.default_app_icon_path
else
2023-02-14 01:26:18 +01:00
icon = helpers.icon_theme.choose_icon(
{"application-all", "application", "application-default-icon", "app"},
self.icon_theme, self.icon_size)
end
end
local app = {
desktop_app_info = desktop_app_info,
2023-02-21 04:01:16 +01:00
path = desktop_app_info:get_filename(),
id = id,
name = name,
2023-02-21 04:01:16 +01:00
generic_name = desktop_app_info:get_string("GenericName"),
startup_wm_class = desktop_app_info:get_startup_wm_class(),
keywords = desktop_app_info:get_string("Keywords"),
icon = icon,
icon_name = desktop_app_info:get_string("Icon"),
terminal = desktop_app_info:get_string("Terminal") == "true" and true or false,
exec = exec,
launch = function()
app:launch()
end
}
2023-03-12 17:28:26 +01:00
table.insert(entries, app)
end
end
end
end
2023-03-12 17:28:26 +01:00
self:get_rofi_grid():set_entries(entries)
end
More app launcher improvements (#132) * Make sure there is always a default icon * Use get_example_icon_path to get the default icon * Refactor scrolling to add support for left and right scrolling * fixup! Make sure there is always a default icon * Fix calculation happening at the wrong time * Fix default icons again * Where did that come from? * Fix calculation happening at the wrong time for scroll_up as well * Fix error on scroll right when scrolling to page where amount of rows is smaller than the selected row * Sort search results by string similarity * Don't sort by similarity when the search string is empty * Add hover effects * try_to_keep_index_after_searching should be false by default * This should only trigger for lmb * Add an option to hide the app launcher when clicked with lmb/rmb outside of it * Use gtk-launch so terminal apps spawn correctly * Use get_executable instead of get_commandline * Add an option to set the hover colors * Further improvements for the spawn function * Fix scrolling/searching errors when there app list is empty * This should never be nil anyway * whitespace * Refactor show, hide and toggle method + remove support for manually setting x an y (use placement) * Add arguements for custom icon_theme (defaults to the selected system gtk theme) and icon_size (defaults to 48) * Pass the app table instead of individual keys to create_app_widget * Add an arguement to pass the default terminal for terminal apps as gtk-launch only uses xterm * Reformating * Rename 'mark_app' and 'unmark_app' to 'select_app' and 'unselect_app' * Call :hide() from app.spawn() to avoid calling hide() twice on some cases * Fix escape not closing the launcher after b7e44ec4 * Reduce code duplication and only reset the launcher when the animation is over (if not nil) * Set active_widget to nil when the grid is empty to prevent from spawning the wrong app * Override the default exe_callback * Override the default behaviour for 'Return' via hooks instead because overriding only exe_callback still doesn't stop it from pausing the prompt keygrabber * Set active_widget to nil on unselect * Unselect previous app on search to avoid from spawning it when the grid is empty * Use double quotes for everything
2021-11-05 04:38:54 +01:00
function app_launcher:show()
if self.show_on_focused_screen then
self:get_widget().screen = awful.screen.focused()
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
end
self:get_widget().visible = true
self:get_text_input():focus()
self:emit_signal("visibility", true)
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
end
More app launcher improvements (#132) * Make sure there is always a default icon * Use get_example_icon_path to get the default icon * Refactor scrolling to add support for left and right scrolling * fixup! Make sure there is always a default icon * Fix calculation happening at the wrong time * Fix default icons again * Where did that come from? * Fix calculation happening at the wrong time for scroll_up as well * Fix error on scroll right when scrolling to page where amount of rows is smaller than the selected row * Sort search results by string similarity * Don't sort by similarity when the search string is empty * Add hover effects * try_to_keep_index_after_searching should be false by default * This should only trigger for lmb * Add an option to hide the app launcher when clicked with lmb/rmb outside of it * Use gtk-launch so terminal apps spawn correctly * Use get_executable instead of get_commandline * Add an option to set the hover colors * Further improvements for the spawn function * Fix scrolling/searching errors when there app list is empty * This should never be nil anyway * whitespace * Refactor show, hide and toggle method + remove support for manually setting x an y (use placement) * Add arguements for custom icon_theme (defaults to the selected system gtk theme) and icon_size (defaults to 48) * Pass the app table instead of individual keys to create_app_widget * Add an arguement to pass the default terminal for terminal apps as gtk-launch only uses xterm * Reformating * Rename 'mark_app' and 'unmark_app' to 'select_app' and 'unselect_app' * Call :hide() from app.spawn() to avoid calling hide() twice on some cases * Fix escape not closing the launcher after b7e44ec4 * Reduce code duplication and only reset the launcher when the animation is over (if not nil) * Set active_widget to nil when the grid is empty to prevent from spawning the wrong app * Override the default exe_callback * Override the default behaviour for 'Return' via hooks instead because overriding only exe_callback still doesn't stop it from pausing the prompt keygrabber * Set active_widget to nil on unselect * Unselect previous app on search to avoid from spawning it when the grid is empty * Use double quotes for everything
2021-11-05 04:38:54 +01:00
function app_launcher:hide()
if self:get_widget().visible == false then
2023-02-22 04:17:18 +01:00
return
end
if self.reset_on_hide == true then
self:get_rofi_grid():reset()
end
self:get_widget().visible = false
self:get_text_input():unfocus()
self:emit_signal("visibility", false)
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
end
More app launcher improvements (#132) * Make sure there is always a default icon * Use get_example_icon_path to get the default icon * Refactor scrolling to add support for left and right scrolling * fixup! Make sure there is always a default icon * Fix calculation happening at the wrong time * Fix default icons again * Where did that come from? * Fix calculation happening at the wrong time for scroll_up as well * Fix error on scroll right when scrolling to page where amount of rows is smaller than the selected row * Sort search results by string similarity * Don't sort by similarity when the search string is empty * Add hover effects * try_to_keep_index_after_searching should be false by default * This should only trigger for lmb * Add an option to hide the app launcher when clicked with lmb/rmb outside of it * Use gtk-launch so terminal apps spawn correctly * Use get_executable instead of get_commandline * Add an option to set the hover colors * Further improvements for the spawn function * Fix scrolling/searching errors when there app list is empty * This should never be nil anyway * whitespace * Refactor show, hide and toggle method + remove support for manually setting x an y (use placement) * Add arguements for custom icon_theme (defaults to the selected system gtk theme) and icon_size (defaults to 48) * Pass the app table instead of individual keys to create_app_widget * Add an arguement to pass the default terminal for terminal apps as gtk-launch only uses xterm * Reformating * Rename 'mark_app' and 'unmark_app' to 'select_app' and 'unselect_app' * Call :hide() from app.spawn() to avoid calling hide() twice on some cases * Fix escape not closing the launcher after b7e44ec4 * Reduce code duplication and only reset the launcher when the animation is over (if not nil) * Set active_widget to nil when the grid is empty to prevent from spawning the wrong app * Override the default exe_callback * Override the default behaviour for 'Return' via hooks instead because overriding only exe_callback still doesn't stop it from pausing the prompt keygrabber * Set active_widget to nil on unselect * Unselect previous app on search to avoid from spawning it when the grid is empty * Use double quotes for everything
2021-11-05 04:38:54 +01:00
function app_launcher:toggle()
if self:get_widget().visible then
More app launcher improvements (#132) * Make sure there is always a default icon * Use get_example_icon_path to get the default icon * Refactor scrolling to add support for left and right scrolling * fixup! Make sure there is always a default icon * Fix calculation happening at the wrong time * Fix default icons again * Where did that come from? * Fix calculation happening at the wrong time for scroll_up as well * Fix error on scroll right when scrolling to page where amount of rows is smaller than the selected row * Sort search results by string similarity * Don't sort by similarity when the search string is empty * Add hover effects * try_to_keep_index_after_searching should be false by default * This should only trigger for lmb * Add an option to hide the app launcher when clicked with lmb/rmb outside of it * Use gtk-launch so terminal apps spawn correctly * Use get_executable instead of get_commandline * Add an option to set the hover colors * Further improvements for the spawn function * Fix scrolling/searching errors when there app list is empty * This should never be nil anyway * whitespace * Refactor show, hide and toggle method + remove support for manually setting x an y (use placement) * Add arguements for custom icon_theme (defaults to the selected system gtk theme) and icon_size (defaults to 48) * Pass the app table instead of individual keys to create_app_widget * Add an arguement to pass the default terminal for terminal apps as gtk-launch only uses xterm * Reformating * Rename 'mark_app' and 'unmark_app' to 'select_app' and 'unselect_app' * Call :hide() from app.spawn() to avoid calling hide() twice on some cases * Fix escape not closing the launcher after b7e44ec4 * Reduce code duplication and only reset the launcher when the animation is over (if not nil) * Set active_widget to nil when the grid is empty to prevent from spawning the wrong app * Override the default exe_callback * Override the default behaviour for 'Return' via hooks instead because overriding only exe_callback still doesn't stop it from pausing the prompt keygrabber * Set active_widget to nil on unselect * Unselect previous app on search to avoid from spawning it when the grid is empty * Use double quotes for everything
2021-11-05 04:38:54 +01:00
self:hide()
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
else
More app launcher improvements (#132) * Make sure there is always a default icon * Use get_example_icon_path to get the default icon * Refactor scrolling to add support for left and right scrolling * fixup! Make sure there is always a default icon * Fix calculation happening at the wrong time * Fix default icons again * Where did that come from? * Fix calculation happening at the wrong time for scroll_up as well * Fix error on scroll right when scrolling to page where amount of rows is smaller than the selected row * Sort search results by string similarity * Don't sort by similarity when the search string is empty * Add hover effects * try_to_keep_index_after_searching should be false by default * This should only trigger for lmb * Add an option to hide the app launcher when clicked with lmb/rmb outside of it * Use gtk-launch so terminal apps spawn correctly * Use get_executable instead of get_commandline * Add an option to set the hover colors * Further improvements for the spawn function * Fix scrolling/searching errors when there app list is empty * This should never be nil anyway * whitespace * Refactor show, hide and toggle method + remove support for manually setting x an y (use placement) * Add arguements for custom icon_theme (defaults to the selected system gtk theme) and icon_size (defaults to 48) * Pass the app table instead of individual keys to create_app_widget * Add an arguement to pass the default terminal for terminal apps as gtk-launch only uses xterm * Reformating * Rename 'mark_app' and 'unmark_app' to 'select_app' and 'unselect_app' * Call :hide() from app.spawn() to avoid calling hide() twice on some cases * Fix escape not closing the launcher after b7e44ec4 * Reduce code duplication and only reset the launcher when the animation is over (if not nil) * Set active_widget to nil when the grid is empty to prevent from spawning the wrong app * Override the default exe_callback * Override the default behaviour for 'Return' via hooks instead because overriding only exe_callback still doesn't stop it from pausing the prompt keygrabber * Set active_widget to nil on unselect * Unselect previous app on search to avoid from spawning it when the grid is empty * Use double quotes for everything
2021-11-05 04:38:54 +01:00
self:show()
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
end
end
function app_launcher:get_widget()
return self._private.widget
end
function app_launcher:get_rofi_grid()
return self:get_widget().widget
end
function app_launcher:get_text_input()
return self:get_rofi_grid():get_text_input()
end
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
local function new(args)
args = args or {}
2023-03-12 23:49:54 +01:00
local ret = gobject {}
args.skip_names = default_value(args.skip_names, {})
args.skip_commands = default_value(args.skip_commands, {})
args.skip_empty_icons = default_value(args.skip_empty_icons, false)
args.hide_on_left_clicked_outside = default_value(args.hide_on_left_clicked_outside, true)
args.hide_on_right_clicked_outside = default_value(args.hide_on_right_clicked_outside, true)
args.hide_on_launch = default_value(args.hide_on_launch, true)
args.reset_on_hide = default_value(args.reset_on_hide, true)
args.type = default_value(args.type, "dock")
args.show_on_focused_screen = default_value(args.show_on_focused_screen, true)
args.screen = default_value(args.screen, capi.screen.primary)
args.placement = default_value(args.placement, awful.placement.centered)
args.bg = default_value(args.bg, "#000000")
args.border_width = default_value(args.border_width, beautiful.border_width or dpi(0))
args.border_color = default_value(args.border_color, beautiful.border_color or "#FFFFFF")
args.shape = default_value(args.shape, nil)
args.default_app_icon_name = default_value(args.default_app_icon_name, nil)
args.default_app_icon_path = default_value(args.default_app_icon_path, nil)
args.icon_theme = default_value(args.icon_theme, nil)
args.icon_size = default_value(args.icon_size, nil)
args.apps_per_row = default_value(args.apps_per_row, 5)
args.apps_per_column = default_value(args.apps_per_column, 3)
args.text_input_bg_color = default_value(args.text_input_bg_color, "#000000")
args.text_input_text_color = default_value(args.text_input_text_color, "#FFFFFF")
2023-03-12 23:58:38 +01:00
args.text_input_selection_bg = default_value(args.text_input_selection_bg, "#FF0000")
2023-03-28 01:06:57 +02:00
args.text_input_placeholder = default_value(args.text_input_placeholder, "Search:")
2023-02-20 02:39:42 +01:00
args.app_normal_color = default_value(args.app_normal_color, "#000000")
args.app_selected_color = default_value(args.app_selected_color, "#FFFFFF")
2023-03-12 11:32:11 +01:00
args.app_name_normal_color = default_value(args.app_name_normal_color, "#FFFFFF")
2023-02-20 02:39:42 +01:00
args.app_name_selected_color = default_value(args.app_name_selected_color, "#000000")
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
2023-02-19 16:36:09 +01:00
gtable.crush(ret, app_launcher, true)
gtable.crush(ret, args, true)
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
2023-02-19 16:47:54 +01:00
ret._private = {}
ret._private.text = ""
ret._private.pages_count = 0
ret._private.current_page = 1
2023-02-19 16:36:14 +01:00
ret._private.search_timer = gtimer {
timeout = 0.05,
2023-03-03 02:50:54 +01:00
call_now = false,
autostart = false,
2023-02-19 16:36:14 +01:00
single_shot = true,
callback = function()
ret:search()
2023-02-19 16:36:14 +01:00
end
}
if ret.hide_on_left_clicked_outside then
More app launcher improvements (#132) * Make sure there is always a default icon * Use get_example_icon_path to get the default icon * Refactor scrolling to add support for left and right scrolling * fixup! Make sure there is always a default icon * Fix calculation happening at the wrong time * Fix default icons again * Where did that come from? * Fix calculation happening at the wrong time for scroll_up as well * Fix error on scroll right when scrolling to page where amount of rows is smaller than the selected row * Sort search results by string similarity * Don't sort by similarity when the search string is empty * Add hover effects * try_to_keep_index_after_searching should be false by default * This should only trigger for lmb * Add an option to hide the app launcher when clicked with lmb/rmb outside of it * Use gtk-launch so terminal apps spawn correctly * Use get_executable instead of get_commandline * Add an option to set the hover colors * Further improvements for the spawn function * Fix scrolling/searching errors when there app list is empty * This should never be nil anyway * whitespace * Refactor show, hide and toggle method + remove support for manually setting x an y (use placement) * Add arguements for custom icon_theme (defaults to the selected system gtk theme) and icon_size (defaults to 48) * Pass the app table instead of individual keys to create_app_widget * Add an arguement to pass the default terminal for terminal apps as gtk-launch only uses xterm * Reformating * Rename 'mark_app' and 'unmark_app' to 'select_app' and 'unselect_app' * Call :hide() from app.spawn() to avoid calling hide() twice on some cases * Fix escape not closing the launcher after b7e44ec4 * Reduce code duplication and only reset the launcher when the animation is over (if not nil) * Set active_widget to nil when the grid is empty to prevent from spawning the wrong app * Override the default exe_callback * Override the default behaviour for 'Return' via hooks instead because overriding only exe_callback still doesn't stop it from pausing the prompt keygrabber * Set active_widget to nil on unselect * Unselect previous app on search to avoid from spawning it when the grid is empty * Use double quotes for everything
2021-11-05 04:38:54 +01:00
awful.mouse.append_client_mousebinding(
awful.button({ }, 1, function (c)
ret:hide()
end)
)
awful.mouse.append_global_mousebinding(
awful.button({ }, 1, function (c)
ret:hide()
end)
)
end
if ret.hide_on_right_clicked_outside then
More app launcher improvements (#132) * Make sure there is always a default icon * Use get_example_icon_path to get the default icon * Refactor scrolling to add support for left and right scrolling * fixup! Make sure there is always a default icon * Fix calculation happening at the wrong time * Fix default icons again * Where did that come from? * Fix calculation happening at the wrong time for scroll_up as well * Fix error on scroll right when scrolling to page where amount of rows is smaller than the selected row * Sort search results by string similarity * Don't sort by similarity when the search string is empty * Add hover effects * try_to_keep_index_after_searching should be false by default * This should only trigger for lmb * Add an option to hide the app launcher when clicked with lmb/rmb outside of it * Use gtk-launch so terminal apps spawn correctly * Use get_executable instead of get_commandline * Add an option to set the hover colors * Further improvements for the spawn function * Fix scrolling/searching errors when there app list is empty * This should never be nil anyway * whitespace * Refactor show, hide and toggle method + remove support for manually setting x an y (use placement) * Add arguements for custom icon_theme (defaults to the selected system gtk theme) and icon_size (defaults to 48) * Pass the app table instead of individual keys to create_app_widget * Add an arguement to pass the default terminal for terminal apps as gtk-launch only uses xterm * Reformating * Rename 'mark_app' and 'unmark_app' to 'select_app' and 'unselect_app' * Call :hide() from app.spawn() to avoid calling hide() twice on some cases * Fix escape not closing the launcher after b7e44ec4 * Reduce code duplication and only reset the launcher when the animation is over (if not nil) * Set active_widget to nil when the grid is empty to prevent from spawning the wrong app * Override the default exe_callback * Override the default behaviour for 'Return' via hooks instead because overriding only exe_callback still doesn't stop it from pausing the prompt keygrabber * Set active_widget to nil on unselect * Unselect previous app on search to avoid from spawning it when the grid is empty * Use double quotes for everything
2021-11-05 04:38:54 +01:00
awful.mouse.append_client_mousebinding(
awful.button({ }, 3, function (c)
ret:hide()
end)
)
awful.mouse.append_global_mousebinding(
awful.button({ }, 3, function (c)
ret:hide()
end)
)
end
2023-03-07 12:20:28 +01:00
awful.spawn.easy_async_with_shell("pkill -f 'inotifywait -m /usr/share/applications -e modify'", function()
awful.spawn.with_line_callback("inotifywait -m /usr/share/applications -e modify", {stdout = function()
generate_apps(ret)
end})
end)
2023-02-19 17:01:01 +01:00
build_widget(ret)
2023-02-05 01:20:23 +01:00
generate_apps(ret)
App launcher ala rofi widget (#103) * Initial commit * Fix missing dpi variable * Add an option to search by command * Add turn_on and turn_off signals * Add options to skip apps by their names or commands * Add an option to skip apps with no icons * Fix looping over the wrong table * Refactor to make it into a proper bling like widget * Fix selecting the wrong app after a search * Why was this in a seperate check? * Fix various issues with toggle/show/hide * Stop it from complaining * Fix wrong app getting selected after scrolling up/down * Add an option to spawn the app when pressing on it regardless if it was selected or not * lol what? * Don't add widgets that won't be visible after scrolling down * Yap wasn't needed * This is a little clearer * Add an option 'try_to_keep_index_after_search' to mimic rofi behaviour * Only add widgets that are visible after a search * Fix search not adding the correct number of widgets * Add proper customization options * Add proper customizaiton options for the prompt * Simplfy scroll down logic and fix possible bugs * Add animation support * Fix app list being empty on some occasions * Default placement when x and y is nil * Free up ram * Add a default icon option * style change * Not needed and also hurts search peformance by a decent amount * Fix error when trying to spawn an app when no app is currently marked * Not needed * Add a small debounce delay for the search to prevent it from lagging * Formatting * Replace menubar with app_info * Fix the default icon option
2021-11-03 22:38:50 +01:00
return ret
end
function app_launcher.mt:__call(...)
return new(...)
end
return setmetatable(app_launcher, app_launcher.mt)