diff --git a/docs/widgets/app_launcher.md b/docs/widgets/app_launcher.md index b0c1ba40..332fce4f 100644 --- a/docs/widgets/app_launcher.md +++ b/docs/widgets/app_launcher.md @@ -35,7 +35,6 @@ local app_launcher = bling.widget.app_launcher(args) ```lua local args = { - terminal = "alacritty" -- Set default terminal favorites = { "firefox", "wezterm" } -- Favorites are given priority and are bubbled to top of the list search_commands = true -- Search by app name AND commandline command skip_names = { "Discord" } -- List of apps to omit from launcher diff --git a/widget/app_launcher/awesome-sensible-terminal b/widget/app_launcher/awesome-sensible-terminal new file mode 100755 index 00000000..4e47296c --- /dev/null +++ b/widget/app_launcher/awesome-sensible-terminal @@ -0,0 +1,25 @@ +#!/bin/sh +# Based on i3-sensible-terminal + +# +# This code is released in public domain by Han Boetes +# +# This script tries to exec a terminal emulator by trying some known terminal +# emulators. +# +# We welcome patches that add distribution-specific mechanisms to find the +# preferred terminal emulator. On Debian, there is the x-terminal-emulator +# symlink for example. +# +# Invariants: +# 1. $TERMINAL must come first +# 2. Distribution-specific mechanisms come next, e.g. x-terminal-emulator +# 3. The terminal emulator with best accessibility comes first. +# 4. No order is guaranteed/desired for the remaining terminal emulators. +for terminal in "$TERMINAL" termite hyper wezterm alacritty kitty x-terminal-emulator mate-terminal gnome-terminal terminator xfce4-terminal urxvt rxvt termit Eterm aterm uxterm xterm roxterm lxterminal terminology st qterminal lilyterm tilix terminix konsole guake tilda; do + if command -v "$terminal" > /dev/null 2>&1; then + exec "$terminal" "$@" + fi +done + +awesome-client 'local naughty = require("naughty"); naughty.notification { message = "awesome-sensible-terminal could not find a terminal emulator. Please install one." }' diff --git a/widget/app_launcher/init.lua b/widget/app_launcher/init.lua index 9dbd0ec3..8657a1e9 100644 --- a/widget/app_launcher/init.lua +++ b/widget/app_launcher/init.lua @@ -19,13 +19,9 @@ local path = ... local app_launcher = { mt = {} } -local terminal_commands_lookup = -{ - alacritty = "alacritty -e", - termite = "termite -e", - rxvt = "rxvt -e", - terminator = "terminator -e" -} +local AWESOME_SENSIBLE_TERMINAL_PATH = debug.getinfo(1).source:match("@?(.*/)") .. + "awesome-sensible-terminal" + local function string_levenshtein(str1, str2) local len1 = string.len(str1) @@ -191,16 +187,7 @@ local function create_app_widget(self, entry) function app.spawn() if entry.terminal == true then - if self.terminal ~= nil then - local terminal_command = terminal_commands_lookup[self.terminal] or self.terminal - awful.spawn(terminal_command .. " " .. entry.executable) - else - awful.spawn.easy_async("gtk-launch " .. entry.executable, function(stdout, stderr) - if stderr then - awful.spawn(entry.executable) - end - end) - end + awful.spawn.with_shell(AWESOME_SENSIBLE_TERMINAL_PATH .. " -e " .. entry.executable) else awful.spawn(entry.executable) end @@ -741,7 +728,6 @@ end local function new(args) args = args or {} - args.terminal = args.terminal or nil args.favorites = args.favorites or {} args.search_commands = args.search_commands == nil and true or args.search_commands args.skip_names = args.skip_names or {}