From f300ba9a9302e70dcc72523639aecc1e04feec53 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 12 Sep 2022 10:19:13 +0530 Subject: switched back to polybar --- .config/XMonad/lib/Defaults.hs | 34 +++++------ .config/XMonad/xmonad.hs | 9 +-- .config/lemon.go | 125 +++++++++++++++++++++++++++-------------- .config/polybar/config.ini | 44 +++++++++++++-- 4 files changed, 144 insertions(+), 68 deletions(-) (limited to '.config') diff --git a/.config/XMonad/lib/Defaults.hs b/.config/XMonad/lib/Defaults.hs index f4779d1..9c83de6 100644 --- a/.config/XMonad/lib/Defaults.hs +++ b/.config/XMonad/lib/Defaults.hs @@ -6,8 +6,9 @@ import XMonad.Layout.Tabbed import XMonad.Actions.GridSelect import XMonad.Util.Loggers -import XMonad.Hooks.StatusBar -import XMonad.Hooks.StatusBar.PP +-- import XMonad.Hooks.StatusBar +-- import XMonad.Hooks.StatusBar.PP + myBorder = "#120F23" myBorder' = "#C44CF2" @@ -98,18 +99,17 @@ myGSConfig colorizer = (buildDefaultGSConfig myGSColorizer) myGridSelect = myGSConfig myGSColorizer -myLemonbarCmd = "lemon | lemonbar -g 1920x28+1920+0 -o -2 -f 'Source Han Sans JP Normal:size=12' -B '#e6100b13' -F '#9d00ff'" -myLemonbarPP = def { - ppCurrent = wrap "%{B#ff0aa3} %{F#FFFFFF}" " %{F-}%{B-}" - , ppVisible = wrap "%{B#28c78f} %{F#FFFFFF}" " %{F-}%{B-}" - , ppHidden = wrap "%{B#9b1bed} %{F#FFFFFF}" " %{F-}%{B-}" - , ppHiddenNoWindows = wrap " " " " - --, ppVisibleNoWindows = wrap "%{B#ffffff} %{F#9b1bed}" " %{F-}%{B-}" - , ppWsSep = "" - , ppSep = "" - , ppTitle = wrap " " "%{r}" . shorten 60 - , ppOrder = \(ws:l:t:ex) -> [t]++[ws] - } - -myLemonbarCmd' = "lemon | lemonbar -g 1920x20+0+0 -o 0 -f 'Source Han Sans JP Normal:size=9' -B '#e6100b13' -F '#9d00ff'" -myLemonbarPP' = myLemonbarPP +-- myLemonbarCmd = "lemon | lemonbar -d -g 1920x28+1920+0 -o -2 -f 'Source Han Sans JP Normal:size=12' -B '#e6100b13' -F '#9d00ff'" +-- myLemonbarCmd' = "lemon | lemonbar -d -g 1920x20+0+0 -o 0 -f 'Source Han Sans JP Normal:size=9' -B '#e6100b13' -F '#9d00ff'" +-- +-- myLemonbarPP = def { +-- ppCurrent = wrap "%{B#ff0aa3} %{F#FFFFFF}" " %{F-}%{B-}" +-- , ppVisible = wrap "%{B#28c78f} %{F#FFFFFF}" " %{F-}%{B-}" +-- , ppHidden = wrap "%{B#9b1bed} %{F#FFFFFF}" " %{F-}%{B-}" +-- , ppHiddenNoWindows = wrap " " " " +-- --, ppVisibleNoWindows = wrap "%{B#ffffff} %{F#9b1bed}" " %{F-}%{B-}" +-- , ppWsSep = "" +-- , ppSep = "" +-- , ppTitle = wrap " " "" . shorten 60 +-- , ppOrder = \(ws:l:t:ex) -> [t]++["%{r}",ws] +-- } diff --git a/.config/XMonad/xmonad.hs b/.config/XMonad/xmonad.hs index c7f3ac0..6a4626d 100644 --- a/.config/XMonad/xmonad.hs +++ b/.config/XMonad/xmonad.hs @@ -4,11 +4,11 @@ import XMonad import XMonad.Hooks.ManageDocks import XMonad.Hooks.EwmhDesktops +-- import XMonad.Hooks.StatusBar import XMonad.Util.EZConfig import XMonad.Util.Run -import XMonad.Hooks.StatusBar import Keybindings import Defaults @@ -16,9 +16,10 @@ import Hooks main :: IO () main = do - myLemonbar <- statusBarPipe myLemonbarCmd (pure myLemonbarPP ) - myLemonbar' <- statusBarPipe myLemonbarCmd' (pure myLemonbarPP') - xmonad $ withSB myLemonbar $ withSB myLemonbar' $ ewmhFullscreen $ ewmh $ docks def { + -- myLemonbar <- statusBarPipe myLemonbarCmd (pure myLemonbarPP) + -- myLemonbar' <- statusBarPipe myLemonbarCmd' (pure myLemonbarPP) + -- xmonad $ withSB (myLemonbar <> myLemonbar') $ ewmhFullscreen $ docks def { + xmonad $ ewmhFullscreen $ ewmh $ docks def { focusFollowsMouse = True , terminal = myTerminal , borderWidth = myBorderWidth diff --git a/.config/lemon.go b/.config/lemon.go index 17471e9..f873d2b 100644 --- a/.config/lemon.go +++ b/.config/lemon.go @@ -13,7 +13,8 @@ import ( ) var ( - data, connectedWiFi, memPercentage, cpuTemp, cpuPercentage string + data, connectedWiFi, memPercentage, cpuTemp, cpuPercentage, volumeLevel string + batteryLevel, chargingStatus string text string = "\n" moduleColor0, moduleColor1 string = "#9b1bed", "#ff0aa3" ) @@ -32,13 +33,43 @@ func stdinLoop() { } } +// to update modules every 5 seconds +func fiveSecLoop() { + for { + memPercentage = getMemUsage() + cpuTemp = getCPUTemp() + cpuPercentage = getCPUUsage() + + time.Sleep(time.Second * 5) + } +} + +// to update modules every 10 seconds +func tenSecLoop() { + for { + connectedWiFi = getWiFiName() + chargingStatus, batteryLevel = getBatteryInfo() + + time.Sleep(time.Second * 10) + } +} + +// very creative name +// used to update modules like volume, etc +// don't want lag on those modules! +func veryFastLoop() { + for { + volumeLevel = getVolumeLevel() + time.Sleep(time.Second / 10) + } +} + func main() { go dataLoop() go stdinLoop() - go cpuUsageLoop() - go connectedWiFiLoop() - go memUsageLoop() - go cpuTempLoop() + go fiveSecLoop() + go tenSecLoop() + go veryFastLoop() for { fmt.Print(data + text) @@ -46,22 +77,36 @@ func main() { } } -// TODO -// volume -// brightness (new) -// battery - func getData() string { time := "%{F" + moduleColor0 + "} " + getTime() + "%{F-} " wifiName := "%{F" + moduleColor1 + "} WiFI: " + connectedWiFi + "%{F-} " - rootFree := "%{F" + moduleColor0 + "} / " + getDisk("/") + "%%%{F-} " - homeFree := "%{F" + moduleColor1 + "} /home " + getDisk("/home") + "%%%{F-} " - hddFree := "%{F" + moduleColor0 + "} /hdd " + getDisk("/hdd") + "%%%{F-} " - cpuUsage := "%{F" + moduleColor1 + "} CPU: " + cpuPercentage + "%%%{F-} " - cpuTemp := "%{F" + moduleColor0 + "} TEMP: " + cpuTemp + "%%{F-} " - memUsage := "%{F" + moduleColor1 + "} MEM: " + memPercentage + "%%{F-} " + rootFree := "%{F" + moduleColor0 + "} / " + getDisk("/") + "%%{F-} " + homeFree := "%{F" + moduleColor1 + "} /home " + getDisk("/home") + "%%{F-} " + hddFree := "%{F" + moduleColor0 + "} /hdd " + getDisk("/hdd") + "%%{F-} " + cpuUsage := "%{F" + moduleColor1 + "} CPU: " + cpuPercentage + "%%{F-} " + cpuTemp := "%{F" + moduleColor0 + "} TEMP: " + cpuTemp + "%{F-} " + memUsage := "%{F" + moduleColor1 + "} MEM: " + memPercentage + "%{F-} " + + volume := "%{F" + moduleColor0 + "}" + if volumeLevel != "muted" { + volume = volume + "} VOL: " + volumeLevel + "%{F-} " + } else { + volume = volume + "} MUTED%{F-} " + } - return time + wifiName + rootFree + homeFree + hddFree + cpuUsage + cpuTemp + memUsage + // shows battery level in different color + // depending on charging status + // hidden when full + var battery string + btlvl, _ := strconv.Atoi(batteryLevel) + if btlvl < 100 { + col := moduleColor1 + if chargingStatus == "Charging" { col = moduleColor0 } + battery = fmt.Sprintf("%%{F%s} BATT: %s%%{F-} ", col, batteryLevel) + } + + // TODO add brightness (new) + return time + wifiName + rootFree + homeFree + hddFree + cpuUsage + cpuTemp + "%{r}" + memUsage + battery } func getWiFiName() string { @@ -72,13 +117,6 @@ func getWiFiName() string { return string(name) } -func connectedWiFiLoop() { - for { - connectedWiFi = getWiFiName() - time.Sleep(time.Second * 15) - } -} - func getMemUsage() string { // script located in ~/.scripts/ // look at github.com/MikunoNaka/dots @@ -87,12 +125,6 @@ func getMemUsage() string { return string(usage) } -func memUsageLoop() { - for { - memPercentage = getMemUsage() - time.Sleep(time.Second * 5) - } -} func getCPUTemp() string { // script located in ~/.scripts/ @@ -102,11 +134,24 @@ func getCPUTemp() string { return string(temp) } -func cpuTempLoop() { - for { - cpuTemp = getCPUTemp() - time.Sleep(time.Second * 5) - } +func getVolumeLevel() string { + // script located in ~/.scripts/ + // look at github.com/MikunoNaka/dots + cmd := exec.Command("volume_level.sh") + level, _ := cmd.Output() + return string(level) +} + +func getBatteryInfo() (string, string) { + // scripts located in ~/.scripts/ + // look at github.com/MikunoNaka/dots + statCmd := exec.Command("charging_status.sh") + stat, _ := statCmd.Output() + + levelCmd := exec.Command("battery_level.sh") + level, _ := levelCmd.Output() + + return string(stat), string(level) } // TODO: maybe add dates on click @@ -153,7 +198,7 @@ func getCPUSample() (idle, total uint64) { return } -func getCPUUsage() { +func getCPUUsage() string { idle0, total0 := getCPUSample() time.Sleep(3 * time.Second) idle1, total1 := getCPUSample() @@ -162,12 +207,6 @@ func getCPUUsage() { totalTicks := float64(total1 - total0) cpuUsage := 100 * (totalTicks - idleTicks) / totalTicks - cpuPercentage = strconv.Itoa(int(cpuUsage)) + return strconv.Itoa(int(cpuUsage)) } -func cpuUsageLoop() { - for { - getCPUUsage() - time.Sleep(5 * time.Second) - } -} diff --git a/.config/polybar/config.ini b/.config/polybar/config.ini index 27f5e00..4dc7b04 100644 --- a/.config/polybar/config.ini +++ b/.config/polybar/config.ini @@ -91,7 +91,7 @@ batt-full-fg = ${colors.module-color-0} [bar/mybar2] monitor = ${env:MONITOR:HDMI-0} enable-ipc = true -width = 1577 +width = 1920 height = 20 offset-x = 0 offset-y = 0 @@ -122,7 +122,7 @@ font-3 = fixed:pixelsize=10;1 ;font-5 = siji:pixelsize=10;1 modules-left = date uptime wlan eth filesystem-root filesystem-home filesystem-hdd cpu temperature memory xwindow -modules-right = battery pulseaudio +modules-right = battery pulseaudio ewmh tray-position = right tray-padding = 2 @@ -136,7 +136,7 @@ cursor-scroll = ns-resize [bar/mybar] ;monitor = ${env:MONITOR:eDP-1} enable-ipc = true -width = 1475 +width = 1920 height = 28 offset-x = 0 offset-y = 0 @@ -167,7 +167,7 @@ font-3 = fixed:pixelsize=10;1 ;font-5 = siji:pixelsize=10;1 modules-left = date uptime wlan eth filesystem-root filesystem-home filesystem-hdd cpu temperature memory xwindow -modules-right = battery pulseaudio +modules-right = battery pulseaudio ewmh override-redirect = true @@ -351,3 +351,39 @@ label-discharging-foreground = ${colors.batt-discharging-fg} label-full-background = ${colors.batt-full-bg} label-full-foreground = ${colors.batt-full-fg} +[module/ewmh] +type = internal/xworkspaces + +pin-workspaces = false +enable-click = true +enable-scroll = false +format = +index-sort = true + +label-monitor = %name% + +label-active = %name% +label-active-foreground = ${colors.ws-active-fg} +label-active-background = ${colors.ws-active-bg} +label-active-underline = ${colors.ws-active-ul} +label-active-padding = 3 + +label-occupied = %name% +label-occupied-foreground = ${colors.ws-occupied-fg} +label-occupied-background = ${colors.ws-occupied-bg} +label-occupied-underline = ${colors.ws-occupied-ul} +label-occupied-padding = 3 + +label-empty = %name% +label-empty-foreground = ${colors.ws-empty-fg} +label-empty-background = ${colors.ws-empty-bg} +label-empty-underline = ${colors.ws-empty-ul} +label-empty-padding = 3 + +label-background = #FFFFFF + +label-urgent = %name% +label-urgent-foreground = #000000 +label-urgent-background = #bd2c40 +label-urgent-underline = #9b0a20 +label-urgent-padding = 0 -- cgit v1.2.3