Compare commits
5 Commits
354ba05faa
...
93d2163ce9
Author | SHA1 | Date |
---|---|---|
Martin | 93d2163ce9 | |
Martin | 1634321bd2 | |
Martin | 0bffb6ad35 | |
Martin | 9a3e36fcb1 | |
Martin | 9cad6fc050 |
|
@ -0,0 +1 @@
|
||||||
|
{"extends": "shell", "mountcwd": true}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"mount": [],
|
"mount": [],
|
||||||
"romount": ["/etc", "/var", "/usr", "/opt", ".oh-my-zsh", ".zsh", ".zshrc"],
|
"romount": ["/etc", "/var", "/usr", "/opt"],
|
||||||
"symlinks": [
|
"symlinks": [
|
||||||
{"src": "usr/lib", "dst": "/lib"},
|
{"src": "usr/lib", "dst": "/lib"},
|
||||||
{"src": "usr/lib64", "dst": "/lib64"},
|
{"src": "usr/lib64", "dst": "/lib64"},
|
|
@ -0,0 +1 @@
|
||||||
|
{"extends": "shell", "romount": [".gitconfig", ".gnupg", "/run/user/1000/gnupg", ".ssh/config"], "mountcwd": true, "mount": [".ssh/known_hosts"]}
|
|
@ -0,0 +1 @@
|
||||||
|
{"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/*"]}
|
|
@ -0,0 +1 @@
|
||||||
|
{"extends": "default", "romount": [".oh-my-zsh", ".zsh", ".zshrc", ".zshrc-local"], "sethostname": true}
|
51
lib/args.nim
51
lib/args.nim
|
@ -1,14 +1,13 @@
|
||||||
import parseopt
|
|
||||||
import options
|
import options
|
||||||
import os
|
import os
|
||||||
|
|
||||||
type Args* = object
|
type Args* = object
|
||||||
name*: Option[string]
|
name*: Option[string]
|
||||||
cmd*: Option[string]
|
cmd*: Option[seq[string]]
|
||||||
profile*: Option[string]
|
profile*: Option[string]
|
||||||
|
|
||||||
proc getCmd*(args: Args): string =
|
proc getCmd*(args: Args): seq[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:
|
||||||
|
@ -16,30 +15,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()
|
||||||
|
|
||||||
while true:
|
var command = newSeq[string]()
|
||||||
p.next()
|
var i = 1
|
||||||
case p.kind
|
|
||||||
of cmdEnd: break
|
|
||||||
of cmdShortOption, cmdLongOption:
|
|
||||||
if p.val == "" or args.parseOpt(p.key, p.val) == false:
|
|
||||||
echo "Invalid argument ", p.val
|
|
||||||
return
|
|
||||||
of cmdArgument:
|
|
||||||
args.name = some(p.key.string)
|
|
||||||
|
|
||||||
|
while i <= paramCount():
|
||||||
|
var arg = paramStr(i)
|
||||||
|
|
||||||
|
if arg == "--name":
|
||||||
|
args.name = some(paramStr(i + 1))
|
||||||
|
i += 2
|
||||||
|
elif arg == "--profile":
|
||||||
|
args.profile = some(paramStr(i + 1))
|
||||||
|
i += 2
|
||||||
|
else:
|
||||||
|
echo arg
|
||||||
|
command.add(arg)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
if command.len > 0:
|
||||||
|
args.cmd = some(command)
|
||||||
|
|
||||||
|
if args.name.isSome or args.cmd.isSome or args.profile.isSome:
|
||||||
return some(args)
|
return some(args)
|
||||||
|
else:
|
||||||
|
return none(Args)
|
||||||
|
|
|
@ -15,9 +15,19 @@ proc checkRelativePath*(p: string): string =
|
||||||
getHomeDir().joinPath(p)
|
getHomeDir().joinPath(p)
|
||||||
|
|
||||||
proc getProfilePath*(profile: string): string =
|
proc getProfilePath*(profile: string): string =
|
||||||
getConfigDir()
|
let pid = getCurrentProcessId()
|
||||||
.joinPath(APP_NAME)
|
|
||||||
.joinPath(profile)
|
for path in [
|
||||||
|
getConfigDir().joinPath(APP_NAME),
|
||||||
|
&"/usr/share/{APP_NAME}",
|
||||||
|
parentDir(expandSymlink(&"/proc/{pid}/exe")).joinPath("configs")
|
||||||
|
]:
|
||||||
|
let file = path.joinPath(profile)
|
||||||
|
|
||||||
|
if fileExists(file):
|
||||||
|
return file
|
||||||
|
|
||||||
|
raise newException(IOError, "Profile not found")
|
||||||
|
|
||||||
proc getProfilePath*(args: Args): string =
|
proc getProfilePath*(args: Args): string =
|
||||||
getProfilePath(args.getProfile())
|
getProfilePath(args.getProfile())
|
||||||
|
|
2
main.nim
2
main.nim
|
@ -7,7 +7,7 @@ proc main(): int =
|
||||||
let args = parseArgs()
|
let args = parseArgs()
|
||||||
|
|
||||||
if args.isNone:
|
if args.isNone:
|
||||||
echo "Usage: bwshell --command=cmd --profile=profile <sandbox_name>"
|
echo "Usage: bwshell --name=sandbox_name --profile=profile <sandbox_cmd>"
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
randomize()
|
randomize()
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/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
|
Loading…
Reference in New Issue