You are not logged in.
Hi,
I have a script which execute rsync everytime I connect a pen drive to the pc.
Is it possible to show an icon in the plasma system tray when that script is running?
Last edited by Xwang (2021-01-28 11:48:58)
Offline
An internet search will lead you to...
https://www.maketecheasier.com/use-cust … ns-in-kde/
Offline
An internet search will lead you to...
https://www.maketecheasier.com/use-cust … ns-in-kde/
The link doesn't really answer the OP's question on how to trigger an icon in system tray on running his script. It just tells you how to use or modify a custom icon for the KDE apps already being used which is fairly straightforward.
Offline
Maybe using yad?
#!/bin/bash
yad --notification --image=terminal &
pid=${!}
sleep 10 # do stuff
kill ${pid}Last edited by karabaja4 (2021-01-27 15:27:22)
Offline
Maybe using yad?
#!/bin/bash yad --notification --image=terminal & pid=${!} sleep 10 # do stuff kill ${pid}
Thank you!
I'll try it as soon as possible!
Offline
Maybe using yad?
...
Won't that just show yad's icon in the plasma panel? OP could make a .desktop file in ~/.local/share/applications and assign a suitable icon to that.
Offline
Won't that just show yad's icon in the plasma panel? OP could make a .desktop file in ~/.local/share/applications and assign a suitable icon to that.
It will show the icon in the system tray defined via parameter, which I believe is what OP wanted
--image=terminalLast edited by karabaja4 (2021-01-27 16:25:17)
Offline
Little Go program that does this
// save as main.go
package main
import (
"io/ioutil"
"log"
"os"
"os/exec"
"github.com/getlantern/systray"
)
func main() {
// First Arg: Path to an image
icon := os.Args[1]
// Secord Arg: Path to a script, accepts arguments
script := os.Args[2]
// extra args
extra := os.Args[3:]
data, err := ioutil.ReadFile(icon)
if err != nil {
log.Fatal(err)
}
systray.SetIcon(data)
runner := func() {
cmd := exec.Command(script, extra...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
systray.Quit()
}
systray.Run(runner, nil)
}Install go and go-tools
Compile it with "go build -o traycon main.go "
Put the resulting traycon executable somewhere in your PATH
Now you can execute "traycon /path/to/an/icon.png /path/to/a/script.sh"
You can pass extra arguments if your script accepts them
Stdin Stdout Stderr all accessible
EDIT: you might need the gtk3 package if you don't have it
Last edited by ugjka (2021-01-27 17:24:46)
Offline
karabaja4 wrote:Maybe using yad?
#!/bin/bash yad --notification --image=terminal & pid=${!} sleep 10 # do stuff kill ${pid}Thank you!
I'll try it as soon as possible!
I confirm that this approach solved my issue.
Thank you very much.
Offline