home: major restructuring

needs more work
This commit is contained in:
2022-03-15 10:42:50 +05:30
parent 81452ba490
commit ed3bf181ef
35 changed files with 326 additions and 435 deletions

View File

@@ -0,0 +1,61 @@
/* XPM */
static char *bigger[] = {
/* columns rows colors chars-per-pixel */
"25 22 33 1 ",
" c None",
". c #5277C3",
"X c #5278C3",
"o c #5378C3",
"O c #557BC5",
"+ c #557CC6",
"@ c #567CC6",
"# c #567DC6",
"$ c #577EC6",
"% c #577EC7",
"& c #5880C7",
"* c #5981C8",
"= c #5C87CB",
"- c #5F8BCC",
"; c #608CCE",
": c #618DCE",
"> c #6594D1",
", c #6A9BD5",
"< c #6C9DD6",
"1 c #6C9ED6",
"2 c #6C9FD6",
"3 c #6DA0D7",
"4 c #71A6DA",
"5 c #76ADDE",
"6 c #76AEDE",
"7 c #79B2E0",
"8 c #79B3E0",
"9 c #7AB4E1",
"0 c #7BB4E1",
"q c #7CB7E2",
"w c #7CB7E3",
"e c #7DB8E3",
"r c #7EBAE4",
/* pixels */
" .. rr r ",
" .. rr rr ",
" ... rrrrr ",
" ... rrrrr ",
" ........O2err ",
" ..........=6rr . ",
" rrr .. ",
" rr rrr ... ",
" rrr rq>X. ",
" rrr r4$X... ",
"rrrrrrrr :X..... ",
"rrrrrr7< ....... ",
" rre3$ ... ",
" rr9-o. .X ",
" rr $.. *$O ",
" rr ...2rrrr667rrrr ",
" r ..:7rrrrrrrrr ",
" ...$,rrrrrrrrr ",
" ..... rrr ",
" ... .. rr ",
" .. ... rr ",
" "
};

View File

@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Taken from https://github.com/jaor/xmobar/blob/master/examples/padding-icon.sh
# Detects the width of running window with name given as first
# argument (xprop name '$1') and creates an XPM icon of that width,
# 1px height, and transparent. Outputs an <icon>-tag for use in
# xmobar to display the generated XPM icon.
#
# Run script from xmobar and trayer:
# `Run Com "/where/ever/padding-icon.sh" ["panel"] "trayerpad" 10`
# and use `%trayerpad%` in your template.
# or, if you're using for instance stalonetray:
# `Run Com "/where/ever/padding-icon.sh" ["stalonetray"] "tray" 10`
# Very heavily based on Jonas Camillus Jeppensen code
# https://github.com/jaor/xmobar/issues/239#issuecomment-233206552
# Function to create a transparent Wx1 px XPM icon
create_xpm_icon () {
timestamp=$(date)
pixels=$(for i in `seq $1`; do echo -n "."; done)
cat << EOF > "$2"
/* XPM *
static char * trayer_pad_xpm[] = {
/* This XPM icon is used for padding in xmobar to */
/* leave room for trayer-srg. It is dynamically */
/* updated by by trayer-pad-icon.sh which is run */
/* by xmobar. */
/* Created: ${timestamp} */
/* <w/cols> <h/rows> <colors> <chars per pixel> */
"$1 1 1 1",
/* Colors (none: transparent) */
". c none",
/* Pixels */
"$pixels"
};
EOF
}
# panel window name
pname=${1:-panel}
# Width of the trayer window
width=$(xprop -name $pname | grep 'program specified minimum size' | cut -d ' ' -f 5)
# Icon file name
iconfile="/tmp/$pname-padding-${width:-0}px.xpm"
# If the desired icon does not exist create it
if [ ! -f $iconfile ]
then
create_xpm_icon $width $iconfile
fi
# Output the icon tag for xmobar
echo "<icon=${iconfile}/>"

View File

