Adding trayer to xmonad with script to adjust for trayer width.

This commit is contained in:
Derek Taylor 2020-05-16 21:17:15 -05:00
parent 5a7043c99a
commit 7f6f440a65
3 changed files with 52 additions and 3 deletions

View File

@ -0,0 +1,48 @@
#!/bin/sh
# Copied from https://github.com/jaor/xmobar/issues/239#issuecomment-233206552
# Detects the width of running trayer-srg window (xprop name 'panel')
# 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:
# `Run Com "/where/ever/trayer-padding-icon.sh" [] "trayerpad" 10`
# and use `%trayerpad%` in your template.
# 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-padding-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
}
# Width of the trayer window
width=$(xprop -name panel | grep 'program specified minimum size' | cut -d ' ' -f 5)
# Icon file name
iconfile="/tmp/trayer-padding-${width}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

@ -6,7 +6,7 @@ Config { font = "xft:Mononoki Nerd Font:pixelsize=12:antialias=true:hinting=t
, additionalFonts = [ "xft:FontAwesome:pixelsize=13" ]
, bgColor = "#292d3e"
, fgColor = "#B45BCF"
, position = TopW L 95
, position = TopW L 100
, lowerOnStart = True
, hideOnStart = False
, allDesktops = True
@ -30,9 +30,10 @@ Config { font = "xft:Mononoki Nerd Font:pixelsize=12:antialias=true:hinting=t
, Run Com "uname" ["-r"] "" 3600
-- Prints out the left side items such as workspaces, layout, etc.
-- The workspaces are 'clickable' in my configs.
, Run Com "/home/dt/.config/xmobar/trayer-padding-icon.sh" [] "trayerpad" 10
, Run UnsafeStdinReader
]
, sepChar = "%"
, alignSep = "}{"
, template = " <icon=haskell_20.xpm/> <fc=#666666>|</fc> %UnsafeStdinReader% }{ <fc=#666666>| </fc><fc=#b3afc2> %uname% </fc><fc=#666666>| </fc><fc=#FFB86C>%cpu% </fc><fc=#666666>| </fc><fc=#FF5555>%memory% </fc><fc=#666666>| </fc><fc=#82AAFF>%disku% </fc><fc=#666666>| </fc><fc=#c3e88d>%enp6s0% </fc><fc=#666666>| </fc><fc=#e1acff> %pacupdate%</fc><fc=#666666>| </fc><fc=#8BE9FD>%date% </fc><fc=#666666>| </fc> "
, template = " <icon=haskell_20.xpm/> <fc=#666666>|</fc> %UnsafeStdinReader% }{ <fc=#666666>| </fc><fc=#b3afc2> %uname% </fc><fc=#666666>| </fc><fc=#FFB86C>%cpu% </fc><fc=#666666>| </fc><fc=#FF5555>%memory% </fc><fc=#666666>| </fc><fc=#82AAFF>%disku% </fc><fc=#666666>| </fc><fc=#c3e88d>%enp6s0% </fc><fc=#666666>| </fc><fc=#e1acff> %pacupdate%</fc><fc=#666666>| </fc><fc=#8BE9FD>%date% </fc><fc=#666666>| </fc> %trayerpad%"
}

View File

@ -115,7 +115,7 @@ myStartupHook = do
spawnOnce "picom &"
spawnOnce "nm-applet &"
spawnOnce "volumeicon &"
spawnOnce "trayer --edge top --align right --width 5 --padding 5 --margin 5 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --transparent true --alpha 0 --tint 0x292d3e --height 18 &"
spawnOnce "trayer --edge top --align right --widthtype request --margin 5 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --transparent true --alpha 0 --tint 0x292d3e --height 18 &"
--spawnOnce "emacs --daemon &"
setWMName "LG3D"