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