diff --git a/INSTALL.md b/INSTALL.md index 3250d801..c8b511a7 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -48,7 +48,7 @@ To enable plugins set up the `@dracula-plugins` option in your `.tmux.conf` file The order that you define the plugins will be the order on the status bar left to right. ```bash -# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, tmux-ram-usage, network, network-bandwidth, network-ping, ssh-session, attached-clients, network-vpn, weather, time, mpc, spotify-tui, playerctl, kubernetes-context, synchronize-panes +# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, tmux-ram-usage, network, network-bandwidth, network-ping, ssh-session, attached-clients, network-vpn, weather, time, mpc, spotify-tui, krbtgt, playerctl, kubernetes-context, synchronize-panes set -g @dracula-plugins "cpu-usage gpu-usage ram-usage" ``` @@ -365,6 +365,15 @@ Extract the account as a prefix to the cluster name - Available for EKS only (on ``` set -g @dracula-kubernetes-eks-extract-account true +``` + +### Kerberos TGT options + +Set the principal to check the TGT expiration date for (with or without the REALM) + +``` +set -g @dracula-krbtgt-principal "principal" +``` #### continuum options diff --git a/README.md b/README.md index 9f9bd7f3..bbae27cb 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul - Current kubernetes context - Countdown to tmux-continuum save - Current working directory of tmux pane +- Kerberos TGT expiration date - Show your Libre Freestyle 3 readings [Setup instructions](./scripts/libre.sh) ## Compatibility diff --git a/scripts/dracula.sh b/scripts/dracula.sh index a2ca00ec..b523d190 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -8,6 +8,8 @@ source $current_dir/utils.sh main() { # set configuration option variables + show_krbtgt_label=$(get_tmux_option "@dracula-krbtgt-context-label" "") + krbtgt_principal=$(get_tmux_option "@dracula-krbtgt-principal" "") show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "") show_only_kubernetes_context=$(get_tmux_option "@dracula-show-only-kubernetes-context" "") eks_hide_arn=$(get_tmux_option "@dracula-kubernetes-eks-hide-arn" false) @@ -241,6 +243,10 @@ main() IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-spotify-tui-colors" "green dark_gray") script="#($current_dir/spotify-tui.sh)" + elif [ $plugin = "krbtgt" ]; then + IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-krbtgt-colors" "cyan dark_gray") + script="#($current_dir/krbtgt.sh $krbtgt_principal $show_krbtgt_label)" + elif [ $plugin = "playerctl" ]; then IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-playerctl-colors" "green dark_gray") script="#($current_dir/playerctl.sh)" diff --git a/scripts/krbtgt.sh b/scripts/krbtgt.sh new file mode 100755 index 00000000..347da47e --- /dev/null +++ b/scripts/krbtgt.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +principal=$1 +label=$2 + +current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $current_dir/utils.sh + +if [ -n "$principal" ]; then + _principal=$principal + if ! [[ "$_principal" =~ "@" ]]; then + _principal="$_principal@" + fi + krb_principal_tgt_cache=$(klist -lan | awk -v krb_principal="^$_principal" '$0 ~ krb_principal {print $2}') + if [ -n "$krb_principal_tgt_cache" ]; then + krb_tgt_expire=$(date '+%H:%M:%S' -d "$(klist $krb_principal_tgt_cache | awk '/krbtgt/ {print $3,$4}')") + else + krb_tgt_expire="" + fi +fi + +main() +{ + # storing the refresh rate in the variable RATE, default is 5 + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) + OUTPUT_STRING="" + if [ -z "$principal" ]; then + OUTPUT_STRING="no principal configured" + fi + + if [ -z "$krb_tgt_expire" ]; then + OUTPUT_STRING="$principal -" + else + OUTPUT_STRING="${principal} ${krb_tgt_expire}" + fi + + if [ "$label" = "" ]; then + echo "${OUTPUT_STRING}" + else + echo "${label} ${OUTPUT_STRING}" + fi + + sleep $RATE +} + +# run the main driver +main