-
Notifications
You must be signed in to change notification settings - Fork 65
Add support for flatpak versions of MPV and VLC #188
Conversation
Added support for official flatpak versions of VLC and mpv
Thank you for the pull request! I looked over your code and I think we can accomplish working with flatpaks in a simpler way. Instead of flatpak being a boolean, make it the flatpak app ID, then we can use a similar mechanism we use for the windows registry. Roughly like this for _, c := range commands {
_, err := exec.LookPath(c.Command[0])
if err == nil {
store.Commands = append(store.Commands, c)
} else if c, found := checkRegistry(c); found {
store.Commands = append(store.Commands, c)
} else if c, found := checkFlatpak(c); found {
store.Commands = append(store.Commands, c)
}
} Then add
func checkFlatpak(c Command) (Command, bool) {
if c.flatpakAppID == "" {
// no flatpak app ID specified
return c, false
}
_, err := exec.LookPath("flatpak")
if err != nil {
// flatpak not installed
return c, false
}
err := exec.Command("flatpak", "info", c.flatpakAppID).Run()
if err != nil {
// not installed
return c, false
}
c.Command[0] = c.flatpakAppID
c.Command = append([]string{"flatpak", "run"}, c.Command...)
return c, true
} What do you think? |
Your solution was definitely cleaner than mine, I added the method with a small title change to func checkFlatpak(c Command) (Command, bool) {
if c.flatpakAppID == "" {
// command is not flatpak
return c, false
}
_, err := exec.LookPath("flatpak")
if err != nil {
// flatpak not installed
return c, false
}
err = exec.Command("flatpak", "info", c.flatpakAppID).Run()
if err != nil {
// package not installed
return c, false
}
c.Command[0] = c.flatpakAppID
c.Command = append([]string{"flatpak", "run"}, c.Command...)
// optional update title
c.Title = c.Title + " Flatpak"
return c, true
} As for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added two comments. Please also resolve your conflicts / rebase your branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the contribution :)
This change adds detection and execution support for Flatpak versions of mpv and VLC on Linux.