From f6ac3dc05bf7bd7a102d791acd5b924de1bdc2bd Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Fri, 3 Mar 2023 06:14:05 -0700 Subject: [PATCH] Change systray color if there are reboots - switch to unstable - build with go 1.20 --- flake.lock | 8 ++++---- flake.nix | 10 +++++----- icons.go | 11 +++++++++-- main.go | 4 ++++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index 181488e..e121f1e 100644 --- a/flake.lock +++ b/flake.lock @@ -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" } }, diff --git a/flake.nix b/flake.nix index cb5ca05..f7fcb4f 100644 --- a/flake.nix +++ b/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 diff --git a/icons.go b/icons.go index 81a1d01..2314a12 100644 --- a/icons.go +++ b/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 { - i.data.Set(x, y, on) + if !xin.hasReboot { + i.data.Set(x, y, rebootColor) + } else { + i.data.Set(x, y, on) + } } else { i.data.Set(x, y, off) } diff --git a/main.go b/main.go index a29bc13..c1043b0 100644 --- a/main.go +++ b/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)