Skip to content

Commit b9efeda

Browse files
committed
new good stuff and stuff for laptop
1 parent 7c038cc commit b9efeda

12 files changed

Lines changed: 199 additions & 72 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Xmonanza
22
##### XMonad and Xmobar monorepo for sharing code between them, build with stack
33

4-
1. Edit `src/AConfig.hs` (atleast iconpath (check xmobar/Main.hs for icons used))
5-
1. `stack install`
6-
`xmonad-afreak` and `xmobar-afreak` will then be created in `~/.local/bin` or `local-bin-path`
4+
1. `stack install` (or `stack --nix install` if using nix)
5+
`xmonad-afreak` and `xmobar-afreak` is then created in `~/.local/bin` (`local-bin-path`)
76
(`~/.local/bin` needs to be in `$PATH`)
87
1. Copy custom buildscript for xmonad `cp scripts/build ~/.xmonad/` and edit script to correct paths
8+
1. if using nix, run `echo 'STACK_COMMAND="stack --nix"' > ~/.xmonad/.env`
99
1. Link from `xmonad-afreak` -> `xmonad` somewhere in `$PATH` e.g. `ln -s ~/.local/bin/xmonad-afreak ~/.local/bin/xmonad`
1010
(not sure why, but `--restart` doesnt work properly if `xmonad` is not in `$PATH`)
1111
1. Append `xmonad` or `xmonad-afreak` to .xinitrc

package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
- base >= 4.7 && < 5
2121

2222
library:
23-
source-dirs: src
23+
source-dirs: shared
2424
# dependencies:
2525
# - directory
2626

scripts/build

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,34 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
STACK_COMMAND=stack
5+
ENV_FILE=~/.xmonad/.env
6+
7+
if [ -f $ENV_FILE ]; then
8+
source $ENV_FILE
9+
fi
210
# The directory holding your source code and stack.yaml file:
311
SRC_DIR=~/coding/Xmonanza/
12+
13+
#check if src has changed`
14+
sum_file="xmonanza_sum_file"
15+
sum=$(find $SRC_DIR -type f | xargs -d'\n' -P0 -n1 md5sum | sort -k 2 | md5sum)
16+
if [ -f "$1" ] && [ -f "$sum_file" ] && [ "${sum}" = "$(cat ${sum_file})" ]; then
17+
echo "Skipping xmonanza build as content has not changed"
18+
exit
19+
fi
20+
echo -n "${sum}" > ${sum_file}
21+
422
# The name of the executable produced by stack. This comes from the
523
# executable section of your *.cabal or package.yaml file.
624
EXE_NAME=xmonad-afreak
25+
26+
# Do the build.
727
# Unset STACK_YAML, to ensure that $SRC_DIR/stack.yaml is used.
828
unset STACK_YAML
9-
#
10-
# Do the build.
1129
cd $SRC_DIR
12-
stack build
30+
$STACK_COMMAND install
1331

1432
# Create a hard link at the requested destination, replacing any existing one.
15-
ln -f -T $(stack exec -- which $EXE_NAME) $1
33+
EXE_LOCATION=$($STACK_COMMAND exec -- which $EXE_NAME)
34+
ln -f -T "$EXE_LOCATION" "$1"

shared/AConfig.hs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module AConfig (getConfig, AConfig(..)) where
2+
3+
data AConfig = AConfig
4+
{ cl_black :: String
5+
, cl_current_line :: String
6+
, cl_selection :: String
7+
, cl_comment :: String
8+
, cl_grey :: String
9+
, cl_red :: String
10+
, cl_orange:: String
11+
, cl_yellow:: String
12+
, cl_green :: String
13+
, cl_aqua :: String
14+
, cl_blue :: String
15+
, cl_lilly :: String
16+
, cl_font :: String
17+
, cl_barHeight :: Int
18+
} deriving (Show)
19+
20+
getConfig :: AConfig
21+
getConfig = AConfig
22+
{ cl_black = "#2D2D2D"
23+
, cl_current_line = "#393939"
24+
, cl_selection = "#515151"
25+
, cl_comment = "#999999"
26+
, cl_grey = "#CCCCCC"
27+
, cl_red = "#F2777A"
28+
, cl_orange= "#f99157"
29+
, cl_yellow= "#ffcc66"
30+
, cl_green = "#99cc99"
31+
, cl_aqua = "#66CCCC"
32+
, cl_blue = "#6699cc"
33+
, cl_lilly = "#CC99CC"
34+
, cl_font = "xft:Hack Nerd Font:size=13:Regular:antialias=true"
35+
, cl_barHeight=45
36+
}

