yad tray icon crashes, but works when run from VSCode

59 views Asked by At

I am on Ubuntu 22.04. This following bash script:

#!/bin/bash

# stop on error (always good practice)
set -e 

# create a FIFO file, used to manage the I/O redirection from shell
PIPE=$(mktemp -u --tmpdir ${0##*/}.XXXXXXXX)
mkfifo $PIPE
export PIPE

# attach a file descriptor to the file
exec 3<> $PIPE

# add handler to manage process shutdown
function on_exit() {
    # send command to yad through pipe
    echo "quit" >&3
    rm -f $PIPE
}
trap on_exit EXIT
   
# create the notification icon
yad --notification                  \
    --listen                        \
    --image="/path/to/icon" <&3 &

while true; do 
    sleep 60
done

works just fine when running it from the built in vscode terminal. However when i open a gnome terminal and run the same command (./yad-debug.sh) or try to run it as a startup application I get:

(yad:29692): Gtk-CRITICAL **: 15:21:14.013: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed

I tried changing environment variables to match what VSCode has but nothing changed. As you can see it is also specified that it should be run with /bin/bash, so that should not be an issue either. If there is any further information that would help, I will gladly share it.

Here is the diff of running set from vscode and running set from gnome-terminal:

198d197
< _=
284,315d282
< { 
< { 
< { 
< { 
< { 
< { 
< { 
< { 
< { 
< { 
< { 
< { 
< { 
< { 
< { 
< { 
< }
< }
< }
< }
< }
< }
< }
< }
< }
< }
< }
< }
< }
< }
< }
< }
521d487
< BASH_COMMAND='set > ~/Documents/vscode.env'
526d491
< BASH_REMATCH=()
543,557d507
<     builtin eval "terms=( $(trap -p "${1:-DEBUG}") )";
<     builtin local -a terms;
<     builtin local LC_ALL=C str="${1}" i byte token out='';
<     builtin printf '\e]633;A\a'
<     builtin printf '\e]633;B\a'
<     builtin printf '\e]633;C\a';
<         builtin printf '\e]633;D\a';
<         builtin printf '\e]633;D;%s\a' "$__vsc_status";
<     builtin printf '\e]633;E;%s;%s\a' "$(__vsc_escape_value "${__vsc_current_command}")" $__vsc_nonce
<     builtin printf '\e]633;F\a'
<     builtin printf '\e]633;G\a'
<     builtin printf '\e]633;P;Cwd=%s\a' "$(__vsc_escape_value "$PWD")"
<     builtin printf '%s' "${terms[2]:-}"
<     builtin printf '%s\n' "${out}"
<         byte="${str:$i:1}";
602d551
< CHROME_DESKTOP=code-url-handler.desktop
605c554
< COLUMNS=138
---
> COLUMNS=80
838,839d786
<     do
<     do
896,897d842
<     done;
<     done;
947,948d891
<             else
<         else
971,973d913
<         else
<     else
<     else
1042d981
<         eval "${cmd:-}";
1118d1056
<             fi;
1155,1159d1092
<         fi;
<         fi;
<         fi;
<         fi;
<     fi
1182,1184d1114
<     fi
<     fi;
<     fi;
1254d1183
<     for cmd in "${__vsc_original_prompt_command[@]}";
1262d1190
<     for ((i=0; i < "${#str}"; ++i ))
1299d1226
< GDK_BACKEND=x11
1311,1312d1237
< GIO_LAUNCHED_DESKTOP_FILE_PID=9235
< GIO_LAUNCHED_DESKTOP_FILE=/usr/share/applications/code.desktop
1314d1238
< GIT_ASKPASS=/usr/share/code/resources/app/extensions/git/dist/askpass.sh
1341,1342d1264
< GJS_DEBUG_OUTPUT=stderr
< GJS_DEBUG_TOPICS='JS ERROR;JS LOG'
1345a1268,1269
> GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/5de6f03d_baec_4b5b_90c9_0e17b9fa9894
> GNOME_TERMINAL_SERVICE=:1.810
1358a1283
> _=/home/simon/.cargo/env
1393d1317
<     if [[ ! "$BASH_COMMAND" =~ ^__vsc_prompt* ]]; then
1396,1397d1319
<             if [ "$byte" = ";" ]; then
<         if [ "$byte" = "\\" ]; then
1459,1464d1380
<     if [ "$__vsc_current_command" = "" ]; then
<         if [[ "$__vsc_custom_PS1" == "" || "$__vsc_custom_PS1" != "$PS1" ]]; then
<         if [[ "$__vsc_custom_PS2" == "" || "$__vsc_custom_PS2" != "$PS2" ]]; then
<         if [ "$__vsc_history_verify" = "1" ]; then
<     if [ "$__vsc_in_command_execution" = "0" ]; then
<     if [ "$__vsc_in_command_execution" = "1" ]; then
1575d1490
< IM_CONFIG_CHECK_ENV=1
1594d1508
< INVOCATION_ID=da802a91e49b408ea31998f9b2c352a8
1602d1515
< JOURNAL_STREAM=8:31235
1638c1551
< LINES=15
---
> LINES=24
1824d1736
< MANAGERPID=1657
1875d1786
< ORIGINAL_XDG_CURRENT_DESKTOP=ubuntu:GNOME
1877d1787
<         out+="$token";
1898c1808
< PATH=/home/simon/.local/bin:/home/simon/.cargo/bin:/home/simon/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
---
> PATH=/home/simon/.cargo/bin:/home/simon/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
1907c1817
< PPID=9800
---
> PPID=62895
1948,1949d1857
< PROMPT_COMMAND=__vsc_prompt_cmd
< PS1=$'\\[\E]633;A\a\\]\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ \\[\E]633;B\a\\]'
1952c1860
<             PS1="$__vsc_custom_PS1";
---
> PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
1955,1956c1863
< PS2=$'\\[\E]633;F\a\\]> \\[\E]633;G\a\\]'
<             PS2="$__vsc_custom_PS2";
---
> PS2='> '
1962c1869
< PWD='/home/simon/Zoho WorkDrive (Kriele)/My Folders/coding/bash'
---
> PWD=/home/simon
2014d1920
<     return "$1"
2113c2019
< SYSTEMD_EXEC_PID=1884
---
> SYSTEMD_EXEC_PID=2040
2121,2122d2026
< TERM_PROGRAM_VERSION=1.83.1
< TERM_PROGRAM=vscode
2133,2135d2036
<             token="\\\\";
<                 token="$byte";
<                 token="\\x3b";
2192,2245c2093
< __vsc_command_complete () 
<     __vsc_command_complete "$__vsc_status";
<     __vsc_command_output_start
< __vsc_command_output_start () 
< __vsc_continuation_end () 
< __vsc_continuation_start () 
<         __vsc_current_command="";
<     __vsc_current_command="";
<             __vsc_current_command=$BASH_COMMAND;
<             __vsc_current_command="$(builtin history 1 | sed 's/ *[0-9]* *//')";
< __vsc_current_command='set > ~/Documents/vscode.env'
< __vsc_custom_PS1=$'\\[\E]633;A\a\\]\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ \\[\E]633;B\a\\]'
<             __vsc_custom_PS1="\[$(__vsc_prompt_start)\]$__vsc_original_PS1\[$(__vsc_prompt_end)\]";
< __vsc_custom_PS2=$'\\[\E]633;F\a\\]> \\[\E]633;G\a\\]'
<             __vsc_custom_PS2="\[$(__vsc_continuation_start)\]$__vsc_original_PS2\[$(__vsc_continuation_end)\]";
< __vsc_dbg_trap=
< __vsc_escape_value () 
< __vsc_get_trap () 
< __vsc_history_verify=0
<         __vsc_in_command_execution="0";
<         __vsc_in_command_execution="1";
< __vsc_in_command_execution=1
<     __vsc_initialized=1;
< __vsc_initialized=1
< __vsc_nonce=f9d9fe6a-77d1-48c1-9ea1-40770118ec5c
< VSCODE_GIT_ASKPASS_EXTRA_ARGS=--ms-enable-electron-run-as-node
< VSCODE_GIT_ASKPASS_MAIN=/usr/share/code/resources/app/extensions/git/dist/askpass-main.js
< VSCODE_GIT_ASKPASS_NODE=/usr/share/code/code
< VSCODE_GIT_IPC_HANDLE=/run/user/1000/vscode-git-b4e1450751.sock
< VSCODE_SHELL_INTEGRATION=1
< __vsc_original_prompt_command=
<             __vsc_original_PS1=$PS1;
< __vsc_original_PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
< __vsc_original_PS2='> '
<             __vsc_original_PS2=$PS2;
<     __vsc_precmd
<     __vsc_precmd
< __vsc_precmd () 
<         __vsc_preexec;
< __vsc_preexec () 
< __vsc_preexec_only () 
< __vsc_prompt_cmd () 
< __vsc_prompt_cmd_original () 
< __vsc_prompt_end () 
< __vsc_prompt_start () 
< __vsc_restore_exit_code () 
<     __vsc_restore_exit_code "${__vsc_status}";
<     __vsc_status="$?";
<     __vsc_status="$?";
< __vsc_status=0
<     __vsc_update_cwd
< __vsc_update_cwd () 
<     __vsc_update_prompt
< __vsc_update_prompt () 
---
> VTE_VERSION=6800
2283c2131
< XDG_CURRENT_DESKTOP=Unity
---
> XDG_CURRENT_DESKTOP=ubuntu:GNOME
0

There are 0 answers