Compare commits
15 commits
Author | SHA1 | Date | |
---|---|---|---|
1b5b96a10f | |||
64629c2d23 | |||
Simon Vieille | 64908e4eb4 | ||
Simon Vieille | 7057a29f6d | ||
Simon Vieille | 7dded95ca0 | ||
Simon Vieille | b395a13e00 | ||
Simon Vieille | b8ad31e366 | ||
Simon Vieille | bc2a4b3453 | ||
Simon Vieille | fcd69a98a0 | ||
Simon Vieille | eb82aba33c | ||
Simon Vieille | 039bb2c2b1 | ||
Simon Vieille | 251a5a11e3 | ||
Simon Vieille | 8367740348 | ||
Simon Vieille | dc1ded5546 | ||
Simon Vieille | 2cd37bbda4 |
|
@ -1,4 +1,4 @@
|
|||
pipeline:
|
||||
steps:
|
||||
vendor:
|
||||
image: golang:1.18
|
||||
commands:
|
||||
|
@ -8,6 +8,9 @@ pipeline:
|
|||
image: golang:1.18
|
||||
commands:
|
||||
- make
|
||||
- mkdir release
|
||||
- tar -c -z -f release/build-amd64.tar.gz build/linux-amd64/
|
||||
- tar -c -z -f release/build-arm64.tar.gz build/linux-arm64/
|
||||
|
||||
release:
|
||||
image: plugins/gitea-release
|
||||
|
@ -16,6 +19,6 @@ pipeline:
|
|||
from_secret: gitnet_api_key
|
||||
base_url: https://gitnet.fr
|
||||
note:
|
||||
files: build/*
|
||||
files: release/*
|
||||
when:
|
||||
event: [tag]
|
||||
|
|
14
Makefile
14
Makefile
|
@ -1,8 +1,16 @@
|
|||
all: linux-amd64 linux-arm64
|
||||
|
||||
.ONESHELL:
|
||||
all:
|
||||
linux-amd64:
|
||||
for i in blocks/*; do
|
||||
go build -ldflags '-s -w' -v -o "build/$$(basename "$$i")" "$$i/main.go"
|
||||
GOARCH=amd64 GOOS=linux go build -ldflags '-s -w' -v -o "build/linux-amd64/$$(basename "$$i")" "$$i/main.go"
|
||||
done
|
||||
|
||||
.ONESHELL:
|
||||
linux-arm64:
|
||||
for i in blocks/*; do
|
||||
GOARCH=arm64 GOOS=linux go build -ldflags '-s -w' -v -o "build/linux-arm64/$$(basename "$$i")" "$$i/main.go"
|
||||
done
|
||||
|
||||
clean:
|
||||
rm build/* 2>/dev/null || true
|
||||
rm -fr build/* 2>/dev/null || true
|
||||
|
|
28
README.md
28
README.md
|
@ -55,7 +55,7 @@ interval=1000
|
|||
|
||||
### Date
|
||||
|
||||
Show the time using given format.
|
||||
Show the time using the given format.
|
||||
|
||||
```
|
||||
[time]
|
||||
|
@ -187,6 +187,18 @@ markup=pango
|
|||
interval=1
|
||||
```
|
||||
|
||||
### Weather
|
||||
|
||||
Show the weather of the given location ([https://fr.wttr.in/](https://fr.wttr.in/)).
|
||||
|
||||
```
|
||||
[weather]
|
||||
command=/path/to/weather -loc=Paris -lang=fr
|
||||
format=json
|
||||
markup=pango
|
||||
interval=1800
|
||||
```
|
||||
|
||||
### Wireguard toggler
|
||||
|
||||
Toggler for wireguard.
|
||||
|
@ -205,22 +217,14 @@ markup=pango
|
|||
interval=2
|
||||
```
|
||||
|
||||
### Task bar
|
||||
### Workspace Apps (task bar)
|
||||
|
||||
Add blocks that represent opened apps and create a task bar.
|
||||
|
||||
```
|
||||
[workspace_apps_0]
|
||||
command=/path/to/workspace_apps 0 $BLOCK_BUTTON
|
||||
[workspace_apps]
|
||||
command=/path/to/workspace_apps -x=$relative_x
|
||||
format=json
|
||||
markup=pango
|
||||
interval=1
|
||||
|
||||
[workspace_apps_1]
|
||||
command=/path/to/workspace_apps 1 $BLOCK_BUTTON
|
||||
format=json
|
||||
markup=pango
|
||||
interval=1
|
||||
|
||||
...
|
||||
```
|
||||
|
|
|
@ -2,10 +2,16 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
||||
"os"
|
||||
"os/exec"
|
||||
sos"
|
||||
"os/"
|
||||
"strings"
|
||||
|
||||
r "gitnet.fr/deblan/i3-blocks-gsrrindg
|
||||
r "gitnet.fr/deblan/i3-blocks-gsrrindg
|
||||
r "gitnet.fr/deblan/i3-blocks-gsrrindg
|
||||
r "gitnet.fr/deblan/i3-blocks-gsrrindg
|
||||
r "gitnet.fr/deblan/i3-blocks-gsrrindg
|
||||
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
||||
)
|
||||
|
||||
func GetMetadata(metadata string) string {
|
||||
|
@ -20,11 +26,15 @@ func GetMetadata(metadata string) string {
|
|||
}
|
||||
|
||||
func GetTitle() string {
|
||||
return GetMetadata("xesam:title")
|
||||
data := GetMetadata("xesam:title")
|
||||
|
||||
return strings.Trim(string(data), "\n")
|
||||
}
|
||||
|
||||
func GetArtist() string {
|
||||
return GetMetadata("xesam:artist")
|
||||
data := GetMetadata("xesam:artist")
|
||||
|
||||
return strings.Trim(string(data), "\n")
|
||||
}
|
||||
|
||||
func GetStatus() string {
|
||||
|
@ -41,6 +51,8 @@ func main() {
|
|||
|
||||
if status == "Not available" {
|
||||
return
|
||||
} else if status == "Stopped" {
|
||||
return
|
||||
} else if status == "Paused" {
|
||||
stmt = r.TextWithPadding(r.FontAwesome("\uf04c"), r.FB{
|
||||
Background: r.Color("black3"),
|
||||
|
|
58
blocks/weather/main.go
Normal file
58
blocks/weather/main.go
Normal file
|
@ -0,0 +1,58 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func openBrowser(wg *sync.WaitGroup, url string) {
|
||||
defer wg.Done()
|
||||
command := exec.Command("tmux", "new", "-d", "xdg-open", url)
|
||||
command.Run()
|
||||
}
|
||||
|
||||
func main() {
|
||||
var wg sync.WaitGroup
|
||||
|
||||
argLocation := flag.String("loc", "", "location")
|
||||
argLang := flag.String("lang", "fr", "lang")
|
||||
flag.Parse()
|
||||
|
||||
url := fmt.Sprintf("https://%s.wttr.in/%s?format=%%l+%%c+%%t+%%m", *argLang, *argLocation)
|
||||
|
||||
if os.Getenv("BLOCK_BUTTON") == "1" {
|
||||
url2 := fmt.Sprintf("https://%s.wttr.in/%s", *argLang, *argLocation)
|
||||
wg.Add(1)
|
||||
go openBrowser(&wg, url2)
|
||||
}
|
||||
|
||||
resp, err := http.Get(url)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
content := string(body)
|
||||
|
||||
fb := r.FB{
|
||||
Foreground: r.Color("white1"),
|
||||
Background: r.Color("black2"),
|
||||
}
|
||||
|
||||
content = strings.ReplaceAll(content, " ", " ")
|
||||
options := r.NewBlockOptions()
|
||||
options.FullText = r.TextWithPadding(content, fb)
|
||||
block := r.Block("meteo", options)
|
||||
|
||||
fmt.Println(block)
|
||||
wg.Wait()
|
||||
}
|
|
@ -4,7 +4,8 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
||||
"os"
|
||||
// "os"
|
||||
"flag"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -117,50 +118,55 @@ func main() {
|
|||
tree := GetTree()
|
||||
nodes := GetVisibleNodes(tree, workspaces)
|
||||
|
||||
appNumber, _ := strconv.Atoi(os.Args[1])
|
||||
blockButton := ""
|
||||
argX := flag.String("x", "", "")
|
||||
flag.Parse()
|
||||
|
||||
for k, v := range os.Args {
|
||||
if k == 2 {
|
||||
blockButton = v
|
||||
}
|
||||
x := 0
|
||||
minX := 0
|
||||
|
||||
if *argX != "" {
|
||||
x, _ = strconv.Atoi(*argX)
|
||||
}
|
||||
|
||||
for key, app := range nodes {
|
||||
if key == appNumber {
|
||||
options := r.NewBlockOptions()
|
||||
|
||||
for _, app := range nodes {
|
||||
foreground := "#9cb7d1"
|
||||
background := "#222222"
|
||||
|
||||
title := strings.ToUpper(app.WindowProperties.Title)
|
||||
|
||||
if len(title) > 30 {
|
||||
title = fmt.Sprintf("%s…", title[0:29])
|
||||
}
|
||||
|
||||
size := (len(title) + 4) * 6
|
||||
maxX := minX + size
|
||||
isClicked := (x > minX && x < maxX)
|
||||
minX = maxX
|
||||
|
||||
if app.Urgent {
|
||||
foreground = "#ffffff"
|
||||
background = "#07c0d4"
|
||||
} else if app.Focused {
|
||||
} else if (app.Focused && x == 0) || isClicked {
|
||||
foreground = "#07c0d4"
|
||||
background = "#333333"
|
||||
} else if app.Output == "__i3" {
|
||||
foreground = "#bababa"
|
||||
}
|
||||
|
||||
if isClicked {
|
||||
Focus(app.Window)
|
||||
}
|
||||
|
||||
fb := r.FB{
|
||||
Foreground: foreground,
|
||||
Background: background,
|
||||
}
|
||||
|
||||
title := strings.ToUpper(app.WindowProperties.Title)
|
||||
|
||||
if len(title) > 25 {
|
||||
title = fmt.Sprintf("%s…", title[0:22])
|
||||
options.FullText = fmt.Sprintf("%s%s", options.FullText, r.TextWithPadding(title, fb))
|
||||
}
|
||||
|
||||
options := r.NewBlockOptions()
|
||||
options.FullText = r.TextWithPadding(title, fb)
|
||||
block := r.Block(fmt.Sprintf("workspace_apps_%d", appNumber), options)
|
||||
|
||||
block := r.Block("workspace_apps", options)
|
||||
fmt.Println(block)
|
||||
|
||||
if blockButton == "1" {
|
||||
Focus(app.Window)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package rendering
|
||||
|
||||
import (
|
||||
// "bytes"
|
||||
"encoding/json"
|
||||
// "strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -31,6 +33,7 @@ func Block(name string, options BlockOptions) string {
|
|||
|
||||
block = strings.ReplaceAll(block, `\u003c`, "<")
|
||||
block = strings.ReplaceAll(block, `\u003e`, ">")
|
||||
block = strings.ReplaceAll(block, `\u0026`, "et")
|
||||
|
||||
return block
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue