Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement in BatteryBar and CPUTemperature #157

Closed
wants to merge 8 commits into from

Conversation

vanjo9800
Copy link

I have designed a convenient way to see the remaining time of the battery when still seeing the icon. I have also made it easier to access the CPU temperature directly from the configuration using $temp$.

let template = ST.newSTMP fmt
let template' = ST.setManyAttrib [ ("user", userLoad'),
("system", systemLoad'),
("total", totalLoad') ] template
("total", totalLoad'),
("temp",cpuTemp')] template
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation string needs to be updated in the usage. otherwise: nice job, i've been looking for something like this.

taffybar.cabal Outdated
@@ -53,7 +53,8 @@ library
safe >= 0.3 && < 1,
split >= 0.1.4.2,
process >= 1.0.1.1,
enclosed-exceptions >= 1.0.0.1
enclosed-exceptions >= 1.0.0.1,
gtk2hs-buildtools >= 0.13.0.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary?

@anarcat
Copy link

anarcat commented Apr 9, 2018

@vanjo9800 there was a new major release, so you'll need to reroll your changes to fix the conflicts here.

@colonelpanic8
Copy link
Member

@anarcat any interest in taking this over?

@anarcat
Copy link

anarcat commented May 10, 2018

i'm not sure i'm the right person to do this. all my Haskell experiments are cargo-culting and voodoo experiments... after much pain, i have arrived at this nasty piece of business:

tempZoneWidget :: Int -> IO Widget
tempZoneWidget zone = do
  label <- pollingLabelNew "N/A C" 1.0 $ callback
  widgetShowAll label
  return label
  where
    path = "/sys/devices/virtual/thermal/thermal_zone" ++ show zone ++ "/temp"
    callback = do
        temp <- readFile $ path
        let tempn = (read temp) :: Int
        let tempd = (fromIntegral tempn) / 1000
            fmt :: Double -> String
            fmt celc = printf "zone%d: %f°C" zone celc
        return (fmt tempd)

... which is used, clunkily, as:

main = do
  let
      temp0 = tempZoneWidget 0
      temp3 = tempZoneWidget 3
 defaultTaffybar defaultTaffybarConfig { startWidgets = [ pager ], endWidgets = [ temp0, temp3 ] }

surely there is a better way, particularly to get autodiscovery of the available temperatures, but I really got tired of this and stopped there...

suggestions?

@colonelpanic8
Copy link
Member

@anarcat @vanjo9800 see changes that were recently pushed to master as part of integrating #119

@anarcat
Copy link

anarcat commented May 12, 2018

i guess the problem i had with getCPUTemp is i had trouble turning it into a working widget... any suggestions?

@colonelpanic8
Copy link
Member

@anarcat If you just want a text widget it should be really easy

@colonelpanic8
Copy link
Member

Something like

getAverageTemp = fromMaybe "Error" . fmap (show . snd) <$> getMTuple
  where getMTuple = lookup "temp1_input" <$> getCPUTemperatures

cpuTemp = pollingLabelNew "" 15.0 getAverageTemp

probably won't compile, but you can figure out the details.

@colonelpanic8
Copy link
Member

@anarcat You can ping me on https://gitter.im/taffybar/Lobby if you have any more questions

@anarcat
Copy link

anarcat commented May 13, 2018

@IvanMalison yes, a text widget. assume I have no clue what i'm doing and the above is just something i cargo-culted and bruteforced until it worked. :p

@colonelpanic8
Copy link
Member

@anarcat did you try what I posted? You'll need to import Data.Maybe

@anarcat
Copy link

anarcat commented May 13, 2018

oops, sorry - i hadn't see the previous comment showing how to actually build the widget! :)

i need to deploy the latest source, i still haven't managed to do that just yet... sorry for the delay and confusion!

it looks like the code snippet you provided shows temperature for probe 1, is there a way to show all available probes?

@colonelpanic8
Copy link
Member

I believe that temp1 is the aggregated temperature. If you REALLY want all of the temperatures, something like:

getAllTemp = intercalate ", " . map (show . snd) <$> getCPUTemperatures

cpuTemp = pollingLabelNew "" 15.0 getAllTemp

that will just make the label be a comma separated list of the temperatures.

Not sure if that is what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants