Skip to content
Snippets Groups Projects
Commit b98f8c4f authored by jktr's avatar jktr
Browse files

Remove dead code

parent d7213c90
No related branches found
No related tags found
1 merge request!8bump deps and build tooling
...@@ -6,7 +6,6 @@ module QBar.Qubes.AdminAPI ( ...@@ -6,7 +6,6 @@ module QBar.Qubes.AdminAPI (
qubesEvents, qubesEvents,
qubesGetProperty, qubesGetProperty,
qubesListLabelNames, qubesListLabelNames,
qubesListLabels,
qubesListProperties, qubesListProperties,
qubesListVMs, qubesListVMs,
qubesListVMsP, qubesListVMsP,
...@@ -17,7 +16,7 @@ module QBar.Qubes.AdminAPI ( ...@@ -17,7 +16,7 @@ module QBar.Qubes.AdminAPI (
import QBar.Prelude import QBar.Prelude
import Control.Monad (forM_, guard) import Control.Monad (forM_)
import Data.Binary import Data.Binary
import Data.Binary.Get import Data.Binary.Get
import Data.Binary.Put import Data.Binary.Put
...@@ -29,7 +28,6 @@ import Data.Function ((&)) ...@@ -29,7 +28,6 @@ import Data.Function ((&))
import Data.Map qualified as Map import Data.Map qualified as Map
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Network.HostName import Network.HostName
import Numeric (showHex, readHex)
import Pipes import Pipes
import Pipes.Prelude qualified as P import Pipes.Prelude qualified as P
import Pipes.Safe qualified as P import Pipes.Safe qualified as P
...@@ -298,9 +296,6 @@ qubesGetProperty name = parse <$> qubesAdminCall "admin.property.Get" [name] ...@@ -298,9 +296,6 @@ qubesGetProperty name = parse <$> qubesAdminCall "admin.property.Get" [name]
splitOn ch = fmap BLC.tail . BLC.break (== ch) splitOn ch = fmap BLC.tail . BLC.break (== ch)
(isDefault, (typeStr, value)) = splitOn ' ' reply & fmap (splitOn ' ') (isDefault, (typeStr, value)) = splitOn ' ' reply & fmap (splitOn ' ')
qubesListPropertyNames :: IO [BL.ByteString]
qubesListPropertyNames = qubesAdminCallLines "admin.property.List" []
qubesListProperties :: IO [(BL.ByteString, QubesPropertyInfo)] qubesListProperties :: IO [(BL.ByteString, QubesPropertyInfo)]
qubesListProperties = qubesListLabelNames >>= mapM (toSndM qubesGetProperty) qubesListProperties = qubesListLabelNames >>= mapM (toSndM qubesGetProperty)
where where
...@@ -323,33 +318,10 @@ qubesUsageOfDefaultPool = qubesGetDefaultPool >>= qubesGetPoolInfo >>= extract ...@@ -323,33 +318,10 @@ qubesUsageOfDefaultPool = qubesGetDefaultPool >>= qubesGetPoolInfo >>= extract
tryReadProp :: Read a => BL.ByteString -> [(BL.ByteString, BL.ByteString)] -> Maybe a tryReadProp :: Read a => BL.ByteString -> [(BL.ByteString, BL.ByteString)] -> Maybe a
tryReadProp name props = readMaybe . BLC.unpack =<< lookup name props tryReadProp name props = readMaybe . BLC.unpack =<< lookup name props
newtype QubesLabelColor = QubesLabelColor { fromQubesLabelColor :: Int }
deriving (Eq, Ord)
instance Show QubesLabelColor where
showsPrec _ (QubesLabelColor x) = \s -> "0x" <> pad 6 (showHex x "") <> s
where pad l s = replicate (l - length s) '0' <> s
instance Read QubesLabelColor where
readsPrec _ ('0' : 'x' : xs) = do
let (num, remainder) = splitAt 6 xs
guard $ length num == 6
(num', []) <- readHex num
[(QubesLabelColor num', remainder)]
readsPrec _ _ = []
qubesGetLabelColor :: BL.ByteString -> IO QubesLabelColor
qubesGetLabelColor name = read . BLC.unpack <$> qubesAdminCall "admin.label.Get" [name]
qubesListLabelNames :: IO [BL.ByteString] qubesListLabelNames :: IO [BL.ByteString]
qubesListLabelNames = qubesAdminCallLines "admin.label.List" [] qubesListLabelNames = qubesAdminCallLines "admin.label.List" []
qubesListLabels :: IO [(BL.ByteString, QubesLabelColor)]
qubesListLabels = qubesListLabelNames >>= mapM (toSndM qubesGetLabelColor)
where
toSndM :: Applicative m => (a -> m b) -> a -> m (a, b)
toSndM f x = sequenceA (x, f x)
qubesMonitorProperty :: forall m. MonadIO m qubesMonitorProperty :: forall m. MonadIO m
=> Producer QubesEvent m () -> BL.ByteString -> Producer QubesPropertyInfo m () => Producer QubesEvent m () -> BL.ByteString -> Producer QubesPropertyInfo m ()
qubesMonitorProperty events name = events >-> P.filter isRelevant >-> fetchValue qubesMonitorProperty events name = events >-> P.filter isRelevant >-> fetchValue
......
...@@ -30,9 +30,6 @@ import Pipes.Concurrent (Input, spawn, latest, toOutput, fromInput) ...@@ -30,9 +30,6 @@ import Pipes.Concurrent (Input, spawn, latest, toOutput, fromInput)
import Pipes.Prelude qualified as PP import Pipes.Prelude qualified as PP
import System.IO (stdin, stdout, stderr, hFlush) import System.IO (stdin, stdout, stderr, hFlush)
data ServerMode = Host | Mirror
data ServerOutput = Sway | Headless
renderIndicators :: [Text] renderIndicators :: [Text]
renderIndicators = ["*"] <> cycle ["/", "-", "\\", "|"] renderIndicators = ["*"] <> cycle ["/", "-", "\\", "|"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment