Refactor xdg_open as function