-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathset-bg-host
executable file
·55 lines (46 loc) · 1.64 KB
/
set-bg-host
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/zsh
function __calculate_iterm_window_dimensions {
applescript="tell application \"iTerm\"
get bounds of window 1
end tell"
size=($(osascript -e $applescript | tr ',' ' '))
x1=${size[1]} y1=${size[2]} x2=${size[3]} y2=${size[4]}
# 15px - scrollbar width
w=$(( $x2 - $x1 ))
# 44px - titlebar + tabs height
h=$(( $y2 - $y1 - 44))
echo "${w}x${h}"
}
# Console dimensions
DIMENSIONS=$(__calculate_iterm_window_dimensions)
a=(${(s/x/)DIMENSIONS})
WIDTH=$(($a[1]-32))
HEIGHT=$(($a[2]-32))
HOSTNAME=$(/usr/bin/base-hostname "$@")
DESTFILE="/tmp/iTermBG.$HOSTNAME.png"
LOCALHOST=`uname -n | cut -d '.' -f1 | tr '[A-Z]' '[a-z]'`
# Check whether we are on localhost
if [[ "$HOSTNAME" == "$LOCALHOST" ]]
then
# Colors for local
BG_COLOR="#121212" # Background color
FG_COLOR="#454545" # Foreground color
else
# Colors for remote
BG_COLOR="#341212" # Background color
FG_COLOR="#454545" # Foreground color
fi
GRAVITY="SouthEast" # Text gravity (NorthWest, North, NorthEast,
FONT_SIZE="20" # Font size in points
FONT="Helvetica-Light"
OFFSET_X=35
OFFSET_Y=04
# if [ ! -f /tmp/iTermBG.${HOSTNAME}.png ]; then
convert -crop ${DIMENSIONS}-$WIDTH-$HEIGHT\! /usr/bin/Apple.png \
-background "$BG_COLOR" -flatten -quality 100 -gravity "$GRAVITY" -font "$FONT" -pointsize "$FONT_SIZE" -antialias -alpha Off \
-fill black -annotate +$(($OFFSET_X+1))+$(($OFFSET_Y+1)) "$HOSTNAME" \
-fill "#323232" -annotate +$(($OFFSET_X-1))+$(($OFFSET_Y-1)) "$HOSTNAME" \
-fill "#252525" -annotate +$OFFSET_X+$OFFSET_Y "$HOSTNAME" \
$DESTFILE
# fi
/usr/bin/set-bg $DESTFILE