From: Samir Benmendil Date: Sun, 24 Jan 2021 01:31:13 +0000 (+0000) Subject: awesome: use TERMINAL env as much as possible X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/800d8089ce276ae1b2a3f9875a370b7e00a763db?ds=sidebyside awesome: use TERMINAL env as much as possible --- diff --git a/awesome/bindings.lua b/awesome/bindings.lua index dd3edff..8d96009 100644 --- a/awesome/bindings.lua +++ b/awesome/bindings.lua @@ -1,4 +1,5 @@ local hotkeys_popup = require("awful.hotkeys_popup").widget +local utils = require("utils") -- Default modkey. modkey = "Mod4" @@ -124,7 +125,7 @@ globalkeys = gears.table.join(globalkeys, awful.key({ }, "F13", function () awful.spawn("ksnapshot") end), awful.key({ }, "Print", function () awful.spawn("ksnapshot") end), -- ranger - awful.key({ modkey }, "r", function () awful.spawn(terminal .. " -e ranger") end), + awful.key({ modkey }, "r", function () utils.spawn_terminal("ranger") end), -- Volume awful.key({ }, "XF86AudioMute", function () awful.spawn("pulsemixer --toggle-mute") end, {description = "toggle mute", group = "volume"}), @@ -142,7 +143,7 @@ globalkeys = gears.table.join(globalkeys, awful.key({ modkey, "Control" }, "Escape", function () awful.spawn("i3lock -c 000000") end), -- VimWiki awful.key({ modkey }, "i", function () - awful.spawn(terminal.." -name vimwiki -e vim -c 'call vimwiki#base#goto_index(v:count1)'") + utils.spawn_terminal("vim -c 'call vimwiki#base#goto_index(v:count1)'", { instance = "vimwiki"}) end) ) diff --git a/awesome/rc.lua b/awesome/rc.lua index c932e62..74688d7 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -37,7 +37,15 @@ end beautiful.init(gears.filesystem.get_dir("config").."/themes/mlp/theme.lua") -- This is used later as the default terminal and editor to run. -terminal = "urxvtc" +terminal = os.getenv("TERMINAL") or "xterm" +terminal_class = (function() + local map = { urxvt = "URxvt" + , urxvtc = "URxvt" + , xterm = "XTerm" + } + return map[terminal] or terminal +end)() + editor = os.getenv("EDITOR") or "vim" editor_cmd = terminal .. " -e " .. editor diff --git a/awesome/rules.lua b/awesome/rules.lua index e06145f..f748882 100644 --- a/awesome/rules.lua +++ b/awesome/rules.lua @@ -35,7 +35,7 @@ awful.rules.rules = { "gimp", } }, properties = { floating = true } }, - { rule = { class = "URxvt", instance = "pulsemixer" }, + { rule = { class = terminal_class, instance = "pulsemixer" }, properties = { floating = true, skip_taskbar = true, ontop = true, @@ -46,18 +46,18 @@ awful.rules.rules = { end } }, { rule = { class = "Wine"}, properties = { floating = true } }, - { rule = { class = "URxvt"}, + { rule = { class = terminal_class }, properties = { opacity = 0.8 } }, - { rule = { class = "URxvt", instance = "mutt" }, + { rule = { class = terminal_class, instance = "mutt" }, properties = { tag = wwwtag, function (c) awful.client.setslave(c) end } }, - { rule = { class = "URxvt", instance = "ncmpcpp" }, + { rule = { class = terminal_class, instance = "ncmpcpp" }, properties = { tag = mediatag, function (c) awful.client.setmaster(c) end } }, - { rule = { class = "URxvt", instance = "mopidy" }, + { rule = { class = terminal_class, instance = "mopidy" }, properties = { tag = mediatag, function (c) awful.client.setmaster(c) end } }, - { rule = { class = "URxvt", instance = "weechat" }, + { rule = { class = terminal_class, instance = "weechat" }, properties = { tag = imtag, function (c) awful.client.setmaster(c) end } }, { rule_any = { class = { "Steam", "steam" } }, diff --git a/awesome/utils.lua b/awesome/utils.lua index b8dd97f..4042241 100644 --- a/awesome/utils.lua +++ b/awesome/utils.lua @@ -13,6 +13,17 @@ function utils.is_dir(path) return os.execute(('[ -d "%s" ]'):format(path)) end +function utils.spawn_terminal(prg, cprop, cb) + local join = require("gears.table").join + local term_cmd = {terminal} + if cprop and cprop.instance then + if terminal:match("rxvt") then + term_cmd = join(term_cmd, {"-name", cprop.instance}) + end + end + awful.spawn(join(term_cmd, {"-e", prg}), cprop, cb) +end + function utils.run_or_kill(prg, cprop, screen) if not prg then do return nil end diff --git a/awesome/widgets/pomodoro.lua b/awesome/widgets/pomodoro.lua index b6e9116..8a9b0d0 100644 --- a/awesome/widgets/pomodoro.lua +++ b/awesome/widgets/pomodoro.lua @@ -22,7 +22,7 @@ pombox:add(pomodoro.widget) -- pomodoro:connect_signal("stop_pause", function () naughty.notify{ text = "stop_pause", timeout = 10 } end) -- pomodoro:connect_signal("start_working", function () naughty.notify{ text = "start_working", timeout = 10 } end) pomodoro:connect_signal("work_stop", function () - awful.spawn(terminal.." -name diary -e diary") + utils.spawn_terminal("diary", { instance = "diary" }) end) globalkeys = gears.table.join(globalkeys,