Change systray color if there are reboots
- switch to unstable - build with go 1.20
This commit is contained in:
parent
288e93c2a0
commit
f6ac3dc05b
8
flake.lock
generated
8
flake.lock
generated
@ -2,16 +2,16 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1671883564,
|
"lastModified": 1677676435,
|
||||||
"narHash": "sha256-C15oAtyupmLB3coZY7qzEHXjhtUx/+77olVdqVMruAg=",
|
"narHash": "sha256-6FxdcmQr5JeZqsQvfinIMr0XcTyTuR7EXX0H3ANShpQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "dac57a4eccf1442e8bf4030df6fcbb55883cb682",
|
"rev": "a08d6979dd7c82c4cef0dcc6ac45ab16051c1169",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-22.11",
|
"ref": "nixos-unstable",
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
10
flake.nix
10
flake.nix
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
description = "xintray: a status indicator that lives in the tray";
|
description = "xintray: a status indicator that lives in the tray";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "nixpkgs/nixos-22.11";
|
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
outputs = { self, nixpkgs }:
|
outputs = { self, nixpkgs }:
|
||||||
let
|
let
|
||||||
@ -14,9 +14,9 @@
|
|||||||
let pkgs = nixpkgsFor.${system};
|
let pkgs = nixpkgsFor.${system};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
xintray = pkgs.buildGoModule {
|
xintray = pkgs.buildGo120Module {
|
||||||
pname = "xintray";
|
pname = "xintray";
|
||||||
version = "v0.1.8";
|
version = "v0.1.9";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
vendorSha256 =
|
vendorSha256 =
|
||||||
@ -48,11 +48,11 @@
|
|||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
PS1='\u@\h:\@; '
|
PS1='\u@\h:\@; '
|
||||||
echo "Go `${pkgs.go}/bin/go version`"
|
echo "Go `${pkgs.go_1_20}/bin/go version`"
|
||||||
'';
|
'';
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
git
|
git
|
||||||
go
|
go_1_20
|
||||||
gopls
|
gopls
|
||||||
go-tools
|
go-tools
|
||||||
|
|
||||||
|
11
icons.go
11
icons.go
@ -61,7 +61,10 @@ func buildImage(xin *xinStatus) *myIcon {
|
|||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
border, err := parseHexColor("#000000")
|
border, err := parseHexColor("#000000")
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
rebootColor, err := parseHexColor("#DE3163")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
@ -81,7 +84,11 @@ func buildImage(xin *xinStatus) *myIcon {
|
|||||||
i.data.Set(x, y, border)
|
i.data.Set(x, y, border)
|
||||||
} else {
|
} else {
|
||||||
if aliveCount > 0 && y < gridMark*utdCount {
|
if aliveCount > 0 && y < gridMark*utdCount {
|
||||||
i.data.Set(x, y, on)
|
if !xin.hasReboot {
|
||||||
|
i.data.Set(x, y, rebootColor)
|
||||||
|
} else {
|
||||||
|
i.data.Set(x, y, on)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
i.data.Set(x, y, off)
|
i.data.Set(x, y, off)
|
||||||
}
|
}
|
||||||
|
4
main.go
4
main.go
@ -42,6 +42,7 @@ type xinStatus struct {
|
|||||||
repoCommit commit
|
repoCommit commit
|
||||||
config Config
|
config Config
|
||||||
upgradeProgress *widget.ProgressBar
|
upgradeProgress *widget.ProgressBar
|
||||||
|
hasReboot bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Status struct {
|
type Status struct {
|
||||||
@ -108,6 +109,9 @@ func (x *xinStatus) aliveCount() float64 {
|
|||||||
for _, s := range x.config.Statuses {
|
for _, s := range x.config.Statuses {
|
||||||
if s.clientEstablished {
|
if s.clientEstablished {
|
||||||
alive = alive + 1
|
alive = alive + 1
|
||||||
|
if s.NeedsRestart {
|
||||||
|
x.hasReboot = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return float64(alive)
|
return float64(alive)
|
||||||
|
Loading…
Reference in New Issue
Block a user