Compare commits

2 Commits

Author SHA1 Message Date
9cad6fc050 Start working on launcher mode 2021-08-14 13:49:26 +02:00
354ba05faa add dbus and dri 2021-08-14 13:48:55 +02:00
4 changed files with 39 additions and 10 deletions

View File

@@ -4,11 +4,11 @@ import os
type Args* = object
name*: Option[string]
cmd*: Option[string]
cmd*: Option[seq[string]]
profile*: Option[string]
proc getCmd*(args: Args): string =
return args.cmd.get(getEnv("SHELL", "/bin/bash"))
proc getCmd*(args: Args): seq[string] =
return args.cmd.get(@[getEnv("SHELL", "/bin/bash")])
proc getProfile*(args: Args): string =
if args.profile.isSome:
@@ -18,8 +18,8 @@ proc getProfile*(args: Args): string =
proc parseOpt(args: var Args, key: string, value: string): bool =
case key
of "command", "c":
args.cmd = some(value)
of "name", "n":
args.name = some(value)
of "profile", "p":
args.profile = some(value)
else:
@@ -30,6 +30,7 @@ proc parseOpt(args: var Args, key: string, value: string): bool =
proc parseArgs*(): Option[Args] =
var p = initOptParser()
var args = Args()
var command = newSeq[string]()
while true:
p.next()
@@ -40,6 +41,9 @@ proc parseArgs*(): Option[Args] =
echo "Invalid argument ", p.val
return
of cmdArgument:
args.name = some(p.key.string)
command.add(p.key.string)
if command.len > 0:
args.cmd = some(command)
return some(args)

View File

@@ -10,10 +10,10 @@ type DbusProxy* = object
socket*: string
args: seq[string]
proc exec*(proxy: var DbusProxy) =
proc exec*(proxy: DbusProxy): Process =
# todo: start dbus proxy in bwrap
# todo: pass arguments as fd
proxy.process = startProcess("xdg-dbus-proxy", args = proxy.args,
startProcess("xdg-dbus-proxy", args = proxy.args,
options = {poEchoCmd, poParentStreams, poUsePath})
proc startDBusProxy*(config: Config, hostname: string): DbusProxy =
@@ -49,6 +49,6 @@ proc startDBusProxy*(config: Config, hostname: string): DbusProxy =
proxy.args.add("--filter")
proxy.args.add("--log")
proxy.exec()
proxy.process = proxy.exec()
proxy

View File

@@ -5,9 +5,10 @@ import random
proc main(): int =
let args = parseArgs()
echo args
if args.isNone:
echo "Usage: bwshell --command=cmd --profile=profile <sandbox_name>"
echo "Usage: bwshell --name=sandbox_name --profile=profile <sandbox_cmd>"
return 1
else:
randomize()

24
scripts/applications.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <target_dir>"
exit 1
fi
check_dir() {
local dir=$1
local file
for application in "$dir/"*; do
file="$(basename "$application")"
sed "s/Exec=/Exec=bwrap --name='$file' --profile=gui /gi" "$application" > "$target/$file"
done
}
dirs=("/usr/share/applications" "$HOME/.local/share/applications")
target="$1"
for dir in "${dirs[@]}"; do
check_dir "$dir"
done