application launcher now has support for environment variables

This commit is contained in:
Ezri 2024-03-25 12:15:08 -06:00
parent d6250a459d
commit f0de9b9111
Signed by: ezri
GPG Key ID: 058A78E5680C6F24
2 changed files with 18 additions and 4 deletions

View File

@ -4,25 +4,31 @@
{
"index": 1,
"name": "terminal",
"exec": "alacritty",
"exec": "console",
"program_name": "console"
},
{
"index": 2,
"name": "code",
"exec": "alacritty",
"exec": "console",
"program_name": "console"
},
{
"index": 3,
"name": "internet",
"exec": "env MOZ_ENABLE_WAYLAND=0 firefox --new-window",
"exec": "firefox --new-window",
"environ": {
"MOZ_ENABLE_WAYLAND": "1"
},
"program_name": "firefox"
},
{
"index": 4,
"name": "project",
"exec": "env MOZ_ENABLE_WAYLAND=0 firefox --new-window",
"exec": "firefox --new-window",
"environ": {
"MOZ_ENABLE_WAYLAND": "1"
},
"program_name": "firefox"
},
{

View File

@ -15,6 +15,7 @@ program_name=$(echo $ws_data | jq -r '.program_name')
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))
systemd_run_args=""
@ -37,8 +38,15 @@ fi
echo "Launching application $program"
if [[ $environ != "" ]]; then
for env in $environ; do
export $env
done
fi
if [[ $program == "console" ]] && [[ $pty == "alacritty" ]]; then
# Create a new window if an instance is already running, otherwise start the service
echo "Creating new alacritty window"
$pty msg create-window || /usr/bin/systemctl --user start alacritty.service
exit 0
elif [[ $program == "console" ]]; then