diff --git a/trayer-padding-icon.sh b/trayer-padding-icon.sh new file mode 100755 index 0000000000000000000000000000000000000000..adee04a1ebddfdaf508778f2ea7c67f61828fd1b --- /dev/null +++ b/trayer-padding-icon.sh @@ -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}/>" diff --git a/xmobar.hs b/xmobar.hs index 1ae39060ac3d1f9df66268f61b55e61ba8083048..b44ab5c04cbb3938d4c5fa2f6f44bb68e47fd134 100644 --- a/xmobar.hs +++ b/xmobar.hs @@ -19,10 +19,11 @@ Config { font = "xft:HackNerdFont:size=10:antialias=true,IPAPGothic:size=10: , Run Com "/home/kubat/.local/libexec/get_pa_volume.sh" [] "volume" 2 , Run Com "/home/kubat/.local/libexec/is_vpn_running.sh" [] "vpn" 50 , Run Com "/usr/local/bin/lkt.sh" [ "current" ] "lektor" 5 + , Run Com "/home/kubat/.xmonad/trayer-padding-icon.sh" [] "trayerpad" 20 , Run StdinReader ] , allDesktops = False , sepChar = "%" , alignSep = "}{" - , template = " <icon=haskell_20.xpm/> %StdinReader% } %lektor% { %cpu% %coretemp% %memory% <fc=#b58900>Vol</fc> %volume% %vpn%%battery% | <fc=#b58900>%date%</fc> " + , template = " <icon=haskell_20.xpm/> %StdinReader% } %lektor% { %cpu% %coretemp% %memory% <fc=#b58900>Vol</fc> %volume% %vpn%%battery% | <fc=#b58900>%date%</fc> %trayerpad%" } diff --git a/xmonad.hs b/xmonad.hs index 9e089ded358e4ab537a75e5672afc54430b1336e..5387861d9bbf753020fb36c6789e75912ebaa8f4 100644 --- a/xmonad.hs +++ b/xmonad.hs @@ -131,9 +131,11 @@ myStartupHook = do spawnOnce "/home/kubat/.local/bin/xbanish" spawn "/home/kubat/.xmonad/init.sh" spawn "xrdb /home/kubat/.Xresources" + spawnOnce "twmnd &" + spawnOnce "nm-applet &" spawnOnce "feh --bg-scale /home/kubat/.xmonad/wallpaper &" spawn "setxkbmap kubat" - spawnOnce "twmnd &" + spawnOnce "trayer --edge top --align right --widthtype request --padding 6 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --tint 0x002b36 --transparent true --alpha 0 --height 18 &" myLayoutHook = minimize $ boringAuto (toggleLayouts (noBorders Full) others) @@ -230,8 +232,8 @@ myAdditionalKeys = ]) -- Volume, with pulseaudio - , ((mod4Mask, xK_F11), spawn "pavolume voldown 5") - , ((mod4Mask, xK_F12), spawn "pavolume volup 5") + , ((mod4Mask, xK_F11), spawn "pavolume voldown 5 --noshow") + , ((mod4Mask, xK_F12), spawn "pavolume volup 5 --noshow") , ((mod4Mask, xK_F10), spawn "pavolume mutetoggle") -- Lektord