From ef2dfef39f82ca18ca08a1c190a812b53e149278 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 30 Jul 2026 02:22:54 -0400 Subject: [PATCH] Wifi strength in prompt on Linux. --- tcshrc.prompt.defs | 6 ++++++ tcshrc.prompt.final | 26 ++++++++++++++++++++++++-- tcshrc.system.Linux | 5 +++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index 584acdf..453c730 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -190,10 +190,16 @@ set end_prompt="%#" # The battery level thresholds are fixed, no need to recompute each prompt. +set vertical_fills=( ' ' `printf "\u2581 \u2582 \u2583 \u2584 \u2585 \u2586 \u2587 \u2588"` ) + +set horizontal_fills=( ' ' `printf "\u258f \u258e \u258d \u258c \u258b \u258a \u2589 \u2588"` ) + set battery_levels=( 75 50 33 20 10 ) set battery_colors=( ${bright_green} ${green} ${csi}93m ${csi}33m ${red} ${red}${blink} ___ ) +set wifi_levels=( ${sgr_reset}____${sgr_reset} ${red}`printf '\u2582'`___${sgr_reset} ${bright_yellow}`printf '\u2582\u2584'`__${sgr_reset} ${bright_green}`printf '\u2582\u2584\u2586'`_${sgr_reset} ${bright_blue}`printf '\u2582\u2584\u2586\u2588'`${sgr_reset} ++++ ) + alias oldp 'set prompt="$prompt_simple"; set cshenv_user_prompt_override' alias newp 'set prompt="$prompt_cool"; unset cshenv_user_prompt_override' diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index edf8ac4..c57bf2a 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -167,13 +167,35 @@ if( $?cshenv_show_battery_level ) then set battery_level=" ${battery_level}" endif - set battery_prefix="%{${csi}m${csi}28D%}" + set battery_prefix="%{${csi}m${csi}32D%}" set battery_prompt="%{${csi}38;2;128;128;255;3mBattery Level:${sgr_reset} ${battery_color}${battery_level}%}${percent_color_seq}%{%${sgr_reset} %}" else set battery_prefix="" set battery_prompt="" endif +set wifi_prompt="" +if ( $?CSHENV_ENABLE_PROMPT_WIFI && $CSHENV_SYSTEM == "Linux" && -f /proc/net/wireless ) then + set wifi_check=(`cat /proc/net/wireless`) + # This one uses the Wifi special chip emoji thing. + #set wifi_prompt="%{`printf '\U0001F6DC'`: " + # Codepoints: '\u03a6\u03c6\u03d5' + #set wifi_prompt="%{`printf 'y\u03c6'`: " + # This one uses the math symbols for Y and Phi, and seems to look the best: + set wifi_prompt="%{\e[1000000G\e[28D\e[36m`printf '\U0001d654\U0001D74b'`\e[;1m:\e[m " + set wifi_levels_tmp=( ${wifi_levels} ) + if( $#wifi_check > 27 ) then + set wifi_level=${wifi_check[31]:s/.//} + + if( ${wifi_level} >= -90 ) shift wifi_levels_tmp + if( ${wifi_level} >= -80 ) shift wifi_levels_tmp + if( ${wifi_level} >= -75 ) shift wifi_levels_tmp + if( ${wifi_level} >= -50 ) shift wifi_levels_tmp + endif + set wifi_bars="${wifi_levels_tmp[1]}" + set wifi_prompt="${wifi_prompt}${wifi_bars} %}" +endif + set git_prompt="" set git_prefix="" set git_tracking_stat="" @@ -314,7 +336,7 @@ if( "" != "${internal_bracket_prompt}" ) then set internal_bracket_view="${brace_color_seq}\[${internal_bracket_prompt}${brace_color_seq}\]" endif -set prompt_cool="%{\n%}${align_prefix}${battery_prompt_view}${date_prompt_view}%{ %}${time_prompt_view}${align_suffix}${internal_bracket_view}${prompt_color_seq}${end_prompt}%{${text_color_seq}%} " +set prompt_cool="%{\n%}${align_prefix}${battery_prompt_view}${wifi_prompt}${date_prompt_view}%{ %}${time_prompt_view}${align_suffix}${internal_bracket_view}${prompt_color_seq}${end_prompt}%{${text_color_seq}%} " if( ! ${?cshenv_user_prompt_override} ) then diff --git a/tcshrc.system.Linux b/tcshrc.system.Linux index 536915d..9e45f9b 100644 --- a/tcshrc.system.Linux +++ b/tcshrc.system.Linux @@ -14,6 +14,11 @@ if( ${#battery_locations} > 0 ) then end endif +set wireless_cards=( `lspci | grep Wireless` ) +if( $#wireless_cards > 0 ) then + setenv CSHENV_ENABLE_PROMPT_WIFI +endif + # Set the acknowledgement bit, essentially setenv CSHENV_SYSTEM_CONFIGURED Linux