I tried this but it still gives me error with filename with ', even if I escaped the whole command, how's that possible?
\ true &&
\ app=$(su -c 'xdg-mime query default $(xdg-mime query filetype %f)' $USER);
\ appcmd=$(cat /usr/share/applications/$app | grep -oP '(?<=^Exec=).*' | awk '{print $1}');
\ su -c "$appcmd %f %i" $USER
edit it like this still present the same symptoms:
\ su -c "$(printf '%%q ' $appcmd %f %i)" $USER
the error it gives is
parse error near `)'
and it popups only with filename '
edit: I think it has something to do with the first %f at this point, I'll try that way
edit2: that was it! it finally works now with double quotes! thank for your guidance as always
\ true &&
\ app=$(su -c "xdg-mime query default $(xdg-mime query filetype %f)" $USER);
\ appcmd=$(cat /usr/share/applications/$app | grep -oP '(?<=^Exec=).*' | awk '{print $1}');
\ su -c "$appcmd %f %i" $USER