@@ -0,0 +1,49 @@
import Xmobar
bg, fg, grey, red, green, yellow, blue, magenta, cyan, white, sep :: String
sep = "<fc=" ++ cyan ++ ">║</fc>"
bg = "#1d1f21"
fg = "#c5c8c6"
grey = "#969896"
red = "#cc6666"
green = "#b5bd68"
yellow = "#f0c674"
blue = "#81a2be"
magenta = "#b294bb"
cyan = "#8abeb7"
white = "#ecebec"
config :: Config
config =
defaultConfig
{ font = "xft:Fira Mono:style=Regular:antialias=true:pixelsize,Font Awesome 5 Brands:pixelsize=16,Font Awesome 5 Free:pixelsize=16:style=Solid,Lohit Devanagari:style=Regular:pixelsize=16,Lohit Gurmukhi:style=Regular:pixelsize=16,Noto Sans CJK JP:style=Regular:pixelsize=16,Noto Sans CJK KR:style=Regular:pixelsize=16,Noto Sans CJK SC:style=Regular:pixelsize=16",
additionalFonts =
[ "xft:Font Awesome 5 Free:pixelsize=15:style=Solid",
"xft:Font Awesome 5 Brands:pixelsize=15"
],
position = Static { xpos = 0, ypos = 0, height = 23, width = 1920 },
bgColor = bg,
fgColor = fg,
lowerOnStart = False,
overrideRedirect = False,
allDesktops = True,
persistent = True,
commands =
[ Run $ MultiCpu ["-t", "<fn=1>\xf2db</fn> <total>%", "-L", "20", "-H", "80", "-h", magenta, "-l", green, "-n", yellow] 10,
Run $ Memory ["-t", "<fn=1>\xf538</fn> <usedratio>%", "-H", "10240", "-L", "6144", "-h", magenta, "-l", green, "-n", yellow] 20,
Run $ BatteryP ["BAT1", "BAT0", "BAT2"] ["-t", "<acstatus>", "-L", "10", "-H", "80", "-l", magenta, "-h", green, "-n", yellow, "--", "-O", "Charging", "-o", "<left>%", "-a", "notify-send -u critical 'Battery running out!'", "-A", "5", "--lows", "<fn=1>\xf243</fn> ", "--mediums", "<fn=1>\xf242</fn> ", "--highs", "<fn=1>\xf240</fn> "] 300,
Run $ Network "wlp0s20f3" ["-t", "<fn=1>\xf1eb</fn> <fc=" ++ magenta ++ "><rx>/<tx></fc>"] 10,
Run $ Date "<fn=1>\xf073</fn> %-d/%-m/%-y/%w" "date" 10000,
Run $ Date "%H:%M:%S" "time" 10,
Run $ MPD ["-t", "<statei><title><fn=" ++ magenta ++ "> \xf001</fn>", "--", "-P", ">> ", "-Z", "|| ", "-S", "Stopped", "-h", "127.0.0.1", "-p", "6600"] 10,
Run $ Com "/home/natto/.xmonad/lib/padding-icon.sh" ["stalonetray"] "tray" 10,
Run $ Com "pamixer" ["--get-volume"] "" 100,
Run UnsafeStdinReader
],
sepChar = "*",
alignSep = "--",
template = "<action=`dmenu_run` button=1><icon=/home/natto/.xmonad/lib/nixos.xpm/></action> *UnsafeStdinReader* " ++ sep ++ " <fn=1></fn>*mpd* -- *multicpu* " ++ sep ++ " *memory* " ++ sep ++ " *wlp0s20f3* " ++ sep ++ " *battery* " ++ sep ++ " <fn=1>\xf028</fn> <fc=" ++ green ++ ">*pamixer*%</fc> " ++ sep ++ " *date* - *time* " ++ sep ++ "*tray*"
}
main :: IO ()
main = xmobar config

View File

