]> git.rmz.io Git - dotfiles.git/commitdiff
awesome: use TERMINAL env as much as possible
authorSamir Benmendil <me@rmz.io>
Sun, 24 Jan 2021 01:31:13 +0000 (01:31 +0000)
committerSamir Benmendil <me@rmz.io>
Sun, 24 Jan 2021 21:35:32 +0000 (21:35 +0000)
awesome/bindings.lua
awesome/rc.lua
awesome/rules.lua
awesome/utils.lua
awesome/widgets/pomodoro.lua

index dd3edff7e0958e4c25efd7cc83524c2e933f6e39..8d960099baa5797174b1e71f48919f83018c1582 100644 (file)
@@ -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)
 )
 
index c932e62208e37615fe71949de23670dda17fc849..74688d7ed5ccf52701965f540a6aa6412a3d95a6 100644 (file)
@@ -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
 
index e06145fc3dee0521a86de10e38482a1c03a24271..f7488821a02a452fee5608b96c156f289c970d8d 100644 (file)
@@ -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" } },
index b8dd97fd122ad2347193fccc53677b930fbe5e94..40422416fa798df90f2ee3d4f3b5dd28265fa49e 100644 (file)
@@ -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
index b6e9116a33556f01001ddf94aa932125cff93f64..8a9b0d00cc7d416302ddd84954a5d7671c6ed8bf 100644 (file)
@@ -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,