Skip to content

Commit fa164e9

Browse files
authored
Merge pull request #357 from iyegoroff/xkb-custom-icon
Made keyboard icon customizable
2 parents 42f06c1 + 0e10d39 commit fa164e9

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

segments/xkb_layout.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@
1111
# This script will print the correct layout even if layout is set per window.
1212
# Exit if platform is not linux as this script is dependant on X11
1313

14+
TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON_DEFAULT=""
15+
16+
generate_segmentrc() {
17+
read -d '' rccontents << EORC
18+
# Keyboard icon
19+
export TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON="${TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON_DEFAULT}"
20+
EORC
21+
echo "$rccontents"
22+
}
23+
24+
1425
run_segment() {
26+
__process_settings
27+
1528
if ! shell_is_linux; then
1629
return 1
1730
fi
@@ -25,8 +38,14 @@ run_segment() {
2538
cur_layout_nbr=$(($(./xkb_layout)+1));
2639
cur_layout=$(setxkbmap -query | grep layout | sed 's/layout:\s\+//g' | \
2740
awk -F ',' '{print $'$(echo "$cur_layout_nbr")'}')
28-
echo " $cur_layout"
41+
echo "$TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON $cur_layout"
2942
else
3043
return 1
3144
fi
3245
}
46+
47+
__process_settings() {
48+
if [ -z "$TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON" ]; then
49+
export TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON="${TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON_DEFAULT}"
50+
fi
51+
}

0 commit comments

Comments
 (0)