Compare commits
21 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 | ||
Simon Vieille | f1771fe367 | ||
Simon Vieille | 42b76dd78d | ||
Simon Vieille | b3d57a5f94 | ||
Simon Vieille | 84fd3269cc | ||
Simon Vieille | 7ff5b31ce8 | ||
Simon Vieille | f63b3bf11c |
|
@ -1,4 +1,4 @@
|
||||||
pipeline:
|
steps:
|
||||||
vendor:
|
vendor:
|
||||||
image: golang:1.18
|
image: golang:1.18
|
||||||
commands:
|
commands:
|
||||||
|
@ -8,6 +8,9 @@ pipeline:
|
||||||
image: golang:1.18
|
image: golang:1.18
|
||||||
commands:
|
commands:
|
||||||
- make
|
- 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:
|
release:
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
|
@ -16,6 +19,6 @@ pipeline:
|
||||||
from_secret: gitnet_api_key
|
from_secret: gitnet_api_key
|
||||||
base_url: https://gitnet.fr
|
base_url: https://gitnet.fr
|
||||||
note:
|
note:
|
||||||
files: build/*
|
files: release/*
|
||||||
when:
|
when:
|
||||||
event: [tag]
|
event: [tag]
|
||||||
|
|
19
Makefile
19
Makefile
|
@ -1,13 +1,16 @@
|
||||||
|
all: linux-amd64 linux-arm64
|
||||||
|
|
||||||
.ONESHELL:
|
.ONESHELL:
|
||||||
all:
|
linux-amd64:
|
||||||
for i in blocks/*; do
|
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
|
done
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm build/* 2>/dev/null || true
|
rm -fr build/* 2>/dev/null || true
|
||||||
|
|
||||||
.ONESHELL:
|
|
||||||
run-code-quality-analysis:
|
|
||||||
export SONAR_TOKEN="$$SONAR_TOKEN_DEBLAN_I3_BLOCKS_GO"
|
|
||||||
sonar-scanner -Dsonar.projectKey=deblan-i3-blocks-go -Dsonar.sources=. -Dsonar.host.url="$$SONAR_SERVER"
|
|
||||||
|
|
167
README.md
167
README.md
|
@ -5,7 +5,7 @@ Blocks compatible with [i3blocks](https://github.com/vivien/i3blocks).
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* `go` for compilation
|
* `go` for compilation
|
||||||
* `sudo` for `wireguard` block
|
* `sudo` and `wg-quick` for `wireguard` block
|
||||||
* `tmux` for `app` and `date` blocks
|
* `tmux` for `app` and `date` blocks
|
||||||
* `df` for `du` block
|
* `df` for `du` block
|
||||||
* `xdg-open` for `du` block
|
* `xdg-open` for `du` block
|
||||||
|
@ -27,81 +27,204 @@ make
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
Each binary has a help, eg `./app -h`.
|
||||||
|
|
||||||
|
### App
|
||||||
|
|
||||||
Add the shortcut `<name>` and run `<command>` when clicked.
|
Add the shortcut `<name>` and run `<command>` when clicked.
|
||||||
|
|
||||||
```
|
```
|
||||||
app <block_name> <name> <command> <background_color> <foreground_color>
|
[app_otp]
|
||||||
|
command=/path/to/app -block=app_otp -name=🔐 -bg-color='#363636' -fg-color='#ffc337' -cmd=otpclient
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=1000
|
||||||
|
|
||||||
|
[app_flameshot]
|
||||||
|
command=/path/to/app -block=app_flameshot -name=F -bg-color='#bf007e' -fg-color='#fff' -cmd="flameshot gui --delay 500"
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=1000
|
||||||
|
|
||||||
|
[app_ksnip]
|
||||||
|
command=/path/to/app -block=app_youtube -name=Y -bg-color='#c74a42' -fg-color='#fff' -cmd="xdg-open https://www.youtube.com/"
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=1000
|
||||||
```
|
```
|
||||||
|
|
||||||
Show the time using given format and run `gnome-calendar` when clicked.
|
### Date
|
||||||
|
|
||||||
|
Show the time using the given format.
|
||||||
|
|
||||||
```
|
```
|
||||||
date -format="%H:%M:%S %d/%m/%Y"
|
[time]
|
||||||
|
command=/home/simon/www/repo/i3-blocks-go/build/date -format="%H:%M:%S %d/%m/%Y"
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=persist
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Disk usage
|
||||||
|
|
||||||
Show mount point usage and warns with limits and colors.
|
Show mount point usage and warns with limits and colors.
|
||||||
|
|
||||||
```
|
```
|
||||||
du -block=<block_name> -name=<name> -mount-point=<mount_point> -limit-warning=<limit_warning> -limit-danger=<limit_danger>
|
[du_root]
|
||||||
|
command=/path/to/du -block=du_root -mount-point=/ -name=root -limit-warning=70 -limit-danger=90
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=30
|
||||||
|
|
||||||
|
[du_home]
|
||||||
|
command=/path/to/du -block=du_home -mount-point=/home -name=home -limit-warning=90 -limit-danger=95
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=30
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### IP
|
||||||
|
|
||||||
Show the IP of the given iface.
|
Show the IP of the given iface.
|
||||||
|
|
||||||
```
|
```
|
||||||
ip -iface=<iface> -version=<ip4|ip6> -name=<name>
|
[ip_wg0_ip4]
|
||||||
|
command=/path/to/ip -iface=wg0 -version=ip4 -name=VPN
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=3
|
||||||
|
|
||||||
|
[ip_eth0_ip4]
|
||||||
|
command=/path/to/ip -iface=eth0 -version=ip4 -name=Foo
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=3
|
||||||
|
|
||||||
|
[ip_eth0_ip6]
|
||||||
|
command=/path/to/ip -iface=eth0 -version=ip4 -name=Bar
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### IP (wan)
|
||||||
|
|
||||||
Show the public IP.
|
Show the public IP.
|
||||||
|
|
||||||
```
|
```
|
||||||
ip_wan
|
[ip_wan]
|
||||||
|
command=/path/to/ip_wan
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=100
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Prusa telemetry
|
||||||
|
|
||||||
Show the telemetry using Prusa Printer API.
|
Show the telemetry using Prusa Printer API.
|
||||||
|
|
||||||
```
|
```
|
||||||
prusa_telemetry -api=http://1.2.3.4/api/telemetry
|
[prusa]
|
||||||
|
command=/path/to/prusa_telemetry -api=http://1.2.3.4/api/telemetry
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=60
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Process
|
||||||
|
|
||||||
Show a message when the given process is running (use `preg -f`).
|
Show a message when the given process is running (use `preg -f`).
|
||||||
|
|
||||||
```
|
```
|
||||||
ps -process=<process> -message=<message>
|
[ps]
|
||||||
|
command=/path/to/ps -process=foo -message="Foo is running"
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Feed indicator
|
||||||
|
|
||||||
Show indicator of RSS.
|
Show indicator of RSS.
|
||||||
|
|
||||||
```
|
```
|
||||||
rss -block=<block_name> -feed=<feed_url> -website=<feed_reader_url> -empty-color=<color> -non-empty-color=<color>
|
[rss_foo]
|
||||||
|
command=/path/to/rss -block=rss_foo -feed="https://foo.example.com/feed.xml" -website="https://foo.example.com/" -empty-color="#CCCCCC" -non-empty-color="#B3FF6C"
|
||||||
|
align=left
|
||||||
|
interval=30
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
|
||||||
|
[rss_bar]
|
||||||
|
command=/path/to/rss -block=rss_bar -feed="https://bar.example.com/atom.xml" -website="https://bar.example.com/" -empty-color="#aabfc1" -non-empty-color="#00d8f0"
|
||||||
|
align=left
|
||||||
|
interval=30
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Spotify status
|
||||||
|
|
||||||
Show current song played (spotify).
|
Show current song played (spotify).
|
||||||
|
|
||||||
```
|
```
|
||||||
spotify
|
[spotify]
|
||||||
|
command=/path/to/spotify
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Volume
|
||||||
|
|
||||||
Show volume.
|
Show volume.
|
||||||
|
|
||||||
```
|
```
|
||||||
volume -channel=<channel>
|
[volume]
|
||||||
|
command=/path/to/volume -channel=Master
|
||||||
|
format=json
|
||||||
|
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.
|
Toggler for wireguard.
|
||||||
|
|
||||||
```
|
```
|
||||||
wireguard -iface=<iface> -name=<name>
|
[wireguard_wg0]
|
||||||
|
command=/path/to/wireguard -iface=wg0 -name=Foo
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=2
|
||||||
|
|
||||||
|
[wireguard_wg1]
|
||||||
|
command=/path/to/wireguard -iface=wg1 -name=Bar
|
||||||
|
format=json
|
||||||
|
markup=pango
|
||||||
|
interval=2
|
||||||
```
|
```
|
||||||
|
|
||||||
Add a blocks that represent opened apps to create a task bar.
|
### Workspace Apps (task bar)
|
||||||
|
|
||||||
|
Add blocks that represent opened apps and create a task bar.
|
||||||
|
|
||||||
```
|
```
|
||||||
workspace_apps 0 $BLOCK_BUTTON
|
[workspace_apps]
|
||||||
workspace_apps 1 $BLOCK_BUTTON
|
command=/path/to/workspace_apps -x=$relative_x
|
||||||
workspace_apps 2 $BLOCK_BUTTON
|
format=json
|
||||||
workspace_apps 3 $BLOCK_BUTTON
|
markup=pango
|
||||||
workspace_apps 4 $BLOCK_BUTTON
|
interval=1
|
||||||
workspace_apps 5 $BLOCK_BUTTON
|
|
||||||
workspace_apps 6 $BLOCK_BUTTON
|
|
||||||
workspace_apps 7 $BLOCK_BUTTON
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -6,41 +6,26 @@ import (
|
||||||
"github.com/enescakir/emoji"
|
"github.com/enescakir/emoji"
|
||||||
"github.com/itchyny/timefmt-go"
|
"github.com/itchyny/timefmt-go"
|
||||||
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func runCalendar(wg *sync.WaitGroup) {
|
|
||||||
defer wg.Done()
|
|
||||||
command := exec.Command("tmux", "new", "-d", "gnome-calendar")
|
|
||||||
command.Run()
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
argFormat := flag.String("format", "%H:%M:%S %m-%d-%Y", "time format")
|
argFormat := flag.String("format", "%H:%M:%S %m-%d-%Y", "time format")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
now := time.Now()
|
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
|
|
||||||
if os.Getenv("BLOCK_BUTTON") == "1" {
|
|
||||||
wg.Add(1)
|
|
||||||
go runCalendar(&wg)
|
|
||||||
}
|
|
||||||
|
|
||||||
symbol := string(emoji.Calendar)
|
symbol := string(emoji.Calendar)
|
||||||
date := timefmt.Format(now, *argFormat)
|
|
||||||
|
|
||||||
options := r.NewBlockOptions()
|
for {
|
||||||
options.FullText = r.TextWithRightPadding(fmt.Sprintf("%s %s", symbol, date), r.FB{
|
now := time.Now()
|
||||||
Foreground: r.Color("white"),
|
date := timefmt.Format(now, *argFormat)
|
||||||
Background: r.Color("black4"),
|
|
||||||
})
|
|
||||||
|
|
||||||
block := r.Block("date", options)
|
options := r.NewBlockOptions()
|
||||||
fmt.Println(block)
|
options.FullText = r.TextWithRightPadding(fmt.Sprintf("%s %s", symbol, date), r.FB{
|
||||||
wg.Wait()
|
Foreground: r.Color("white"),
|
||||||
|
Background: r.Color("black4"),
|
||||||
|
})
|
||||||
|
|
||||||
|
block := r.Block("date", options)
|
||||||
|
fmt.Println(block)
|
||||||
|
time.Sleep(time.Millisecond * 500)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,16 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
sos"
|
||||||
"os"
|
"os/"
|
||||||
"os/exec"
|
|
||||||
"strings"
|
"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 {
|
func GetMetadata(metadata string) string {
|
||||||
|
@ -20,11 +26,15 @@ func GetMetadata(metadata string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTitle() string {
|
func GetTitle() string {
|
||||||
return GetMetadata("xesam:title")
|
data := GetMetadata("xesam:title")
|
||||||
|
|
||||||
|
return strings.Trim(string(data), "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetArtist() string {
|
func GetArtist() string {
|
||||||
return GetMetadata("xesam:artist")
|
data := GetMetadata("xesam:artist")
|
||||||
|
|
||||||
|
return strings.Trim(string(data), "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStatus() string {
|
func GetStatus() string {
|
||||||
|
@ -41,6 +51,8 @@ func main() {
|
||||||
|
|
||||||
if status == "Not available" {
|
if status == "Not available" {
|
||||||
return
|
return
|
||||||
|
} else if status == "Stopped" {
|
||||||
|
return
|
||||||
} else if status == "Paused" {
|
} else if status == "Paused" {
|
||||||
stmt = r.TextWithPadding(r.FontAwesome("\uf04c"), r.FB{
|
stmt = r.TextWithPadding(r.FontAwesome("\uf04c"), r.FB{
|
||||||
Background: r.Color("black3"),
|
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"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
||||||
"os"
|
// "os"
|
||||||
|
"flag"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -117,50 +118,55 @@ func main() {
|
||||||
tree := GetTree()
|
tree := GetTree()
|
||||||
nodes := GetVisibleNodes(tree, workspaces)
|
nodes := GetVisibleNodes(tree, workspaces)
|
||||||
|
|
||||||
appNumber, _ := strconv.Atoi(os.Args[1])
|
argX := flag.String("x", "", "")
|
||||||
blockButton := ""
|
flag.Parse()
|
||||||
|
|
||||||
for k, v := range os.Args {
|
x := 0
|
||||||
if k == 2 {
|
minX := 0
|
||||||
blockButton = v
|
|
||||||
}
|
if *argX != "" {
|
||||||
|
x, _ = strconv.Atoi(*argX)
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, app := range nodes {
|
options := r.NewBlockOptions()
|
||||||
if key == appNumber {
|
|
||||||
foreground := "#9cb7d1"
|
|
||||||
background := "#222222"
|
|
||||||
|
|
||||||
if app.Urgent {
|
for _, app := range nodes {
|
||||||
foreground = "#ffffff"
|
foreground := "#9cb7d1"
|
||||||
background = "#07c0d4"
|
background := "#222222"
|
||||||
} else if app.Focused {
|
|
||||||
foreground = "#07c0d4"
|
|
||||||
background = "#333333"
|
|
||||||
} else if app.Output == "__i3" {
|
|
||||||
foreground = "#bababa"
|
|
||||||
}
|
|
||||||
|
|
||||||
fb := r.FB{
|
title := strings.ToUpper(app.WindowProperties.Title)
|
||||||
Foreground: foreground,
|
|
||||||
Background: background,
|
|
||||||
}
|
|
||||||
|
|
||||||
title := strings.ToUpper(app.WindowProperties.Title)
|
if len(title) > 30 {
|
||||||
|
title = fmt.Sprintf("%s…", title[0:29])
|
||||||
if len(title) > 25 {
|
|
||||||
title = fmt.Sprintf("%s…", title[0:22])
|
|
||||||
}
|
|
||||||
|
|
||||||
options := r.NewBlockOptions()
|
|
||||||
options.FullText = r.TextWithPadding(title, fb)
|
|
||||||
block := r.Block(fmt.Sprintf("workspace_apps_%d", appNumber), options)
|
|
||||||
|
|
||||||
fmt.Println(block)
|
|
||||||
|
|
||||||
if blockButton == "1" {
|
|
||||||
Focus(app.Window)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 && 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,
|
||||||
|
}
|
||||||
|
|
||||||
|
options.FullText = fmt.Sprintf("%s%s", options.FullText, r.TextWithPadding(title, fb))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
block := r.Block("workspace_apps", options)
|
||||||
|
fmt.Println(block)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package rendering
|
package rendering
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
// "bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
// "strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,6 +33,7 @@ func Block(name string, options BlockOptions) string {
|
||||||
|
|
||||||
block = strings.ReplaceAll(block, `\u003c`, "<")
|
block = strings.ReplaceAll(block, `\u003c`, "<")
|
||||||
block = strings.ReplaceAll(block, `\u003e`, ">")
|
block = strings.ReplaceAll(block, `\u003e`, ">")
|
||||||
|
block = strings.ReplaceAll(block, `\u0026`, "et")
|
||||||
|
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue