2024-06-20 04:08:46 +01:00
|
|
|
// SPDX-FileCopyrightText: 2024 Dan Anglin <d.n.i.anglin@gmail.com>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2024-06-20 02:01:11 +01:00
|
|
|
package utilities
|
|
|
|
|
|
|
|
import (
|
2024-06-20 04:08:46 +01:00
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"os/exec"
|
2024-06-20 02:01:11 +01:00
|
|
|
"regexp"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetFQDN(url string) string {
|
|
|
|
r := regexp.MustCompile(`http(s)?:\/\/`)
|
|
|
|
|
|
|
|
return r.ReplaceAllString(url, "")
|
|
|
|
}
|
2024-06-20 04:08:46 +01:00
|
|
|
|
|
|
|
func OpenMedia(viewer, path string) error {
|
|
|
|
if viewer == "" {
|
|
|
|
return errors.New("the image viewer is not specified")
|
|
|
|
}
|
|
|
|
|
|
|
|
command := exec.Command(viewer, path)
|
|
|
|
|
|
|
|
if err := command.Start(); err != nil {
|
|
|
|
return fmt.Errorf("received an error after starting the image viewer: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|