Skip to content

Commit

Permalink
Fix overwriting newly installed portals with disabled portals
Browse files Browse the repository at this point in the history
  • Loading branch information
pdamianik authored and fufexan committed Aug 16, 2023
1 parent e8194a9 commit d3f1a59
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pages/Useful Utilities/Hyprland-desktop-portal.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,21 @@ disable_portal() {
mv "$ENABLED_PORTAL_DIR/$1.portal" "$DISABLED_PORTAL_DIR/$1.portal"
}

remove_disabled_portal() {
rm "$DISABLED_PORTAL_DIR/$1.portal"
}

PORTAL=$1
ENABLE=${2:-$(is_portal_enabled "$PORTAL" && echo "disable" || echo "enable")}

if [ "$ENABLE" = "enable" ]; then
is_portal_disabled "$PORTAL" && enable_portal "$PORTAL"
if is_portal_enabled "$PORTAL"; then
# remove disabled portal if enabled portal exists as well,
# as the enabled portal is most likely a newly installed version
is_portal_disabled "$PORTAL" && remove_disabled_portal "$PORTAL"
else
is_portal_disabled "$PORTAL" && enable_portal "$PORTAL"
fi
else
is_portal_enabled "$PORTAL" && disable_portal "$PORTAL"
fi
Expand Down

0 comments on commit d3f1a59

Please sign in to comment.