package main // The two optional features, weather and local news. Each can be turned off in // the settings window: its icon leaves the bar, its panel is closed, and nothing // is downloaded for it. Both are on until switched off. import ( "os" "path/filepath" "strings" ) var ( showWeather = true showNews = true showSys = true showGM = true // the Google Messages bubble showBattery = true showVolume = true showWifi = true showEmoji = true // the emoji panel button showClip = true // the clipboard history button showAI = true // the Claude and Grok button showMusic = true // the mp3 player button ) func featuresFile() string { return filepath.Join(dataDir(), "features.txt") } func loadFeatures() { b, err := os.ReadFile(featuresFile()) if err != nil { return } for _, ln := range strings.Split(string(b), "\n") { k, v, ok := strings.Cut(strings.TrimSpace(ln), "=") if !ok { continue } on := strings.TrimSpace(v) != "0" switch strings.TrimSpace(k) { case "weather": showWeather = on case "news": showNews = on case "sys": showSys = on case "messages": showGM = on case "panelfade": flyMatchBar = on case "group": groupWins = on case "autohide": autoHide = on case "battery": showBattery = on case "volume": showVolume = on case "wifi": showWifi = on case "emoji": showEmoji = on case "clip": showClip = on case "ai": showAI = on case "music": showMusic = on } } } func saveFeatures() { s := "weather=" + b01(showWeather) + "\nnews=" + b01(showNews) + "\nsys=" + b01(showSys) + "\nmessages=" + b01(showGM) + "\npanelfade=" + b01(flyMatchBar) + "\ngroup=" + b01(groupWins) + "\nautohide=" + b01(autoHide) + "\nbattery=" + b01(showBattery) + "\nvolume=" + b01(showVolume) + "\nwifi=" + b01(showWifi) + "\nemoji=" + b01(showEmoji) + "\nclip=" + b01(showClip) + "\nai=" + b01(showAI) + "\nmusic=" + b01(showMusic) + "\n" _ = os.MkdirAll(dataDir(), 0o755) _ = os.WriteFile(featuresFile(), []byte(s), 0o644) } func b01(b bool) string { if b { return "1" } return "0" } // setShowWeather is called by the settings window. func setShowWeather(on bool) { if showWeather == on { return } showWeather = on saveFeatures() if on { weatherRefresh(false) } else { weatherHide() } featuresChanged() } // setShowNews is called by the settings window. func setShowNews(on bool) { if showNews == on { return } showNews = on saveFeatures() if on { newsRefresh(false) } else { newsHide() } featuresChanged() } // setShowSys is called by the settings window. func setShowSys(on bool) { if showSys == on { return } showSys = on saveFeatures() if !on { sysHide() } featuresChanged() } // setShowGM is called by the settings window. func setShowGM(on bool) { if showGM == on { return } showGM = on saveFeatures() if on { gmAutoTried = false // let the background check start Messages again } else { gmClose() } featuresChanged() } // setFlyMatchBar is called by the settings window: should the panels be as // see-through as the bar? func setFlyMatchBar(on bool) { if flyMatchBar == on { return } flyMatchBar = on saveFeatures() flyRefreshAll() } func featuresChanged() { settingsZipStatusUpdate() redraw(hwndMain) } // zipStatusText is the one line the settings window shows under the ZIP box. func zipStatusText() string { switch { case !showWeather && !showNews: return "Weather and news are both turned off." case wxZip == "": return "Type a 5 digit ZIP code to turn on weather and local news." case showWeather: return weatherStatusText() } return newsStatusText() } // setGroupWins is called by the settings window: one icon per program, with a // count, or one icon per window. func setGroupWins(on bool) { if groupWins == on { return } groupWins = on saveFeatures() styleCacheClear() apps = groupApps(allApps) positionBar(hwndMain) }