-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactions_linux.go
More file actions
49 lines (43 loc) · 1.15 KB
/
actions_linux.go
File metadata and controls
49 lines (43 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//go:build linux
// +build linux
package main
import (
"bytes"
"os/exec"
)
func (as *ActionService) ShowNotification(title, message string) error {
// Try notify-send (most common on Linux)
cmd := exec.Command("notify-send", title, message)
return cmd.Run()
}
func (as *ActionService) OpenURL(url string) error {
cmd := exec.Command("xdg-open", url)
return cmd.Start()
}
func (as *ActionService) SetClipboard(content string) error {
// Try xclip first, then xsel as fallback
cmd := exec.Command("xclip", "-selection", "clipboard")
cmd.Stdin = bytes.NewBufferString(content)
err := cmd.Run()
if err != nil {
// Fallback to xsel
cmd = exec.Command("xsel", "--clipboard", "--input")
cmd.Stdin = bytes.NewBufferString(content)
return cmd.Run()
}
return nil
}
func (as *ActionService) GetClipboard() (string, error) {
// Try xclip first, then xsel as fallback
cmd := exec.Command("xclip", "-selection", "clipboard", "-o")
output, err := cmd.Output()
if err != nil {
// Fallback to xsel
cmd = exec.Command("xsel", "--clipboard", "--output")
output, err = cmd.Output()
if err != nil {
return "", err
}
}
return string(output), nil
}