cpuBarWithLabel :: Cpu -> Int -> BarConfig -> CpuBar
cpuBarWithLabel cpu ms conf = item $ do
  box <- liftIO $ do
    box   <- Gtk.hBoxNew False 2
    bar   <- barNew conf
    label <- Gtk.labelNew (Just "0%")
    i     <- readStat cpu
    (_, h) <- widgetGetSize label

    Gtk.labelSetJustify label Gtk.JustifyLeft
    Gtk.widgetSetName label $ show cpu ++ "-label"
    Gtk.widgetSetSizeRequest label 40 h
    Gtk.boxPackStart box bar Gtk.PackNatural 0
    Gtk.boxPackStart box label Gtk.PackNatural 0

    withCss label $ fgColor (barTextColor conf)

    pollForever 0 i $ \p -> do
      a <- readStat cpu
      threadDelay (ms * 1000)
      b <- readStat cpu
      let value = calcCpuLoad p a b
      Gtk.labelSetText label (show value ++ "%")
      Gtk.set bar [barValue Gtk.:= value]
      return b
    return box
  return $ PanelItem (show cpu ++ "Bar") (Gtk.toWidget box) Gtk.PackNatural
cpuBarWithLabel :: Cpu -> Int -> BarConfig -> CpuBar
cpuBarWithLabel cpu ms conf = item $ do
  box <- liftIO $ do
    box   <- Gtk.hBoxNew False 2
    bar   <- barNew conf
    label <- Gtk.labelNew (Just "0%")
    i     <- readStat cpu
    (_, h) <- widgetGetSize label

    Gtk.labelSetJustify label Gtk.JustifyLeft
    Gtk.widgetSetName label $ show cpu ++ "-label"
    Gtk.widgetSetSizeRequest label 40 h
    Gtk.boxPackStart box bar Gtk.PackNatural 0
    Gtk.boxPackStart box label Gtk.PackNatural 0

    withCss label $ fgColor (barTextColor conf)

    pollForever 0 i $ \p -> do
      a <- readStat cpu
      threadDelay (ms * 1000)
      b <- readStat cpu
      let value = calcCpuLoad p a b
      Gtk.labelSetText label (show value ++ "%")
      Gtk.set bar [barValue Gtk.:= value]
      return b
    return box
  return $ PanelItem (show cpu ++ "Bar") (Gtk.toWidget box) Gtk.PackNatural
cpuBarWithLabel cpu ms conf = item $ do
  box <- liftIO $ do
    box   <- Gtk.hBoxNew False 2
    bar   <- barNew conf
    label <- Gtk.labelNew (Just "0%")
    i     <- readStat cpu
    (_, h) <- widgetGetSize label

    Gtk.labelSetJustify label Gtk.JustifyLeft
    Gtk.widgetSetName label $ show cpu ++ "-label"
    Gtk.widgetSetSizeRequest label 40 h
    Gtk.boxPackStart box bar Gtk.PackNatural 0
    Gtk.boxPackStart box label Gtk.PackNatural 0

    withCss label $ fgColor (barTextColor conf)

    pollForever 0 i $ \p -> do
      a <- readStat cpu
      threadDelay (ms * 1000)
      b <- readStat cpu
      let value = calcCpuLoad p a b
      Gtk.labelSetText label (show value ++ "%")
      Gtk.set bar [barValue Gtk.:= value]
      return b
    return box
  return $ PanelItem (show cpu ++ "Bar") (Gtk.toWidget box) Gtk.PackNatural