mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-09 01:34:21 +02:00
start: make xrun start apps after awesome is ready
`xrun` is also moved in its own module
This commit is contained in:
parent
1367a9bad1
commit
b1eaaf7516
3 changed files with 50 additions and 48 deletions
2
rc.lua
2
rc.lua
|
@ -42,6 +42,7 @@ config.layouts = {
|
||||||
config.hostname = awful.util.pread('uname -n'):gsub('\n', '')
|
config.hostname = awful.util.pread('uname -n'):gsub('\n', '')
|
||||||
|
|
||||||
-- Remaining modules
|
-- Remaining modules
|
||||||
|
loadrc("xrun")
|
||||||
loadrc("appearance")
|
loadrc("appearance")
|
||||||
loadrc("start")
|
loadrc("start")
|
||||||
loadrc("bindings")
|
loadrc("bindings")
|
||||||
|
@ -53,4 +54,3 @@ loadrc("signals")
|
||||||
loadrc("rules")
|
loadrc("rules")
|
||||||
|
|
||||||
root.keys(config.keys.global)
|
root.keys(config.keys.global)
|
||||||
startapps()
|
|
||||||
|
|
63
rc/start.lua
63
rc/start.lua
|
@ -1,23 +1,5 @@
|
||||||
-- Startup
|
-- Startup
|
||||||
|
|
||||||
-- run a command only if the client does not already exist
|
|
||||||
xrun = function(name, cmd)
|
|
||||||
-- Try first the list of clients from awesome
|
|
||||||
local clients = client.get()
|
|
||||||
local client
|
|
||||||
for _, client in pairs(clients) do
|
|
||||||
if client.name == name or client.class == name or client.instance == name then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Not found, let's check with xwininfo. We can only check name...
|
|
||||||
if os.execute("xwininfo -name '" .. name .. "' > /dev/null 2> /dev/null") == 0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
awful.util.spawn_with_shell(cmd or name)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Setup display
|
-- Setup display
|
||||||
local xrandr = {
|
local xrandr = {
|
||||||
naruto = "--output VGA1 --auto --output DVI1 --auto --left-of VGA1",
|
naruto = "--output VGA1 --auto --output DVI1 --auto --left-of VGA1",
|
||||||
|
@ -70,34 +52,21 @@ end
|
||||||
os.execute(table.concat(execute, ";"))
|
os.execute(table.concat(execute, ";"))
|
||||||
|
|
||||||
-- Spawn various X programs
|
-- Spawn various X programs
|
||||||
startapps = function(now)
|
xrun("polkit-gnome-authentication-agent-1",
|
||||||
-- xrun can only be used when awesome has started
|
"/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1")
|
||||||
if not now then
|
xrun("Bluetooth Applet",
|
||||||
local stimer = timer { timeout = 0 }
|
"bluetooth-applet")
|
||||||
stimer:add_signal("timeout", function()
|
xrun("Pidgin", "pidgin -n")
|
||||||
stimer:stop()
|
xrun("emacs")
|
||||||
startapps(true)
|
|
||||||
end)
|
|
||||||
stimer:start()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
xrun("polkit-gnome-authentication-agent-1",
|
if config.hostname == "neo" then
|
||||||
"/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1")
|
xrun("keepassx", "keepassx -min -lock")
|
||||||
xrun("Bluetooth Applet",
|
xrun("Transmission", "transmission-gtk -m")
|
||||||
"bluetooth-applet")
|
xrun("chromium")
|
||||||
xrun("Pidgin", "pidgin -n")
|
elseif config.hostname == "guybrush" then
|
||||||
xrun("emacs")
|
xrun("keepassx", "keepassx -min -lock")
|
||||||
|
xrun("NetworkManager Applet", "nm-applet")
|
||||||
if config.hostname == "neo" then
|
xrun("chromium")
|
||||||
xrun("keepassx", "keepassx -min -lock")
|
elseif config.hostname == "naruto" then
|
||||||
xrun("Transmission", "transmission-gtk -m")
|
xrun("iceweasel")
|
||||||
xrun("chromium")
|
|
||||||
elseif config.hostname == "guybrush" then
|
|
||||||
xrun("keepassx", "keepassx -min -lock")
|
|
||||||
xrun("NetworkManager Applet", "nm-applet")
|
|
||||||
xrun("chromium")
|
|
||||||
elseif config.hostname == "naruto" then
|
|
||||||
xrun("iceweasel")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
33
rc/xrun.lua
Normal file
33
rc/xrun.lua
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
-- run a command only if the client does not already exist
|
||||||
|
|
||||||
|
local xrun_now = function(name, cmd)
|
||||||
|
-- Try first the list of clients from awesome (which is available
|
||||||
|
-- only if awesome has fully started, therefore, this function
|
||||||
|
-- should be run inside a 0 timer)
|
||||||
|
local clients = client.get()
|
||||||
|
local client
|
||||||
|
for _, client in pairs(clients) do
|
||||||
|
if client.name == name or client.class == name or client.instance == name then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Not found, let's check with xwininfo. We can only check name but
|
||||||
|
-- we can catch application without a window...
|
||||||
|
if os.execute("xwininfo -name '" .. name .. "' > /dev/null 2> /dev/null") == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
awful.util.spawn_with_shell(cmd or name)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Run a command if not already running.
|
||||||
|
xrun = function(name, cmd)
|
||||||
|
-- We need to wait for awesome to be ready. Hence the timer.
|
||||||
|
local stimer = timer { timeout = 0 }
|
||||||
|
local run = function()
|
||||||
|
stimer:stop()
|
||||||
|
xrun_now(name, cmd)
|
||||||
|
end
|
||||||
|
stimer:add_signal("timeout", run)
|
||||||
|
stimer:start()
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue