upload dialog API.

This commit is contained in:
Miroslav Šedivý
2021-01-17 23:50:03 +01:00
parent 98dc08cba9
commit 2b3bb6e21a
4 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,58 @@
package desktop
import (
"os/exec"
)
func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
mu.Lock()
defer mu.Unlock()
// TOOD: Use native API.
cmd := exec.Command(
"xdotool",
"search", "--name", "Open", "windowfocus",
"sleep", "0.2",
"key", "--clearmodifiers", "ctrl+l",
"type", "--args", "1", uri + "//",
"key", "--clearmodifiers", "Return",
"sleep", "1",
"key", "--clearmodifiers", "Down",
"key", "--clearmodifiers", "ctrl+a",
"key", "--clearmodifiers", "Return",
"sleep", "0.3",
)
_, err := cmd.Output()
return err
}
func (manager *DesktopManagerCtx) CloseFileChooserDialog() error {
mu.Lock()
defer mu.Unlock()
// TOOD: Use native API.
cmd := exec.Command(
"xdotool",
"search", "--name", "Open", "windowfocus",
"sleep", "0.2",
"key", "--clearmodifiers", "alt+f4",
)
_, err := cmd.Output()
return err
}
func (manager *DesktopManagerCtx) IsFileChooserDialogOpen() bool {
mu.Lock()
defer mu.Unlock()
// TOOD: Use native API.
cmd := exec.Command(
"xdotool",
"search", "--name", "Open", "windowfocus",
)
_, err := cmd.Output()
return err == nil
}