1 Commits

Author SHA1 Message Date
920eb49941 add dbus and dri 2021-06-27 18:31:05 +02:00
10 changed files with 30 additions and 67 deletions

View File

@@ -1 +0,0 @@
{"extends": "shell", "mountcwd": true}

View File

@@ -1,10 +0,0 @@
{
"mount": [],
"romount": ["/etc", "/var", "/usr", "/opt"],
"symlinks": [
{"src": "usr/lib", "dst": "/lib"},
{"src": "usr/lib64", "dst": "/lib64"},
{"src": "usr/bin", "dst": "/bin"},
{"src": "usr/sbin", "dst": "/sbin"}
]
}

View File

@@ -1 +0,0 @@
{"extends": "shell", "romount": [".gitconfig", ".gnupg", "/run/user/1000/gnupg", ".ssh/config"], "mountcwd": true, "mount": [".ssh/known_hosts"]}

View File

@@ -1 +0,0 @@
{"extends": "default", "romount": [".Xauthority", "/tmp/.X11-unix", "/run/user/1000/pulse/native"], "dbus": true, "dbuscall": ["org.freedesktop.Notifications.*=@/org/freedesktop/Notifications", "org.freedesktop.portal.*=*"], "dbusbroadcast": ["org.freedesktop.portal.*=@/org/freedesktop/portal/*"]}

View File

@@ -1 +0,0 @@
{"extends": "default", "romount": [".oh-my-zsh", ".zsh", ".zshrc", ".zshrc-local"], "sethostname": true}

View File

@@ -1,13 +1,14 @@
import parseopt
import options import options
import os import os
type Args* = object type Args* = object
name*: Option[string] name*: Option[string]
cmd*: Option[seq[string]] cmd*: Option[string]
profile*: Option[string] profile*: Option[string]
proc getCmd*(args: Args): seq[string] = proc getCmd*(args: Args): string =
return args.cmd.get(@[getEnv("SHELL", "/bin/bash")]) return args.cmd.get(getEnv("SHELL", "/bin/bash"))
proc getProfile*(args: Args): string = proc getProfile*(args: Args): string =
if args.profile.isSome: if args.profile.isSome:
@@ -15,27 +16,30 @@ proc getProfile*(args: Args): string =
return "default" return "default"
proc parseOpt(args: var Args, key: string, value: string): bool =
case key
of "command", "c":
args.cmd = some(value)
of "profile", "p":
args.profile = some(value)
else:
return false
return true
proc parseArgs*(): Option[Args] = proc parseArgs*(): Option[Args] =
var p = initOptParser()
var args = Args() var args = Args()
var command = newSeq[string]() while true:
var i = 1 p.next()
case p.kind
while i <= paramCount(): of cmdEnd: break
var arg = paramStr(i) of cmdShortOption, cmdLongOption:
if p.val == "" or args.parseOpt(p.key, p.val) == false:
if arg == "--name": echo "Invalid argument ", p.val
args.name = some(paramStr(i + 1)) return
i += 2 of cmdArgument:
elif arg == "--profile": args.name = some(p.key.string)
args.profile = some(paramStr(i + 1))
i += 2
else:
echo arg
command.add(arg)
i += 1
if command.len > 0:
args.cmd = some(command)
return some(args) return some(args)

View File

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

View File

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

View File

@@ -1,26 +0,0 @@
#!/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=bwshell --name '$file' --profile gui /gi" "$application" > "$target/$file"
done
}
dirs=("/usr/share/applications" "$HOME/.local/share/applications")
target="$1"
mkdir -p "$target"
for dir in "${dirs[@]}"; do
check_dir "$dir"
done