mirror of
https://github.com/stashapp/stash.git
synced 2026-03-31 18:42:06 +02:00
* Add reveal in file manager button to file info panel Adds a folder icon button next to the path field in the Scene, Image, and Gallery file info panels. Clicking it calls a new GraphQL mutation that opens the file's enclosing directory in the system file manager (Finder on macOS, Explorer on Windows, xdg-open on Linux). Also fixes the existing revealInFileManager implementations which were constructing exec.Command but never calling Run(), making them no-ops: - darwin: add Run() to open -R - windows: add Run() and fix flag from \select to /select,<path> - linux: implement with xdg-open on the parent directory - desktop.go: use os.Stat instead of FileExists so folders work too * Disallow reveal operation if request not from loopback --------- Co-authored-by: 1509x <1509x@users.noreply.github.com> Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
//go:build unix && !darwin
|
|
// +build unix,!darwin
|
|
|
|
package desktop
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/stashapp/stash/pkg/logger"
|
|
)
|
|
|
|
// isService checks if started by init, e.g. stash is a *nix systemd service
|
|
func isService() bool {
|
|
return os.Getppid() == 1
|
|
}
|
|
|
|
func isServerDockerized() bool {
|
|
_, dockerEnvErr := os.Stat("/.dockerenv")
|
|
cgroups, _ := os.ReadFile("/proc/self/cgroup")
|
|
if !os.IsNotExist(dockerEnvErr) || strings.Contains(string(cgroups), "docker") {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func sendNotification(notificationTitle string, notificationText string) {
|
|
err := exec.Command("notify-send", "-i", getIconPath(), notificationTitle, notificationText, "-a", "Stash").Run()
|
|
if err != nil {
|
|
logger.Errorf("Error sending notification on Linux: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func revealInFileManager(path string, info os.FileInfo) error {
|
|
dir := path
|
|
if !info.IsDir() {
|
|
dir = filepath.Dir(path)
|
|
}
|
|
if err := exec.Command("xdg-open", dir).Run(); err != nil {
|
|
return fmt.Errorf("error opening directory in file manager: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func isDoubleClickLaunched() bool {
|
|
return false
|
|
}
|
|
|
|
func hideConsole() {
|
|
|
|
}
|