Skip to content

Commit

Permalink
Merge pull request #357 from iyegoroff/xkb-custom-icon
Browse files Browse the repository at this point in the history
Made keyboard icon customizable
  • Loading branch information
erikw authored Feb 10, 2024
2 parents 42f06c1 + 0e10d39 commit fa164e9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion segments/xkb_layout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@
# This script will print the correct layout even if layout is set per window.
# Exit if platform is not linux as this script is dependant on X11

TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON_DEFAULT=""

generate_segmentrc() {
read -d '' rccontents << EORC
# Keyboard icon
export TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON="${TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON_DEFAULT}"
EORC
echo "$rccontents"
}


run_segment() {
__process_settings

if ! shell_is_linux; then
return 1
fi
Expand All @@ -25,8 +38,14 @@ run_segment() {
cur_layout_nbr=$(($(./xkb_layout)+1));
cur_layout=$(setxkbmap -query | grep layout | sed 's/layout:\s\+//g' | \
awk -F ',' '{print $'$(echo "$cur_layout_nbr")'}')
echo " $cur_layout"
echo "$TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON $cur_layout"
else
return 1
fi
}

__process_settings() {
if [ -z "$TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON" ]; then
export TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON="${TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON_DEFAULT}"
fi
}

0 comments on commit fa164e9

Please sign in to comment.