This repository has been archived by the owner on Jul 19, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allocate the exact right amount of space for trayer!
Found this lovely hack over on https://github.com/jaor/xmobar/issues/239#issuecomment-233206552.
- Loading branch information
Showing
3 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}/>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters