feat(prog/xmonad): compile bar from haskell
This commit is contained in:
parent
79aeaede42
commit
e7b6501dca
11 changed files with 300 additions and 31 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -10,6 +10,3 @@
|
||||||
|
|
||||||
!/programs
|
!/programs
|
||||||
|
|
||||||
/programs/xmonad/*
|
|
||||||
!/programs/xmonad/*.hs
|
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ in
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
# system ui
|
# system ui
|
||||||
dmenu # menu for x window system
|
dmenu # menu for x window system
|
||||||
xmobar # a minimalistic text based status bar
|
|
||||||
flameshot # powerful yet simple to use screenshot software
|
flameshot # powerful yet simple to use screenshot software
|
||||||
|
|
||||||
# tools
|
# tools
|
||||||
|
@ -81,12 +80,12 @@ in
|
||||||
SetPartialStrut = true;
|
SetPartialStrut = true;
|
||||||
expand = true;
|
expand = true;
|
||||||
transparent = true;
|
transparent = true;
|
||||||
alpha = 50;
|
alpha = 0;
|
||||||
edge = "top";
|
edge = "top";
|
||||||
align = "right";
|
align = "right";
|
||||||
width = 4;
|
width = 4;
|
||||||
height = 24;
|
height = 20;
|
||||||
tint = "0x5f5f5f";
|
tint = "0xff222222";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
Config { overrideRedirect = False
|
|
||||||
, font = "xft:Fira Code:size=12:antialias=true"
|
|
||||||
, bgColor = "#5f5f5f"
|
|
||||||
, fgColor = "#f8f8f2"
|
|
||||||
, position = TopW L 96
|
|
||||||
, commands = [ Run Cpu
|
|
||||||
[ "-L", "3"
|
|
||||||
, "-H", "50"
|
|
||||||
, "--high" , "red"
|
|
||||||
, "--normal", "green"
|
|
||||||
] 10
|
|
||||||
, Run Memory ["--template", "Mem: <usedratio>%"] 10
|
|
||||||
, Run Swap [] 10
|
|
||||||
, Run Date "%a %Y-%m-%d <fc=#8be9fd>%H:%M</fc>" "date" 10
|
|
||||||
, Run XMonadLog
|
|
||||||
, Run Kbd [("us(dvorak)", "us"), ("ru", "ru")]
|
|
||||||
, Run Wireless ""
|
|
||||||
[ "--template", "wlan <qualityvbar>"
|
|
||||||
] 10
|
|
||||||
]
|
|
||||||
, sepChar = "%"
|
|
||||||
, alignSep = "}{"
|
|
||||||
, template = "%XMonadLog% }{ %cpu% | %memory% * %swap% <hspace=60/> %wi% | <box> %kbd% </box> | %date% "
|
|
||||||
}
|
|
2
programs/xmonad/xmobar/.gitignore
vendored
Normal file
2
programs/xmonad/xmobar/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.stack-work/
|
||||||
|
*~
|
1
programs/xmonad/xmobar/README.md
Normal file
1
programs/xmonad/xmobar/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# xmobar
|
2
programs/xmonad/xmobar/Setup.hs
Normal file
2
programs/xmonad/xmobar/Setup.hs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
import Distribution.Simple
|
||||||
|
main = defaultMain
|
21
programs/xmonad/xmobar/package.yaml
Normal file
21
programs/xmonad/xmobar/package.yaml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
name: xmobarrc
|
||||||
|
version: 0.1.0
|
||||||
|
synopsis: My xmobar configuration
|
||||||
|
license: Beerware
|
||||||
|
author: Pleshevskiy
|
||||||
|
maintainer: dmitriy@ideascup.me
|
||||||
|
homepage: https://github.com/pleshevskiy/myconfig
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- base
|
||||||
|
- xmobar
|
||||||
|
|
||||||
|
executables:
|
||||||
|
xmobar:
|
||||||
|
source-dirs: src
|
||||||
|
main: xmobar.hs
|
||||||
|
ghc-options:
|
||||||
|
- -threaded
|
||||||
|
- -rtsopts
|
||||||
|
- -with-rtsopts=-N
|
||||||
|
|
137
programs/xmonad/xmobar/src/xmobar.hs
Normal file
137
programs/xmonad/xmobar/src/xmobar.hs
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
{-# LANGUAGE PostfixOperators #-}
|
||||||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
-- |
|
||||||
|
-- Copyright: (c) 2018, 2019, 2022 Jose Antonio Ortega Ruiz
|
||||||
|
-- License: BSD3-style (see LICENSE)
|
||||||
|
--
|
||||||
|
-- Maintainer: jao@gnu.org
|
||||||
|
-- Stability: unstable
|
||||||
|
-- Portability: portable
|
||||||
|
-- Created: Sat Nov 24, 2018 21:03
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- An example of a Haskell-based xmobar. Compile it with
|
||||||
|
-- ghc --make -- xmobar.hs
|
||||||
|
-- with the xmobar library installed or simply call:
|
||||||
|
-- xmobar /path/to/xmobar.hs
|
||||||
|
-- and xmobar will compile and launch it for you and
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
import Xmobar
|
||||||
|
|
||||||
|
import System.Environment (getArgs)
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = getArgs >>= \case
|
||||||
|
["-x", n] -> xmobar . config $ read n
|
||||||
|
_ -> xmobar . config $ 0
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
config :: Int -> Config
|
||||||
|
config n = defaultConfig
|
||||||
|
-- fonts
|
||||||
|
{ font = regularFont 9
|
||||||
|
, additionalFonts =
|
||||||
|
[ boldFont 9
|
||||||
|
]
|
||||||
|
|
||||||
|
-- colors
|
||||||
|
, bgColor = colorBg
|
||||||
|
, fgColor = colorFg
|
||||||
|
|
||||||
|
-- general
|
||||||
|
, position = OnScreen n (TopW L 96)
|
||||||
|
, overrideRedirect = False
|
||||||
|
, commands = myCommands
|
||||||
|
, sepChar = "%"
|
||||||
|
, alignSep = "}{"
|
||||||
|
, template = "%XMonadLog%"
|
||||||
|
<> "} %date% <hspace=60/> %cpu% | %memory% * %swap% | %wlxd03745e1e87bwi%"
|
||||||
|
<> "{ <fn=1><box> %kbd% </box> <fc=#ee9a00>%time%</fc></fn>"
|
||||||
|
}
|
||||||
|
|
||||||
|
myCommands :: [Runnable]
|
||||||
|
myCommands =
|
||||||
|
[ Run $
|
||||||
|
Cpu
|
||||||
|
[ "--template", "Cpu: <total>"
|
||||||
|
, "--suffix" , "True"
|
||||||
|
, "--Low" , "3"
|
||||||
|
, "--High" , "50"
|
||||||
|
, "--low" , colorGreen
|
||||||
|
, "--normal" , colorYellow
|
||||||
|
, "--high" , colorRed
|
||||||
|
]
|
||||||
|
10
|
||||||
|
, Run $ Memory ["-t","Mem: <usedratio>%"] 10
|
||||||
|
, Run $ Swap [] 10
|
||||||
|
, Run $ Date "%a %d %b %Y" "date" (10 `seconds`)
|
||||||
|
, Run $ Date "%H:%M:%S" "time" (1 `seconds`)
|
||||||
|
, Run $ Kbd [("us(dvorak)", "us"), ("ru", "ru")]
|
||||||
|
, Run $ XMonadLog
|
||||||
|
, Run $
|
||||||
|
Wireless
|
||||||
|
"wlxd03745e1e87b"
|
||||||
|
[ "--template", "<ssid> <quality>"
|
||||||
|
, "--suffix" , "True"
|
||||||
|
, "--Low" , "40"
|
||||||
|
, "--High" , "70"
|
||||||
|
, "--low" , colorRed
|
||||||
|
, "--normal" , colorYellow
|
||||||
|
, "--high" , colorGreen
|
||||||
|
]
|
||||||
|
(10 `seconds`)
|
||||||
|
]
|
||||||
|
where
|
||||||
|
seconds, minutes :: Int -> Int
|
||||||
|
seconds = (* 10)
|
||||||
|
minutes = (60 *) . seconds
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
colorBg, colorFg, colorRed, colorGreen, colorYellow, colorCyan :: String
|
||||||
|
colorBg = "#222222"
|
||||||
|
colorFg = "#cccccc"
|
||||||
|
colorRed = "#ff5555"
|
||||||
|
colorGreen = "#50fa7b"
|
||||||
|
colorYellow = "#f1fa8c"
|
||||||
|
colorCyan = "#8be9fd"
|
||||||
|
|
||||||
|
cyan, green, yellow :: String -> String
|
||||||
|
cyan = xmobarColor colorCyan ""
|
||||||
|
green = xmobarColor colorGreen ""
|
||||||
|
yellow = xmobarColor colorYellow ""
|
||||||
|
|
||||||
|
regularFont, boldFont :: Int -> String
|
||||||
|
regularFont size = "xft:Fira Code:size=" <> show size <> ":antialias=true"
|
||||||
|
boldFont size = "xft:Fira Code:bold:size=" <> show size <> ":antialias=true"
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
{- | Use xmobar escape codes to output a string with given foreground and
|
||||||
|
background colors.
|
||||||
|
|
||||||
|
Source: https://hackage.haskell.org/package/xmonad-contrib-0.15/docs/src/XMonad.Hooks.DynamicLog.html#xmobarColor
|
||||||
|
-}
|
||||||
|
xmobarColor
|
||||||
|
:: String -- ^ foreground color: a color name, or #rrggbb format
|
||||||
|
-> String -- ^ background color
|
||||||
|
-> String -- ^ output string
|
||||||
|
-> String
|
||||||
|
xmobarColor fg bg = wrap open "</fc>"
|
||||||
|
where
|
||||||
|
open :: String = concat ["<fc=", fg, if null bg then "" else "," <> bg, ">"]
|
||||||
|
|
||||||
|
-- | Wrap a string in delimiters, unless it is empty.
|
||||||
|
-- Source: https://hackage.haskell.org/package/xmonad-contrib-0.15/docs/src/XMonad.Hooks.DynamicLog.html#wrap
|
||||||
|
wrap
|
||||||
|
:: String -- ^ left delimiter
|
||||||
|
-> String -- ^ right delimiter
|
||||||
|
-> String -- ^ output string
|
||||||
|
-> String
|
||||||
|
wrap _ _ "" = ""
|
||||||
|
wrap l r m = l <> m <> r
|
74
programs/xmonad/xmobar/stack.yaml
Normal file
74
programs/xmonad/xmobar/stack.yaml
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
# This file was automatically generated by 'stack init'
|
||||||
|
#
|
||||||
|
# Some commonly used options have been documented as comments in this file.
|
||||||
|
# For advanced use and comprehensive documentation of the format, please see:
|
||||||
|
# https://docs.haskellstack.org/en/stable/yaml_configuration/
|
||||||
|
|
||||||
|
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
|
||||||
|
# A snapshot resolver dictates the compiler version and the set of packages
|
||||||
|
# to be used for project dependencies. For example:
|
||||||
|
#
|
||||||
|
# resolver: lts-3.5
|
||||||
|
# resolver: nightly-2015-09-21
|
||||||
|
# resolver: ghc-7.10.2
|
||||||
|
#
|
||||||
|
# The location of a snapshot can be provided as a file or url. Stack assumes
|
||||||
|
# a snapshot provided as a file might change, whereas a url resource does not.
|
||||||
|
#
|
||||||
|
# resolver: ./custom-snapshot.yaml
|
||||||
|
# resolver: https://example.com/snapshots/2018-01-01.yaml
|
||||||
|
resolver:
|
||||||
|
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/2.yaml
|
||||||
|
|
||||||
|
# User packages to be built.
|
||||||
|
# Various formats can be used as shown in the example below.
|
||||||
|
#
|
||||||
|
# packages:
|
||||||
|
# - some-directory
|
||||||
|
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
|
||||||
|
# subdirs:
|
||||||
|
# - auto-update
|
||||||
|
# - wai
|
||||||
|
packages:
|
||||||
|
- .
|
||||||
|
|
||||||
|
# Dependency packages to be pulled from upstream that are not in the resolver.
|
||||||
|
# These entries can reference officially published versions as well as
|
||||||
|
# forks / in-progress versions pinned to a git hash. For example:
|
||||||
|
#
|
||||||
|
# extra-deps:
|
||||||
|
# - acme-missiles-0.3
|
||||||
|
# - git: https://github.com/commercialhaskell/stack.git
|
||||||
|
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
|
||||||
|
#
|
||||||
|
extra-deps:
|
||||||
|
- xmobar-0.42
|
||||||
|
- X11-xft-0.3.4
|
||||||
|
- iwlib-0.1.0
|
||||||
|
|
||||||
|
# Override default flag values for local packages and extra-deps
|
||||||
|
flags:
|
||||||
|
xmobar:
|
||||||
|
with_xft: true
|
||||||
|
with_iwlib: true
|
||||||
|
|
||||||
|
# Extra package databases containing global packages
|
||||||
|
# extra-package-dbs: []
|
||||||
|
|
||||||
|
# Control whether we use the GHC we find on the path
|
||||||
|
# system-ghc: true
|
||||||
|
#
|
||||||
|
# Require a specific version of stack, using version ranges
|
||||||
|
# require-stack-version: -any # Default
|
||||||
|
# require-stack-version: ">=2.7"
|
||||||
|
#
|
||||||
|
# Override the architecture used by stack, especially useful on Windows
|
||||||
|
# arch: i386
|
||||||
|
# arch: x86_64
|
||||||
|
#
|
||||||
|
# Extra directories used by stack for building
|
||||||
|
# extra-include-dirs: [/path/to/dir]
|
||||||
|
# extra-lib-dirs: [/path/to/dir]
|
||||||
|
#
|
||||||
|
# Allow a newer minor version of GHC than the snapshot specifies
|
||||||
|
# compiler-check: newer-minor
|
34
programs/xmonad/xmobar/stack.yaml.lock
Normal file
34
programs/xmonad/xmobar/stack.yaml.lock
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# This file was autogenerated by Stack.
|
||||||
|
# You should not edit this file by hand.
|
||||||
|
# For more information, please see the documentation at:
|
||||||
|
# https://docs.haskellstack.org/en/stable/lock_files
|
||||||
|
|
||||||
|
packages:
|
||||||
|
- completed:
|
||||||
|
hackage: xmobar-0.42@sha256:a4583cea362e6e10a9633dc083987377a6016c1c0756802ef06dbb6c2ef77e30,14676
|
||||||
|
pantry-tree:
|
||||||
|
size: 9019
|
||||||
|
sha256: b35b11bd2c2656dc0f033c530a76a7803e48857859802551980fef35de112ba0
|
||||||
|
original:
|
||||||
|
hackage: xmobar-0.42
|
||||||
|
- completed:
|
||||||
|
hackage: X11-xft-0.3.4@sha256:e08bd69d24c40f1a33e6c87964f200656da77ad6a1fbdf6a4073dcb967e65599,1380
|
||||||
|
pantry-tree:
|
||||||
|
size: 330
|
||||||
|
sha256: 0dad74fea9135433d0f4ca7a65dba6c8ac99136bb6cacf901d2ddf795846d0f1
|
||||||
|
original:
|
||||||
|
hackage: X11-xft-0.3.4
|
||||||
|
- completed:
|
||||||
|
hackage: iwlib-0.1.0@sha256:226e4582d6878166a172ff98c868e25c4ed478ab28ab493498e464b1fe19d39a,921
|
||||||
|
pantry-tree:
|
||||||
|
size: 259
|
||||||
|
sha256: f867a93991b791adf4c65bb91f385effee7e18bd78d8e0a61fd03f42f6073705
|
||||||
|
original:
|
||||||
|
hackage: iwlib-0.1.0
|
||||||
|
snapshots:
|
||||||
|
- completed:
|
||||||
|
size: 617368
|
||||||
|
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/2.yaml
|
||||||
|
sha256: e7e57649a12f6178d1158e4b6f1f1885ed56d210ae6174385271cecc9b1ea974
|
||||||
|
original:
|
||||||
|
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/2.yaml
|
26
programs/xmonad/xmobar/xmobarrc.cabal
Normal file
26
programs/xmonad/xmobar/xmobarrc.cabal
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
cabal-version: 2.2
|
||||||
|
|
||||||
|
-- This file has been generated from package.yaml by hpack version 0.34.4.
|
||||||
|
--
|
||||||
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
|
name: xmobarrc
|
||||||
|
version: 0.1.0
|
||||||
|
synopsis: My xmobar configuration
|
||||||
|
homepage: https://github.com/pleshevskiy/myconfig
|
||||||
|
author: Pleshevskiy
|
||||||
|
maintainer: dmitriy@ideascup.me
|
||||||
|
license: Beerware
|
||||||
|
build-type: Simple
|
||||||
|
|
||||||
|
executable xmobar
|
||||||
|
hs-source-dirs:
|
||||||
|
src
|
||||||
|
main-is: xmobar.hs
|
||||||
|
other-modules:
|
||||||
|
Paths_xmobarrc
|
||||||
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||||
|
build-depends:
|
||||||
|
base
|
||||||
|
, xmobar
|
||||||
|
default-language: Haskell2010
|
Loading…
Reference in a new issue