Skip to content

Instantly share code, notes, and snippets.

@aajjbb
Created February 15, 2016 02:24
Show Gist options
  • Save aajjbb/b58df8d0e9f60e6cfaf0 to your computer and use it in GitHub Desktop.
Save aajjbb/b58df8d0e9f60e6cfaf0 to your computer and use it in GitHub Desktop.
-- On rc.lua
function spawn_once(command, class, tag)
-- create move callback
local callback
callback = function(c)
if c.name == class then
awful.client.movetotag(tag, c)
client.disconnect_signal("manage", callback)
end
end
client.connect_signal("manage", callback)
-- now check if not already running!
local findme = command
local firstspace = findme:find(" ")
if firstspace then
findme = findme:sub(0, firstspace-1)
end
-- finally run it
awful.util.spawn_with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. command .. ")")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment