added application launcher arguments support

This commit is contained in:
Ezri 2024-04-03 09:49:40 -06:00
parent 4caaf6d872
commit c8223147f5
Signed by: ezri
GPG Key ID: 058A78E5680C6F24
2 changed files with 13 additions and 7 deletions

View File

@ -16,16 +16,18 @@
{
"index": 3,
"name": "internet",
"exec": "firefox --new-window",
"exec": "firefox",
"args": ["--new-window"],
"environ": {
"MOZ_ENABLE_WAYLAND": "0"
"MOZ_ENABLE_WAYLAND": "1"
},
"program_name": "firefox"
},
{
"index": 4,
"name": "project",
"exec": "firefox --new-window",
"exec": "firefox",
"args": ["--new-window"],
"environ": {
"MOZ_ENABLE_WAYLAND": "0"
},

View File

@ -16,13 +16,15 @@ memory_profile=$(echo $ws_data | jq '.memory_profile' -c)
run_with_systemd=$(echo $ws_data | jq '.systemd' -r)
void_output=$(echo $ws_data | jq '.void_output' -r)
IFS=$'\n' environ=($(echo $ws_data | jq '.environ | to_entries | map("\(.key)=\(.value|tostring)") | .[]' -r 2> /dev/null))
IFS=$'\n' args=($(echo $ws_data | jq '.args | .[]' -r 2> /dev/null))
systemd_run_args=""
systemd_run_args=()
if [[ $memory_profile != "null" ]]; then
max_memory=$(echo $memory_profile | jq -r '.max')
high_memory=$(echo $memory_profile | jq -r '.high')
systemd_run_args+="--property=MemoryAccounting=yes --property=MemoryMax=${max_memory} --property=MemoryHigh=${high_memory}"
systemd_run_args+=("--property=MemoryAccounting=yes" "--property=MemoryMax=${max_memory}" "--property=MemoryHigh=${high_memory}")
fi
pty=alacritty
@ -41,7 +43,7 @@ echo "Launching application $program"
if [[ $environ != "" ]]; then
for env in $environ; do
echo "setting environment $env"
export $env
systemd_run_args+=("--setenv=$env")
done
fi
@ -73,4 +75,6 @@ fi
# Run programs using systemd-run to allow for resource control and capture of stdout/stderr
# We're using a service instead of a scope because scopes don't capture output, and wrapping
# the call in systemd-cat is more complicated than just using a service.
exec systemd-run --user $=systemd_run_args --unit="$program_name-$$" --description="$program_name" --slice=gui.slice -- $=program
echo exec systemd-run --user $=systemd_run_args --unit="$program_name-$$" --description="$program_name" --slice=gui.slice -- $program $args
exec systemd-run --user $=systemd_run_args --unit="$program_name-$$" --description="$program_name" --slice=gui.slice -- $program $args