Skip to content

Instantly share code, notes, and snippets.

@apedicdev
Last active July 31, 2024 07:56
Show Gist options
  • Save apedicdev/337518cefea1a2477be8f43c333f1438 to your computer and use it in GitHub Desktop.
Save apedicdev/337518cefea1a2477be8f43c333f1438 to your computer and use it in GitHub Desktop.
This script specifically updates the Exec line for Google Chrome to include additional flags for enabling Ozone platform and touchpad overscroll history navigation.
#!/bin/bash
modify_desktop_entry() {
local file="$1"
local tmpfile=$(mktemp)
local pattern='^Exec=/opt/google/chrome/google-chrome'
if ! [[ -f "$file" ]]; then
printf "File not found: %s\n" "$file" >&2
return 1
fi
while IFS= read -r line; do
if [[ $line =~ $pattern ]]; then
printf "%s --enable-features=UseOzonePlatform,TouchpadOverscrollHistoryNavigation --ozone-platform=wayland\n" "$line" >> "$tmpfile"
else
printf "%s\n" "$line" >> "$tmpfile"
fi
done < "$file"
mv "$tmpfile" "$file"
}
main() {
local files=("$@")
if [[ ${#files[@]} -eq 0 ]]; then
printf "Usage: %s <file1> <file2> ...\n" "${0##*/}" >&2
return 1
fi
for file in "${files[@]}"; do
if ! modify_desktop_entry "$file"; then
printf "Failed to modify: %s\n" "$file" >&2
continue
fi
done
}
main "$@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment