Simon Vieille
64e25430a2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
43 lines
679 B
Go
43 lines
679 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/atotto/clipboard"
|
|
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
|
"io"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
resp, err := http.Get("https://api.ipify.org/")
|
|
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
ip, _ := io.ReadAll(resp.Body)
|
|
|
|
label := r.TextWithPadding(
|
|
"wan",
|
|
r.FB{
|
|
Foreground: r.Color("grey1"),
|
|
Background: r.Color("black2"),
|
|
},
|
|
)
|
|
|
|
if os.Getenv("BLOCK_BUTTON") == "1" {
|
|
clipboard.WriteAll(string(ip))
|
|
}
|
|
|
|
value := r.TextWithPadding(string(ip), r.FB{})
|
|
options := r.NewBlockOptions()
|
|
options.FullText = fmt.Sprintf("%s%s", label, value)
|
|
|
|
block := r.Block("ip_wan", options)
|
|
|
|
fmt.Println(block)
|
|
}
|