Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
Allocate the exact right amount of space for trayer!
Browse files Browse the repository at this point in the history
  • Loading branch information
jfly committed Mar 19, 2018
1 parent a2eda07 commit ce0c503
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
49 changes: 49 additions & 0 deletions bin/trayer-padding-icon.sh
@@ -0,0 +1,49 @@
#!/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}/>"
2 changes: 1 addition & 1 deletion bootstrap-arch.sh
Expand Up @@ -140,7 +140,7 @@ laptop_stuff() {
# driconf is supposed to help with video tearing (see http://www.apolitech.com/2017/04/20how-to-solve-video-tearing-on-intel.html)
arch_package xf86-video-intel driconf
# Install everything else needed for the desktop environment.
arch_package xorg-server xorg-xinit xorg-xsetroot xorg-xmodmap xorg-xmessage xorg-xrandr xorg-xrdb xorg-xinput
arch_package xorg-server xorg-xinit xorg-xsetroot xorg-xmodmap xorg-xmessage xorg-xrandr xorg-xrdb xorg-xinput xorg-xprop
arch_package xmonad xmonad-contrib xmobar
arch_package feh wmname network-manager-applet alsa-utils maim xclip numlockx xsel xdotool slop byzanz dunst
arch_package termite chromium
Expand Down
5 changes: 3 additions & 2 deletions xmobarrc
Expand Up @@ -2,13 +2,14 @@ Config {
font = "xft:Ubuntu Mono Regular:size=6:bold:antialias=true"
, bgColor = "black"
, fgColor = "grey"
, position = TopW L 90
, position = TopW L 100
, commands = [ Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Date "%a %b %_d %l:%M" "date" 10

, Run Com "get_volume.py" [] "myvolume" 10
, Run Com "get_bathroom_status.sh" [] "h4bathroom" 100
, Run Com "trayer-padding-icon.sh" [] "trayerpad" 100
-- battery monitor
, Run Battery [ "--template" , "Batt: <acstatus>"
, "--Low" , "10" -- units: %
Expand All @@ -29,5 +30,5 @@ Config {
]
, sepChar = "%"
, alignSep = "}{"
, template = "%StdinReader% }{ %h4bathroom%Vol: %myvolume% | %battery% | %cpu% | %memory% <fc=#ee9a00>%date%</fc>"
, template = "%StdinReader% }{ %h4bathroom%Vol: %myvolume% | %battery% | %cpu% | %memory% <fc=#ee9a00>%date%</fc> %trayerpad%"
}

0 comments on commit ce0c503

Please sign in to comment.