From 1c9af65069da8352832447f52cf0ecc6f6a3b40d Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 8 Jan 2022 13:51:41 +0900 Subject: [PATCH 1/4] plugins/battery: Remove composure.sh annotations --- plugins/battery/battery.plugin.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/battery/battery.plugin.sh b/plugins/battery/battery.plugin.sh index 47c7621..de164a3 100644 --- a/plugins/battery/battery.plugin.sh +++ b/plugins/battery/battery.plugin.sh @@ -55,10 +55,10 @@ ac_adapter_disconnected(){ fi } +## @fn battery_percentage +## @about 'displays battery charge as a percentage of full (100%)' +## @group 'battery' battery_percentage(){ - about 'displays battery charge as a percentage of full (100%)' - group 'battery' - if command_exists upower; then local UPOWER_OUTPUT=$(_omb_plugin_battery__upower_print_info | sed -n 's/.*percentage[:[:blank:]]*\([0-9%]\{1,\}\)$/\1/p') @@ -128,10 +128,10 @@ battery_percentage(){ fi } +## @fn battery_charge +## @about 'graphical display of your battery charge' +## @group 'battery' battery_charge(){ - about 'graphical display of your battery charge' - group 'battery' - # Full char local F_C='▸' # Depleted char From 548fbb188c5dccc0efc79aceb31f1f06553f376a Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 8 Jan 2022 14:34:22 +0900 Subject: [PATCH 2/4] plugins/battery: Fix an error message on no battery systems --- plugins/battery/battery.plugin.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/battery/battery.plugin.sh b/plugins/battery/battery.plugin.sh index de164a3..6aa065d 100644 --- a/plugins/battery/battery.plugin.sh +++ b/plugins/battery/battery.plugin.sh @@ -62,7 +62,8 @@ battery_percentage(){ if command_exists upower; then local UPOWER_OUTPUT=$(_omb_plugin_battery__upower_print_info | sed -n 's/.*percentage[:[:blank:]]*\([0-9%]\{1,\}\)$/\1/p') - echo ${UPOWER_OUTPUT: : -1} + [[ $UPOWER_OUTPUT ]] && + echo "${UPOWER_OUTPUT::-1}" elif command_exists acpi; then local ACPI_OUTPUT=$(acpi -b) From 6b2d92efbde406987e9b92d5ee9105b8a2b2ac56 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 8 Jan 2022 14:35:55 +0900 Subject: [PATCH 3/4] themes/kitsune: Add a proper dependency --- themes/kitsune/kitsune.theme.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/kitsune/kitsune.theme.sh b/themes/kitsune/kitsune.theme.sh index d9679bf..05b057b 100644 --- a/themes/kitsune/kitsune.theme.sh +++ b/themes/kitsune/kitsune.theme.sh @@ -4,6 +4,8 @@ # # prompt theming +_omb_module_require plugin:battery + # added TITLEBAR for updating the tab and window titles with the pwd case $TERM in xterm*) From a4f752cd01cd0c8f7623c3d7222f90851db65814 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 8 Jan 2022 14:42:53 +0900 Subject: [PATCH 4/4] themes/kitsune: Fix a bug that information is not updated --- themes/kitsune/kitsune.theme.sh | 44 +++++++++++++++++---------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/themes/kitsune/kitsune.theme.sh b/themes/kitsune/kitsune.theme.sh index 05b057b..b055173 100644 --- a/themes/kitsune/kitsune.theme.sh +++ b/themes/kitsune/kitsune.theme.sh @@ -6,28 +6,30 @@ _omb_module_require plugin:battery -# added TITLEBAR for updating the tab and window titles with the pwd -case $TERM in - xterm*) - TITLEBAR=$(printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}") - ;; - screen) - TITLEBAR=$(printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}") - ;; - *) - TITLEBAR="" - ;; -esac -if [ "$?" == "0" ] -then - SC="${green}^_^"; -else - SC="${red}T_T"; -fi -BC=`battery_percentage` function prompt_command() { - #PS1="${TITLEBAR}[\u@\h \W $(scm_prompt_info)]\$ " - PS1="\n${cyan}┌─${bold_white}[\u@\h]${cyan}─${bold_yellow}(\w)$(scm_prompt_info)\n${cyan}└─${bold_green}[\A]-${green}($BC%)${bold_cyan}-[${green}${bold_green}\$${bold_cyan}]${green} " + local status=$? + + # added TITLEBAR for updating the tab and window titles with the pwd + local TITLEBAR + case $TERM in + xterm* | screen) + TITLEBAR=$'\1\e]0;'$USER@${HOSTNAME%%.*}:${PWD/#$HOME/~}$'\e\\\2' ;; + *) + TITLEBAR= ;; + esac + + local SC + if ((status == 0)); then + SC="$cyan-$bold_green(${green}^_^$bold_green)"; + else + SC="$cyan-$bold_green(${red}T_T$bold_green)"; + fi + + local BC=$(battery_percentage) + [[ $BC == no && $BC == -1 ]] && BC= + BC=${BC:+${cyan}-${green}($BC%)} + + PS1=$TITLEBAR"\n${cyan}┌─${bold_white}[\u@\h]${cyan}─${bold_yellow}(\w)$(scm_prompt_info)\n${cyan}└─${bold_green}[\A]$SC$BC${cyan}-${bold_cyan}[${green}${bold_green}\$${bold_cyan}]${green} " } # scm theming