@@ -0,0 +1,257 @@
import System.IO
import System.Exit
import XMonad
import XMonad.Hooks.SetWMName
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.DynamicLog
import XMonad.Layout.NoBorders
import XMonad.Layout.Spacing (smartSpacing)
import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns
import XMonad.Layout.ResizableTile
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run (spawnPipe)
import XMonad.Actions.FloatKeys (keysMoveWindow,
keysResizeWindow)
import Graphics.X11.ExtraTypes.XF86
import XMonad.Actions.CycleWindows
import qualified XMonad.StackSet as W
import qualified Data.Map as M
--colors
bgColor = "#1d1f21"
fgColor = "#c5c8c6"
activeWinColor = "#f0c674"
inactiveWinColor = "#b294bb"
urgentWinColor = "#cc6666"
miscColor = "#8abeb7"
myBorderWidth = 2
myTerminal = "/usr/bin/env st"
myFocusFollowsMouse = True
myNormalBorderColor = bgColor
myModMask = mod4Mask
myFocusedBorderColor = fgColor
myManageHook = composeAll
[ className =? "Discord" --> doFloat
, className =? "Anki" --> doFloat
]
tabConfig = defaultTheme {
activeTextColor = bgColor,
activeColor = fgColor,
inactiveTextColor = fgColor,
inactiveColor = bgColor
}
myXmobarrc = "~/.xmonad/lib/xmobar.hs"
myWorkspaces = clickable $ ["\xf269", "\xf120", "\xf121", "\xf392", "\xf008", "\xf07b", "\xf11b", "\xf086", "\xf074" ]
where clickable l = ["<action=`xdotool key super+" ++ show (n) ++ "`>" ++ ws ++ "</action>" | (i,ws) <- zip [1..9] l, let n = i ]
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
[ ((modMask, xK_Return),
spawn $ XMonad.terminal conf)
, ((modMask, xK_d),
spawn "/usr/bin/env dmenu_run -l 20")
, ((shiftMask, xK_Print),
spawn "flameshot gui")
, ((0, xK_Print),
spawn "flameshot full -p /home/natto/Pictures")
, ((mod1Mask, xK_Print),
spawn "flameshot gui -d 10000")
, ((modMask, xK_p),
spawn "mpc toggle")
, ((modMask, xK_h),
spawn "mpc next")
, ((modMask, xK_k),
spawn "mpc prev")
, ((modMask .|. shiftMask, xK_a),
spawn "mpc seek -00:00:05")
, ((modMask .|. shiftMask, xK_s),
spawn "mpc seek +00:00:05")
, ((modMask .|. shiftMask, xK_period),
spawn "pamixer --allow-boost -i 5")
, ((modMask .|. shiftMask, xK_comma),
spawn "pamixer --allow-boost -d 5")
, ((modMask .|. shiftMask, xK_q), kill)
, ((mod1Mask, xK_Tab),
cycleRecentWindows [xK_Alt_L] xK_Tab xK_q)
, ((modMask .|. mod1Mask, xK_0), spawn "light -A 5")
, ((modMask .|. mod1Mask, xK_9), spawn "light -U 5")
, ((modMask .|. shiftMask, xK_F1),
spawn "setxkbmap us-colemak")
, ((modMask .|. shiftMask, xK_F2),
spawn "setxkbmap us basic")
, ((modMask .|. shiftMask, xK_F3),
spawn "setxkbmap in deva")
, ((modMask .|. shiftMask, xK_F4),
spawn "setxkbmap in guru")
, ((modMask, xK_space),
sendMessage NextLayout)
, ((modMask, xK_f),
toggleFullscreen)
, ((modMask .|. shiftMask, xK_space),
setLayout $ XMonad.layoutHook conf)
, ((modMask, xK_r),
refresh)
, ((modMask, xK_n),
windows W.focusDown)
, ((modMask, xK_e), windows W.focusUp )
, ((modMask .|. shiftMask, xK_h),
windows W.focusMaster )
, ((modMask .|. shiftMask, xK_Return),
windows W.swapMaster)
, ((modMask .|. shiftMask, xK_n),
windows W.swapDown )
, ((modMask .|. shiftMask, xK_e),
windows W.swapUp )
, ((mod1Mask, xK_m),
sendMessage Expand)
, ((mod1Mask, xK_i),
sendMessage Shrink)
, ((mod1Mask, xK_n),
sendMessage MirrorExpand)
, ((mod1Mask, xK_e),
sendMessage MirrorShrink)
, ((modMask .|. mod1Mask .|. shiftMask, xK_m),
withFocused (keysMoveWindow (-30, 0)))
, ((modMask .|. mod1Mask .|. shiftMask, xK_i),
withFocused (keysMoveWindow (30, 0)))
, ((modMask .|. mod1Mask .|. shiftMask, xK_n),
withFocused (keysMoveWindow (0, 30)))
, ((modMask .|. mod1Mask .|. shiftMask, xK_e),
withFocused (keysMoveWindow (0, -30)))
, ((modMask, xK_t),
withFocused $ windows . W.sink)
, ((modMask, xK_comma),
sendMessage (IncMasterN 1))
, ((modMask, xK_period),
sendMessage (IncMasterN (-1)))
, ((modMask .|. mod1Mask, xK_f),
io (exitWith ExitSuccess))
, ((modMask .|. mod1Mask, xK_r),
restart "xmonad" True)
]
++
[((m .|. modMask, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
myLayoutHook = smartSpacing 8 $ smartBorders $ avoidStruts (
ResizableTall 1 (3/100) (3/5) [] |||
spiral (6/7) |||
tabbed shrinkText tabConfig |||
ThreeCol 1 (3/100) (1/2) |||
Tall 1 (3/100) (1/2) |||
Mirror (Tall 1 (3/100) (1/2)) |||
Full)
-- {{{source: https://github.com/liskin/dotfiles/commit/659af2ec68c26044f9e6ddf11655856613285685#diff-f3bd9f70ef878f30362ff11bbea7fd1d0d6abde1b4befa44b18cce5a27456204R190
toggleFullscreen =
withWindowSet $ \ws ->
withFocused $ \w -> do
let fullRect = W.RationalRect 0 0 1 1
let isFullFloat = w `M.lookup` W.floating ws == Just fullRect
windows $ if isFullFloat then W.sink w else W.float w fullRect
--}}}
--{{{
--couldnt get fullScreenEventHook to work normally so using this for now
--source code: https://github.com/xmonad/xmonad-contrib/blob/v0.16/XMonad/Hooks/EwmhDesktops.hs
fullscreenFix :: XConfig a -> XConfig a
fullscreenFix c = c {
startupHook = startupHook c +++ setSupportedWithFullscreen
}
where x +++ y = mappend x y
setSupportedWithFullscreen :: X ()
setSupportedWithFullscreen = withDisplay $ \dpy -> do
r <- asks theRoot
a <- getAtom "_NET_SUPPORTED"
c <- getAtom "ATOM"
supp <- mapM getAtom ["_NET_WM_STATE_HIDDEN"
,"_NET_WM_STATE_FULLSCREEN"
,"_NET_NUMBER_OF_DESKTOPS"
,"_NET_CLIENT_LIST"
,"_NET_CLIENT_LIST_STACKING"
,"_NET_CURRENT_DESKTOP"
,"_NET_DESKTOP_NAMES"
,"_NET_ACTIVE_WINDOW"
,"_NET_WM_DESKTOP"
,"_NET_WM_STRUT"
]
io $ changeProperty32 dpy r a c propModeReplace (fmap fromIntegral supp)
setWMName "xmonad"
--}}}
main = do xmproc <- spawnPipe ("xmobar " ++ myXmobarrc)
xmonad $ docks $ fullscreenFix $ ewmh def
{ borderWidth = myBorderWidth
, manageHook = manageDocks <+> myManageHook
, handleEventHook = handleEventHook def <+> fullscreenEventHook
, terminal = myTerminal
, focusFollowsMouse = myFocusFollowsMouse
, normalBorderColor = myNormalBorderColor
, layoutHook = myLayoutHook
, modMask = myModMask
, keys = myKeys
, focusedBorderColor = myFocusedBorderColor
, workspaces = myWorkspaces
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppCurrent = xmobarColor activeWinColor "" . wrap "(" ")"
, ppVisible = xmobarColor activeWinColor ""
, ppHidden = xmobarColor inactiveWinColor ""
, ppTitle = xmobarColor fgColor "" . shorten 40
, ppLayout = const ""
, ppUrgent = xmobarColor urgentWinColor "" . wrap "!" ""
, ppSep = "<fc=" ++ miscColor ++ "> ║ </fc>"
}
}