Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8b9ba2c2c |
@@ -16,7 +16,9 @@ func (c *MyConfig) UpdateBatteryInfo() {
|
|||||||
Batts string
|
Batts string
|
||||||
)
|
)
|
||||||
|
|
||||||
for {
|
ticker := time.NewTicker(time.Second * 5)
|
||||||
|
|
||||||
|
for range ticker.C {
|
||||||
batteries, err := battery.GetAll()
|
batteries, err := battery.GetAll()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -166,7 +168,5 @@ func (c *MyConfig) UpdateBatteryInfo() {
|
|||||||
c.Values.BatteryString = Batts
|
c.Values.BatteryString = Batts
|
||||||
c.Channels.UpdateReady <- true
|
c.Channels.UpdateReady <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(5 * time.Second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import (
|
|||||||
|
|
||||||
// UpdateClock get and updates (on i3bar) info about system clock.
|
// UpdateClock get and updates (on i3bar) info about system clock.
|
||||||
func (c *MyConfig) UpdateClock() {
|
func (c *MyConfig) UpdateClock() {
|
||||||
for {
|
ticker := time.NewTicker(time.Second * 1)
|
||||||
|
|
||||||
|
for range ticker.C {
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
hours, minutes, _ := currentTime.Clock()
|
hours, minutes, _ := currentTime.Clock()
|
||||||
year, month, day := currentTime.Date()
|
year, month, day := currentTime.Date()
|
||||||
@@ -21,7 +23,5 @@ func (c *MyConfig) UpdateClock() {
|
|||||||
c.Values.ClockTime = myclock
|
c.Values.ClockTime = myclock
|
||||||
c.Channels.UpdateReady <- true
|
c.Channels.UpdateReady <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type Collection struct {
|
|||||||
|
|
||||||
// Item just interface for stoing any data.
|
// Item just interface for stoing any data.
|
||||||
type item struct {
|
type item struct {
|
||||||
data interface{}
|
data any
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCollection creates new instance of "collection".
|
// NewCollection creates new instance of "collection".
|
||||||
@@ -25,7 +25,7 @@ func NewCollection() *Collection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get returns value by given key. Or empty value.
|
// Get returns value by given key. Or empty value.
|
||||||
func (collection *Collection) Get(key interface{}) (interface{}, bool) {
|
func (collection *Collection) Get(key any) (any, bool) {
|
||||||
obj, exists := collection.items.Load(key)
|
obj, exists := collection.items.Load(key)
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
@@ -38,15 +38,15 @@ func (collection *Collection) Get(key interface{}) (interface{}, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set saves value to given "collection".
|
// Set saves value to given "collection".
|
||||||
func (collection *Collection) Set(key interface{}, value interface{}) {
|
func (collection *Collection) Set(key any, value any) {
|
||||||
collection.items.Store(key, item{
|
collection.items.Store(key, item{
|
||||||
data: value,
|
data: value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Range apply function f to all keys/values in collection. Retuns immediatly on first error.
|
// Range apply function f to all keys/values in collection. Retuns immediatly on first error.
|
||||||
func (collection *Collection) Range(f func(key, value interface{}) bool) {
|
func (collection *Collection) Range(f func(key, value any) bool) {
|
||||||
fn := func(key, value interface{}) bool {
|
fn := func(key, value any) bool {
|
||||||
item := value.(item)
|
item := value.(item)
|
||||||
|
|
||||||
return f(key, item.data)
|
return f(key, item.data)
|
||||||
@@ -56,7 +56,7 @@ func (collection *Collection) Range(f func(key, value interface{}) bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes key and corresponding value from collection.
|
// Delete deletes key and corresponding value from collection.
|
||||||
func (collection *Collection) Delete(key interface{}) {
|
func (collection *Collection) Delete(key any) {
|
||||||
collection.items.Delete(key)
|
collection.items.Delete(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ import (
|
|||||||
func (c *MyConfig) UpdateCPUTemperature() {
|
func (c *MyConfig) UpdateCPUTemperature() {
|
||||||
n := len(c.CPUTemp.File)
|
n := len(c.CPUTemp.File)
|
||||||
|
|
||||||
for {
|
ticker := time.NewTicker(time.Second * 3)
|
||||||
|
|
||||||
|
for range ticker.C {
|
||||||
var (
|
var (
|
||||||
temperature = make([]int64, n)
|
temperature = make([]int64, n)
|
||||||
tSum int64
|
tSum int64
|
||||||
@@ -71,7 +73,5 @@ func (c *MyConfig) UpdateCPUTemperature() {
|
|||||||
c.Values.CPUTemperature = tAvg
|
c.Values.CPUTemperature = tAvg
|
||||||
c.Channels.UpdateReady <- true
|
c.Channels.UpdateReady <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,9 +105,9 @@ func (c *MyConfig) I3EventParser(e *i3.WindowEvent) {
|
|||||||
|
|
||||||
// interfaceToUint превращает данный интерфейс в Uint64.
|
// interfaceToUint превращает данный интерфейс в Uint64.
|
||||||
// Если может, конечно :) .
|
// Если может, конечно :) .
|
||||||
func interfaceToUint64(iface interface{}) uint64 {
|
func interfaceToUint64(iface any) uint64 {
|
||||||
// А теперь мы начинаем дурдом, нам надо превратить ёбанный interface{} в []string
|
// А теперь мы начинаем дурдом, нам надо превратить ёбанный any в []string
|
||||||
// Поскольку interface{} может быть чем угодно, перестрахуемся
|
// Поскольку any может быть чем угодно, перестрахуемся
|
||||||
if reflect.TypeOf(iface).Kind() == reflect.Uint64 {
|
if reflect.TypeOf(iface).Kind() == reflect.Uint64 {
|
||||||
return reflect.ValueOf(iface).Uint()
|
return reflect.ValueOf(iface).Uint()
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ func HasWindows(className string, instanceName string) bool {
|
|||||||
func FindWindowInstance(regexpStr string) bool {
|
func FindWindowInstance(regexpStr string) bool {
|
||||||
var found = false
|
var found = false
|
||||||
|
|
||||||
f := func(key interface{}, value interface{}) bool {
|
f := func(key any, value any) bool {
|
||||||
keyStr := reflect.ValueOf(key).String()
|
keyStr := reflect.ValueOf(key).String()
|
||||||
|
|
||||||
re, err := regexp.Compile(regexpStr) //nolint:nolintlint, gocritic, we do not want shit our pants and panic on
|
re, err := regexp.Compile(regexpStr) //nolint:nolintlint, gocritic, we do not want shit our pants and panic on
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ import (
|
|||||||
|
|
||||||
// UpdateIfStatus updates network interfaces status for i3bar.
|
// UpdateIfStatus updates network interfaces status for i3bar.
|
||||||
func (c *MyConfig) UpdateIfStatus() {
|
func (c *MyConfig) UpdateIfStatus() {
|
||||||
for {
|
ticker := time.NewTicker(time.Second * 3)
|
||||||
|
|
||||||
|
for range ticker.C {
|
||||||
var statusSum string
|
var statusSum string
|
||||||
|
|
||||||
for _, item := range c.NetIf.If {
|
for _, item := range c.NetIf.If {
|
||||||
@@ -53,7 +55,5 @@ func (c *MyConfig) UpdateIfStatus() {
|
|||||||
c.Values.IfStatus = statusSum
|
c.Values.IfStatus = statusSum
|
||||||
c.Channels.UpdateReady <- true
|
c.Channels.UpdateReady <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import (
|
|||||||
|
|
||||||
// UpdateLaStats вытаскивает показание LA за последнюю минуту.
|
// UpdateLaStats вытаскивает показание LA за последнюю минуту.
|
||||||
func (c *MyConfig) UpdateLaStats() {
|
func (c *MyConfig) UpdateLaStats() {
|
||||||
for {
|
ticker := time.NewTicker(time.Second * 3)
|
||||||
|
|
||||||
|
for range ticker.C {
|
||||||
l, _ := load.Avg()
|
l, _ := load.Avg()
|
||||||
|
|
||||||
lav := fmt.Sprintf("%.2f", l.Load1)
|
lav := fmt.Sprintf("%.2f", l.Load1)
|
||||||
@@ -18,7 +20,5 @@ func (c *MyConfig) UpdateLaStats() {
|
|||||||
c.Values.La = lav
|
c.Values.La = lav
|
||||||
c.Channels.UpdateReady <- true
|
c.Channels.UpdateReady <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,13 @@ type Mem struct {
|
|||||||
|
|
||||||
// UpdateMemStats parses mem info stats.
|
// UpdateMemStats parses mem info stats.
|
||||||
func (c *MyConfig) UpdateMemStats() {
|
func (c *MyConfig) UpdateMemStats() {
|
||||||
for {
|
ticker := time.NewTicker(time.Second * 3)
|
||||||
|
|
||||||
|
for range ticker.C {
|
||||||
v, err := mem.VirtualMemory()
|
v, err := mem.VirtualMemory()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Unable to get memory statistics: %s", err)
|
log.Printf("Unable to get memory statistics: %s", err)
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -30,7 +31,6 @@ func (c *MyConfig) UpdateMemStats() {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Unable to get swap statistics: %s", err)
|
log.Printf("Unable to get swap statistics: %s", err)
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,5 @@ func (c *MyConfig) UpdateMemStats() {
|
|||||||
c.Channels.UpdateReady <- true
|
c.Channels.UpdateReady <- true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ func (c *MyConfig) UpdateVPNStatus() {
|
|||||||
vpnCheck string
|
vpnCheck string
|
||||||
)
|
)
|
||||||
|
|
||||||
for {
|
ticker := time.NewTicker(time.Second * 3)
|
||||||
|
|
||||||
|
for range ticker.C {
|
||||||
if c.VPNFileCheck() {
|
if c.VPNFileCheck() {
|
||||||
if c.Vpn.UpColor == "" {
|
if c.Vpn.UpColor == "" {
|
||||||
vpnCheck = `⍋`
|
vpnCheck = `⍋`
|
||||||
@@ -54,8 +56,6 @@ func (c *MyConfig) UpdateVPNStatus() {
|
|||||||
c.Values.VPNStatus = vpnCStatus
|
c.Values.VPNStatus = vpnCStatus
|
||||||
c.Channels.UpdateReady <- true
|
c.Channels.UpdateReady <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user