src/AConfig.hs

Lines changed: 0 additions & 25 deletions
This file was deleted.

stack.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,35 @@ flags:
4747
xmobar:
4848
with_xft: true
4949
with_alsa: true
50+
nix:
51+
# enable: true
52+
pure: true
53+
# packages:
54+
# - haskellPackages.xmonad
55+
# - haskellPackages.xmonad-contrib
56+
# - haskellPackages.xmobar
57+
# - zlib
58+
# # need which for getting the executable for linking to it :)
59+
# - which
5060

61+
packages:
62+
# - cairo
63+
# - gcc
64+
# - gnome2.pango
65+
# - gtk2-x11
66+
# - libxml2
67+
# - pkgconfig
68+
# - upower
69+
- x11
70+
- xorg.libX11
71+
- xorg.libXext
72+
- xorg.libXinerama
73+
- xorg.libXrandr
74+
- xorg.libXrender
75+
- xorg.libXScrnSaver
76+
- alsaLib
77+
- which
78+
5179
# Override default flag values for local packages and extra-deps
5280
# flags: {}
5381

xmobar/Main.hs

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,49 @@
11
import Xmobar
22
import AConfig (getConfig, AConfig (..))
33

4+
-- fcClr :: [Char] -> [Char] -> [Char]
5+
-- fcClr clr str = "<fc="++clr++">"++str++"</fc>"
6+
7+
cmds :: AConfig -> [Runnable]
8+
cmds cnf =
9+
[ Run $ Network "wlp58s0"
10+
["-L","0","-H","32000", "-m", "3",
11+
"--normal",cl_grey cnf,"--high",cl_red cnf,
12+
"-t", "<rx>KB /<tx>KB"] 50
13+
, Run $ MultiCpu
14+
["--low", cl_aqua cnf, "--normal", cl_grey cnf,"--high",cl_red cnf,
15+
"-t", "<total>%"] 50
16+
, Run $ Memory
17+
[ "--normal",cl_grey cnf,"--high",cl_red cnf,
18+
"-m", "2", "-L", "0", "-H", "90",
19+
"-t","<usedratio>%"] 50
20+
, Run $ Date "%a %b %_d %H:%M" "date" 600
21+
, Run $ Alsa "default" "Master"
22+
[ "--low", cl_aqua cnf, "--normal",cl_grey cnf,"--high",cl_red cnf,
23+
"-t", "<volume>%"]
24+
, Run $ MultiCoreTemp
25+
["--low", cl_aqua cnf, "--normal",cl_grey cnf,"--high",cl_red cnf,
26+
"-t", "<avg>°C"] 50
27+
, Run $ UnsafeStdinReader
28+
, Run $ BatteryP ["BAT0"]
29+
["-t", "<acstatus><left>% <timeleft> <watts>",
30+
"-L", "10", "-H", "80", "-p", "3",
31+
"--",
32+
"-O", "\xf58e", "-o", "\xf58b", "-i", "",
33+
"-L", "-20", "-H", "-10",
34+
"-l", cl_grey cnf, "-m", cl_aqua cnf, "-h", cl_red cnf, "-p", cl_green cnf,
35+
"-a", "notify-send -u critical 'Battery running out!!'",
36+
"-A", "3"]
37+
100
38+
]
39+
440
config :: AConfig -> Config
541
config cnf =
642
Config { verbose = False
743
, wmClass = "xmobar"
844
, wmName = "xmobar"
945
, border = NoBorder
10-
, borderColor = "#BFBFBF"
46+
, borderColor = cl_orange cnf
1147
, borderWidth = 1
1248
, textOffsets = []
1349
, font = cl_font cnf
@@ -23,24 +59,14 @@ config cnf =
2359
, pickBroadest = False
2460
, persistent = False
2561
, hideOnStart = False
26-
, iconRoot = cl_iconRoot cnf
62+
, iconRoot = ""
2763
, allDesktops = True
2864
, overrideRedirect = True
29-
, commands = [ Run $ Network "enp0s31f6" ["-L","0","-H","32000", "-m", "3", "--normal",cl_aqua cnf,"--high",cl_red cnf, "-t", "<rx>KB|<tx>KB"] 50
30-
, Run $ MultiCpu [ "--low", cl_aqua cnf, "--normal",cl_aqua cnf,"--high",cl_red cnf, "-t", "<total>%"] 50
31-
, Run $ Memory ["-t","<usedratio>%", "-L", "0", "-H", "90", "--normal",cl_aqua cnf,"--high",cl_red cnf, "-m", "2"] 50
32-
, Run $ Date "%a %b %_d %H:%M" "date" 600
33-
, Run $ Alsa "default" "Master" ["-t", "<volume>%", "--low", cl_aqua cnf, "--normal",cl_aqua cnf,"--high",cl_red cnf]
34-
, Run $ Com "nvidia-settings" ["-t","-q","[gpu:0]/GPUCoreTemp" ] "gputemp" 50
35-
, Run $ MultiCoreTemp [ "--low", cl_aqua cnf, "--normal",cl_aqua cnf,"--high",cl_red cnf, "-t", "<avg>°C"] 50
36-
, Run $ CatInt 0 "/sys/devices/platform/nct6775.2592/hwmon/hwmon3/fan2_input" [
37-
"-L", "0", "-H", "1082", "--normal",cl_aqua cnf,"--high",cl_red cnf] 50
38-
, Run $ UnsafeStdinReader
39-
]
65+
, commands = cmds cnf
4066
, sepChar = "%"
4167
, alignSep = "}{"
4268
, template = "%UnsafeStdinReader%}\
43-
\{<icon=volume.xpm/> %alsa:default:Master% | %enp0s31f6% | <icon=memory.xpm/> %memory% | <icon=cpu.xpm/> %multicpu% %multicoretemp% %cat0% | <icon=gpu.xpm/> %gputemp%°C | <fc=" ++ cl_lilly cnf ++ ">%date%</fc>"
69+
\{奔 %alsa:default:Master% | ﯱ %wlp58s0% | %battery% | \xf85a %memory% | \xfb19 %multicpu% %multicoretemp% | %date%"
4470
}
4571

4672
main :: IO ()

xmonad/BackAndForth.hs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module BackAndForth (backAndForth) where
2+
3+
import XMonad
4+
import qualified XMonad.Hooks.WorkspaceHistory as WH
5+
import XMonad.StackSet
6+
7+
-- needs
8+
-- workspaceHistoryHook
9+
-- attatched to ur loghook
10+
11+
backAndForth :: WorkspaceId -> X ()
12+
backAndForth toWS = do
13+
cur <- gets (currentTag . windowset)
14+
if toWS == cur
15+
then WH.workspaceHistory >>= showPreviousWindow
16+
else windows (greedyView toWS)
17+
18+
showPreviousWindow :: [WorkspaceId] -> X ()
19+
showPreviousWindow (_:znd:_) = windows (greedyView znd)
20+
showPreviousWindow _ = return ()
21+

xmonad/Calculator.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module Calculator (calculatorPrompt) where
2+
import XMonad (MonadIO, X)
3+
import XMonad.Prompt (XPrompt, showXPrompt, completionToCommand, XPConfig, mkXPrompt)
4+
import XMonad.Util.Run (runProcessWithInput)
5+
6+
data CalculatorMode = CalculatorMode
7+
8+
instance XPrompt CalculatorMode where
9+
showXPrompt CalculatorMode = "calc> "
10+
completionToCommand _ = id
11+
12+
calculatorPrompt :: XPConfig -> X ()
13+
calculatorPrompt c = mkXPrompt CalculatorMode c doCalc (\_ -> return ())
14+
15+
doCalc :: MonadIO m => [Char] -> m [String]
16+
doCalc [] = return []
17+
doCalc s = fmap lines $ fmap stripTab $ runProcessWithInput "calc" [s] ""
18+
19+
stripTab (_:xs) = xs
20+
stripTab [] = []

0 commit comments

Comments
 (0)