Support launching with `systemd-run`

Runs in a user scope via `systemd-run --user --scope`.
This commit is contained in:
James Reed 2020-08-19 12:36:08 -06:00
parent da2caa7315
commit da7b3c31de
No known key found for this signature in database
GPG Key ID: 0BE2BD33C5E8125E
5 changed files with 21 additions and 14 deletions

View File

@ -93,10 +93,11 @@ usage: awesome-launch [options] COMMAND...
options:
-h Show help message
-s Launch with systemd-run
-j Launch with firejail
-f FACTORY Launch via a window factory
-i ID The single instance ID to use
-s Spawn if not already running
-1 Spawn if not already running
-r Raise or spawn
```

View File

@ -7,10 +7,11 @@ usage() {
options:
-h Show help message
-s Launch with systemd-run
-j Launch with firejail
-f FACTORY Launch via a window factory
-i ID The single instance ID to use
-s Spawn if not already running
-1 Spawn if not already running
-r Raise or spawn'
}
@ -19,14 +20,15 @@ usage_error() {
exit 2
}
while getopts ':hjf:i:sr' opt; do
while getopts ':hsjf:i:1r' opt; do
case "$opt" in
h) usage; exit ;;
s) systemd=true ;;
j) firejail=true ;;
f) factory="$OPTARG" ;;
i) id="$OPTARG" ;;
s) func='s' ;;
r) func='r' ;;
1) func='spawn.single_instance' ;;
r) func='spawn.raise_or_spawn' ;;
*) usage_error
esac
done
@ -35,17 +37,12 @@ shift $((OPTIND - 1))
[ $# -eq 0 ] && usage_error
case "${func-}" in
s) name='spawn.single_instance' ;;
r) name='spawn.raise_or_spawn' ;;
*) name='spawn'
esac
awesome-client "
args = {
${id+id = '$id',}
${systemd+systemd = '$systemd',}
${firejail+firejail = '$firejail',}
${factory+factory = '$factory',}
}
require('awesome-launch').$name('$*', args)
require('awesome-launch').${func-spawn}('$*', args)
"

View File

@ -95,6 +95,7 @@ end
-- @param args.timeout Seconds after which to stop waiting for a client to spawn.
-- @param args.callback Function to call with client when it spawns.
-- @param args.factory The factory to use (see wm-launch's -f flag).
-- @param args.systemd If true, run cmd with systemd-run.
-- @param args.firejail If true, run cmd with firejail.
-- @return The client's ID.
-- @function launch.spawn
@ -140,6 +141,10 @@ local function spawn(cmd, args)
launch_cmd = launch_cmd .. " -f " .. args.factory
end
if args.systemd then
launch_cmd = launch_cmd .. " -s"
end
if args.firejail then
launch_cmd = launch_cmd .. " -j"
end
@ -173,6 +178,7 @@ setmetatable(launch.spawn, {__call = function (_, ...) spawn(...) end})
-- @param args.timeout Seconds after which to stop waiting for a client to spawn.
-- @param args.callback Function to call with client when it spawns.
-- @param args.factory The factory to use (see wm-launch's -f flag).
-- @param args.systemd If true, run cmd with systemd-run.
-- @param args.firejail If true, run cmd with firejail.
-- @param args.filter Function to filter clients that are considered.
-- @return The client's ID.
@ -199,6 +205,7 @@ end
-- @param args.callback Function to call with client when it spawns.
-- @param args.raise_callback Function to call with client when it spawns or is raised.
-- @param args.factory The factory to use (see wm-launch's -f flag).
-- @param args.systemd If true, run cmd with systemd-run.
-- @param args.firejail If true, run cmd with firejail.
-- @param args.filter Function to filter clients that are considered.
-- @return The client's ID.

View File

@ -1,7 +1,7 @@
--- Launch clients as panels.
--
-- @author James Reed <jcrd@tuta.io>
-- @copyright 2019 James Reed
-- @copyright 2019-2020 James Reed
-- @module awesome-launch.panel
local awful = require("awful")
@ -49,6 +49,7 @@ end
-- @param args.timeout Seconds after which to stop waiting for a client to spawn.
-- @param args.callback Function to call with client when it spawns.
-- @param args.factory The factory to use (see wm-launch's -f flag).
-- @param args.systemd If true, run cmd with systemd-run.
-- @param args.firejail If true, run cmd with firejail.
-- @param args.filter Function to filter clients that are considered.
-- @param args.scale Percent to scale client (see awful.placement.scale).

View File

@ -1,7 +1,7 @@
--- Create new workspaces and launch accompanying clients.
--
-- @author James Reed <jcrd@tuta.io>
-- @copyright 2019 James Reed
-- @copyright 2019-2020 James Reed
-- @module awesome-launch.workspace
local awful = require("awful")
@ -105,6 +105,7 @@ end
-- @param args.timeout Seconds after which to stop waiting for a client to spawn.
-- @param args.callback Function to call with client when it spawns.
-- @param args.factory The factory to use (see wm-launch's -f flag).
-- @param args.systemd If true, run cmd with systemd-run.
-- @param args.firejail If true, run cmd with firejail.
-- @param tag The tag.
-- @function client.add