Skip to content

Migrate desktop launchers' eos-google-chrome to Flathub Chrome#424

Merged
wjt merged 1 commit intomasterfrom
migrate-eos-google-chrome-2-flathub-chrome-in-launcher
Oct 8, 2025
Merged

Migrate desktop launchers' eos-google-chrome to Flathub Chrome#424
wjt merged 1 commit intomasterfrom
migrate-eos-google-chrome-2-flathub-chrome-in-launcher

Conversation

@starnight
Copy link
Contributor

Some desktop launchers execute eos-google-chrome which will run eos-apps Chrome as webapps. So, migrate them to use Flathub Chrome, too.

https://phabricator.endlessm.com/T26944

@starnight starnight requested a review from wjt October 7, 2025 10:54

def update_desktop_shortcut(path):
keyfile = GLib.KeyFile()
print("path: " + path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug print left here unintentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

def update_desktop_shortcut(path):
keyfile = GLib.KeyFile()
print("path: " + path)
keyfile.load_from_file(path, GLib.KeyFileFlags.NONE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.gtk.org/glib/flags.KeyFileFlags.html says, of both flags,

Use this flag if you plan to write the (possibly modified) contents of the key file back to a file

Suggested change
keyfile.load_from_file(path, GLib.KeyFileFlags.NONE)
keyfile.load_from_file(path, GLib.KeyFileFlags.KEEP_COMMENTS | GLib.KeyFileFlags.KEEP_TRANSLATIONS)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the information! Updated in the new commit.


groups, _ = keyfile.get_groups()
for group in groups:
exec_cmd = keyfile.get_string(group, "Exec")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unlikely but you should handle the exception raised if the Exec key does not exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Have not thought that the group may not have "Exec". Add the handler in the new commit.

Comment on lines +121 to +132
orig_data = textwrap.dedent(
"""
[Desktop Entry]
Exec=/usr/bin/eos-google-chrome --profile-directory=Default
"""
).lstrip()
expected_data = textwrap.dedent(
"""
[Desktop Entry]
Exec=/usr/bin/flatpak run com.google.Chrome --profile-directory=Default
"""
).lstrip()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
orig_data = textwrap.dedent(
"""
[Desktop Entry]
Exec=/usr/bin/eos-google-chrome --profile-directory=Default
"""
).lstrip()
expected_data = textwrap.dedent(
"""
[Desktop Entry]
Exec=/usr/bin/flatpak run com.google.Chrome --profile-directory=Default
"""
).lstrip()
orig_data = textwrap.dedent(
"""
# Comment
[Desktop Entry]
Name=Chrome
Name[en_GB]=Chrome, milord
Exec=/usr/bin/eos-google-chrome --profile-directory=Default
"""
).lstrip()
expected_data = textwrap.dedent(
"""
# Comment
[Desktop Entry]
Name=Chrome
Name[en_GB]=Chrome, milord
Exec=/usr/bin/flatpak run com.google.Chrome --profile-directory=Default
"""
).lstrip()

I believe this modified test would fail currently but would succeed with the changes I propose below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, added the multi language test in the new commit.

self.assertEqual(expected_data, new_data)


class TestUpdateDesktopShortcuts(BaseTestCase):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is an actual file from my system:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=YouTube
Exec=/usr/bin/eos-google-chrome "--profile-directory=Profile 1" --app-id=agimnkijcaahngcdmfeangaknmldooml
Icon=chrome-agimnkijcaahngcdmfeangaknmldooml-Profile_1
StartupWMClass=crx_agimnkijcaahngcdmfeangaknmldooml
Actions=Explore;Subscriptions

[Desktop Action Explore]
Name=Explore
Exec=/usr/bin/eos-google-chrome "--profile-directory=Profile 1" --app-id=agimnkijcaahngcdmfeangaknmldooml "--app-launch-url-for-shortcuts-menu-item=https://www.youtube.com/feed/explore?feature=app_shortcuts"

[Desktop Action Subscriptions]
Name=Subscriptions
Exec=/usr/bin/eos-google-chrome "--profile-directory=Profile 1" --app-id=agimnkijcaahngcdmfeangaknmldooml "--app-launch-url-for-shortcuts-menu-item=https://www.youtube.com/feed/subscriptions?feature=app_shortcuts"

I suggest you add this as a test case.

I think you should also test the case where there is a group that does not have an Exec= key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Added as the new commit.

Some desktop launchers execute eos-google-chrome which will run eos-apps
Chrome as webapps. So, migrate them to use Flathub Chrome, too.

https://phabricator.endlessm.com/T26944
@starnight starnight force-pushed the migrate-eos-google-chrome-2-flathub-chrome-in-launcher branch from a2eca7f to 5dba052 Compare October 8, 2025 06:55
@starnight starnight requested a review from wjt October 8, 2025 06:59
@wjt wjt merged commit 3681891 into master Oct 8, 2025
1 check passed
@wjt wjt deleted the migrate-eos-google-chrome-2-flathub-chrome-in-launcher branch October 8, 2025 08:04
@starnight
Copy link
Contributor Author

Thanks! And, cherry picked the commit to eos6.0 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants