From c8223147f5535eb954651d0a4b171c609732004f Mon Sep 17 00:00:00 2001 From: Ezri Date: Wed, 3 Apr 2024 09:49:40 -0600 Subject: [PATCH] added application launcher arguments support --- .config/sway/workspaces.json##hostname.rocinante | 8 +++++--- .local/bin/default-application-launcher | 12 ++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.config/sway/workspaces.json##hostname.rocinante b/.config/sway/workspaces.json##hostname.rocinante index 26f91b5..d13e73d 100644 --- a/.config/sway/workspaces.json##hostname.rocinante +++ b/.config/sway/workspaces.json##hostname.rocinante @@ -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" }, diff --git a/.local/bin/default-application-launcher b/.local/bin/default-application-launcher index ab5a5f8..d9a4c0b 100755 --- a/.local/bin/default-application-launcher +++ b/.local/bin/default-application-launcher @@ -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