Add command line client

This commit is contained in:
James Reed 2019-08-30 17:09:49 -06:00
parent 3d88d6b71c
commit 6564196af3
No known key found for this signature in database
GPG Key ID: 8F79994F6B8378C1
3 changed files with 86 additions and 0 deletions

View File

@ -59,6 +59,36 @@ screen.connect_signal("request::desktop_decoration", function (s)
end)
```
## Command-line client
`awesome-launch` is a wrapper around `awesome-client` that can be used to
launch clients from the command line with single instance IDs tracked by
Awesome.
### Usage
```
usage: awesome-launch [options] COMMAND...
options:
-h Show help message
-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
-r Raise or spawn
```
Enable use of `awesome-client` by including the following in `rc.lua`:
```lua
require("awful.remote")
```
If installed via `luarocks`, ensure `awesome-launch`'s [location][1] is in your
`PATH`.
[1]: https://github.com/luarocks/luarocks/wiki/File-locations#Path_where_commandline_scripts_are_installed
## License
awesome-launch is licensed under the GNU General Public License v3.0 or later

51
awesome-launch Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
set -eu
usage() {
echo 'usage: awesome-launch [options] COMMAND...
options:
-h Show help message
-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
-r Raise or spawn'
}
usage_error() {
usage >&2
exit 2
}
while getopts ':hjf:i:sr' opt; do
case "$opt" in
h) usage; exit ;;
j) firejail=true ;;
f) factory="$OPTARG" ;;
i) id="$OPTARG" ;;
s) func='s' ;;
r) func='r' ;;
*) usage_error
esac
done
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',}
${firejail+firejail = '$firejail',}
${factory+factory = '$factory',}
}
require('awesome-launch').$name('$*', args)
"

View File

@ -19,4 +19,9 @@ build = {
["awesome-launch"] = "init.lua",
["awesome-launch.panel"] = "panel.lua",
},
install = {
bin = {
"awesome-launch",
},
},
}