Created
March 23, 2016 13:43
-
-
Save aajjbb/87d10eddc5eef2f84910 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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