Instead of checking if $HOME and / has permissions, check if ~/.local/share/gpu-screen-recorder has permission by going up the tree, checking ~/.local/share/gpu-screen-recorder and then ~/.local/share and so on, until /.