try noop and easy async for spawning stuff

This commit is contained in:
Thomas Forgione 2017-10-25 10:35:27 +02:00
parent 780f92ff39
commit 318e46c77e
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
2 changed files with 29 additions and 16 deletions

View File

@ -27,6 +27,19 @@ local function set_text(text)
end
end
local function try_noop()
awful.spawn.easy_async_with_shell('sleep 2s && music-client noop', function(stdout, stderr, reason, code)
if code == 1 then
try_noop()
elseif code == 0 then
ret.execute_command('noop')
end
end);
end
ret.execute_command = function(command, arg)
awful.spawn.easy_async({'music-client', command, arg}, function(stdout, stderr, reason, code)
@ -53,8 +66,7 @@ ret.execute_command = function(command, arg)
elseif start_server_command then
-- Start the server and re-exec the command
os.execute('music-server&')
os.execute('sleep 0.2')
ret.execute_command('noop')
try_noop()
else
set_text('music-server not running')
end

View File

@ -433,51 +433,52 @@ globalkeys = awful.util.table.join(
end, {description = "skip to the previous music", group="custom"}),
awful.key({ }, "Print", function ()
os.execute('gnome-screenshot -fp "`echo -n ' .. home .. '"/Pictures/Captures/Capture du " && date "+%Y-%m-%d %H:%M:%S"`.png"')
awful.spawn.easy_async_with_shell('gnome-screenshot -fp "`echo -n ' .. home .. '"/Pictures/Captures/Capture du " && date "+%Y-%m-%d %H:%M:%S"`.png"')
end, {description = "capture the screen", group="custom"}),
awful.key({modkey}, "a", function ()
os.execute(options.browser .. '&')
awful.spawn.easy_async(options.browser, function() end)
naughty.notify({title = "Starting " .. options.browser})
end, {description="start the web browser", group="custom"}),
awful.key({modkey}, "l", function()
os.execute('bash -c "sleep 0.1 && xset dpms force off && slock"')
awful.spawn.easy_async('bash -c "sleep 0.1 && xset dpms force off && slock"', function() end)
end, { description="Locks the screen", group="custom"}),
awful.key({modkey, "Shift"}, "Tab", function()
os.execute('xdotool key Caps_Lock')
awful.spawn.easy_async('xdotool key Caps_Lock', function() end)
end, {description="switch the caps lock", group="custom"}),
awful.key({modkey}, "#83", function()
os.execute("tv.py enable left")
awful.spawn.easy_async("tv.py enable left", function() end)
end, {description="lol", group="custom"}),
awful.key({modkey}, "#84", function()
os.execute("tv.py duplicate")
awful.spawn.easy_async("tv.py duplicate", function() end)
end, {description="lol", group="custom"}),
awful.key({modkey}, "#85", function()
os.execute("tv.py enable right")
awful.spawn.easy_async("tv.py enable right", function() end)
end, {description="lol", group="custom"}),
awful.key({modkey}, "#80", function()
os.execute("tv.py enable above")
awful.spawn.easy_async("tv.py enable above", function() end)
end, {description="lol", group="custom"}),
awful.key({modkey}, "#88", function()
os.execute("tv.py enable below")
awful.spawn.easy_async("tv.py enable below", function() end)
end, {description="lol", group="custom"}),
awful.key({modkey}, "#90", function()
os.execute("tv.py disable")
awful.spawn.easy_async("tv.py disable", function() end)
end, {description="lol", group="custom"}),
awful.key({modkey, "Shift"}, "m", function()
os.execute('sleep 0.5')
for i = 1, #options.email do
os.execute('xdotool type --clearmodifiers ' .. options.email:sub(i,i))
end
awful.spawn.easy_async('sleep 0.5', function()
for i = 1, #options.email do
os.execute('xdotool type --clearmodifiers ' .. options.email:sub(i,i))
end
end)
end, {description="lol", group="autoinput"})
)