Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ethancedwards8 authored Oct 18, 2024
2 parents a39a2b3 + ec85f84 commit ac75148
Show file tree
Hide file tree
Showing 19 changed files with 734 additions and 90 deletions.
23 changes: 20 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ programs.tmux = {

#### Configuration

To enable plugins set up the `@dracula-plugins` option in you `.tmux.conf` file, separate plugin by space.
To enable plugins set up the `@dracula-plugins` option in your `.tmux.conf` file, separate plugin by space.
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, kubernetes-context, synchronize-panes, krbtgt
# 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"
```

Expand Down Expand Up @@ -94,7 +94,7 @@ set -g @dracula-refresh-rate 5
Switch the left smiley icon

```bash
# it can accept `hostname` (full hostname), `session`, `shortname` (short name), `smiley`, `window`, or any character.
# it can accept `hostname` (full hostname), `session`, `shortname` (short name), `smiley`, `window`, or any character.
set -g @dracula-show-left-icon session
```

Expand All @@ -117,6 +117,15 @@ Hide empty plugins
set -g @dracula-show-empty-plugins false
```

Make the powerline background transparent

```bash
set -g @dracula-powerline-bg-transparent true

# the left separator symbol is inversed with a transparent background, you can modify it with any symbol you like
set -g @dracula-inverse-divider 
```

#### cpu-usage options

Customize label
Expand Down Expand Up @@ -383,3 +392,11 @@ Show if the last save was performed less than 60 seconds ago (default threshold
```bash
set -g @dracula-continuum-time-threshold 60
```

#### Playerctl format

Set the playerctl metadata format

```
set -g @dracula-playerctl-format "► {{ artist }} - {{ title }}"
```
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,22 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul
- List of windows with the current window highlighted
- When prefix is enabled, a smiley face turns from green to yellow
- When charging, 'AC' is displayed
- Alternatively show battery level and whether its charging next to percentage by setting:
```
set -g @dracula-battery-label false
set -g @dracula-no-battery-label false
set -g @dracula-show-battery-status true
```
- If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature
- Info if the Panes are synchronized
- Spotify playback (needs the tool spotify-tui installed)
- Spotify playback (needs the tool spotify-tui installed). max-len can be configured.
- Music Player Daemon status (needs the tool mpc installed)
- Playerctl, get current track metadata
- 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

Expand Down
97 changes: 75 additions & 22 deletions scripts/battery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ linux_acpi() {
arg=$1
BAT=$(ls -d /sys/class/power_supply/*)
if [ ! -x "$(which acpi 2> /dev/null)" ];then
case "$arg" in
status)
cat $BAT/status
;;

percent)
cat $BAT/capacity
;;

*)
;;
esac
for DEV in $BAT; do
case "$arg" in
status)
[ -f "$DEV/status" ] && cat "$DEV/status"
;;
percent)
[ -f "$DEV/capacity" ] && cat "$DEV/capacity"
;;
*)
;;
esac
done
else
case "$arg" in
status)
Expand All @@ -41,7 +41,7 @@ battery_percent()
case $(uname -s) in
Linux)
percent=$(linux_acpi percent)
[ -n "$percent" ] && echo " $percent"
[ -n "$percent" ] && echo "$percent%"
;;

Darwin)
Expand Down Expand Up @@ -85,18 +85,57 @@ battery_status()
;;
esac

tmp_bat_perc=$(battery_percent)
bat_perc="${tmp_bat_perc%\%}"

case $status in
discharging|Discharging)
echo ''
# discharging, no AC
declare -A battery_labels=(
[0]="󰂎"
[10]="󰁺"
[20]="󰁻"
[30]="󰁼"
[40]="󰁽"
[50]="󰁾"
[60]="󰁿"
[70]="󰂀"
[80]="󰂁"
[90]="󰂂"
[100]="󰁹"
)
echo "${battery_labels[$((bat_perc/10*10))]:-󰂃}"
;;
high|Full)
echo ''
high|charged|Full)
echo "󰁹"
;;
charging|Charging)
echo 'AC'
# charging from AC
declare -A battery_labels=(
[0]="󰢟"
[10]="󰢜"
[20]="󰂆"
[30]="󰂇"
[40]="󰂈"
[50]="󰢝"
[60]="󰂉"
[70]="󰢞"
[80]="󰂊"
[90]="󰂋"
[100]="󰂅"
)
echo "${battery_labels[$((bat_perc/10*10))]:-󰂃}"
;;
ACattached)
# drawing from AC but not charging
echo ''
;;
finishingcharge)
echo '󰂅'
;;
*)
echo 'AC'
# something wrong...
echo ''
;;
esac
### Old if statements didn't work on BSD, they're probably not POSIX compliant, not sure
Expand All @@ -112,18 +151,32 @@ battery_status()
main()
{
bat_label=$(get_tmux_option "@dracula-battery-label" "")
bat_stat=$(battery_status)
if [ "$bat_label" == false ]; then
bat_label=""
fi

no_bat_label=$(get_tmux_option "@dracula-no-battery-label" "AC")
if [ "$no_bat_label" == false ]; then
no_bat_label=""
fi

show_bat_label=$(get_tmux_option "@dracula-show-battery-status" false)
if $show_bat_label; then
bat_stat=$(battery_status)
else
bat_stat=""
fi

bat_perc=$(battery_percent)

if [ -z "$bat_stat" ]; then # Test if status is empty or not
echo "$bat_label $bat_perc"
elif [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power
echo "$bat_label $bat_stat"
echo "$no_bat_label"
else
echo "$bat_label $bat_stat $bat_perc"
echo "$bat_label$bat_stat $bat_perc"
fi
}

#run main driver program
main

61 changes: 43 additions & 18 deletions scripts/dracula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ main()
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)
eks_extract_account=$(get_tmux_option "@dracula-kubernetes-eks-extract-account" false)
hide_kubernetes_user=$(get_tmux_option "@dracula-kubernetes-hide-user" false)
Expand All @@ -19,6 +20,7 @@ main()
show_location=$(get_tmux_option "@dracula-show-location" true)
fixed_location=$(get_tmux_option "@dracula-fixed-location")
show_powerline=$(get_tmux_option "@dracula-show-powerline" false)
transparent_powerline_bg=$(get_tmux_option "@dracula-transparent-powerline-bg" false)
show_flags=$(get_tmux_option "@dracula-show-flags" false)
show_left_icon=$(get_tmux_option "@dracula-show-left-icon" smiley)
show_left_icon_padding=$(get_tmux_option "@dracula-left-icon-padding" 1)
Expand All @@ -27,27 +29,42 @@ main()
show_timezone=$(get_tmux_option "@dracula-show-timezone" true)
show_left_sep=$(get_tmux_option "@dracula-show-left-sep")
show_right_sep=$(get_tmux_option "@dracula-show-right-sep")
show_inverse_divider=$(get_tmux_option "@dracula-inverse-divider")
show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false)
show_day_month=$(get_tmux_option "@dracula-day-month" false)
show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5)
show_synchronize_panes_label=$(get_tmux_option "@dracula-synchronize-panes-label" "Sync")
time_format=$(get_tmux_option "@dracula-time-format" "")
show_ssh_session_port=$(get_tmux_option "@dracula-show-ssh-session-port" false)
show_libreview=$(get_tmux_option "@dracula-show-libreview" false)
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather")
show_empty_plugins=$(get_tmux_option "@dracula-show-empty-plugins" true)

# Dracula Color Pallette
white='#f8f8f2'
gray='#44475a'
dark_gray='#282a36'
light_purple='#bd93f9'
dark_purple='#6272a4'
cyan='#8be9fd'
green='#50fa7b'
orange='#ffb86c'
red='#ff5555'
pink='#ff79c6'
yellow='#f1fa8c'
white=$(get_tmux_option "@dracula-color-white" "#f8f8f2")
gray=$(get_tmux_option "@dracula-color-gray" "#44475a")
dark_gray=$(get_tmux_option "@dracula-color-dark_gray" "#282a36")
light_purple=$(get_tmux_option "@dracula-color-light_purple" "#bd93f9")
dark_purple=$(get_tmux_option "@dracula-color-dark_purple" "#6272a4")
cyan=$(get_tmux_option "@dracula-color-cyan" "#8be9fd")
green=$(get_tmux_option "@dracula-color-green" "#50fa7b")
orange=$(get_tmux_option "@dracula-color-orange" "#ffb86c")
red=$(get_tmux_option "@dracula-color-red" "#ff5555")
pink=$(get_tmux_option "@dracula-color-pink" "#ff79c6")
yellow=$(get_tmux_option "@dracula-color-yellow" "#f1fa8c")

# Set transparency variables - Colors and window dividers
if $transparent_powerline_bg; then
bg_color="default"
window_sep_fg=${dark_purple}
window_sep_bg=default
window_sep="$show_inverse_divider"
else
bg_color=${gray}
window_sep_fg=${gray}
window_sep_bg=${dark_purple}
window_sep="$show_left_sep"
fi

# Handle left icon configuration
case $show_left_icon in
Expand Down Expand Up @@ -123,12 +140,12 @@ main()
tmux set-option -g message-style "bg=${gray},fg=${white}"

# status bar
tmux set-option -g status-style "bg=${gray},fg=${white}"
tmux set-option -g status-style "bg=${bg_color},fg=${white}"

# Status left
if $show_powerline; then
tmux set-option -g status-left "#[bg=${green},fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ${left_icon} #[fg=${green},bg=${gray}]#{?client_prefix,#[fg=${yellow}],}${left_sep}"
powerbg=${gray}
tmux set-option -g status-left "#[bg=${green},fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ${left_icon} #[fg=${green},bg=${bg_color}]#{?client_prefix,#[fg=${yellow}],}${left_sep}"
powerbg=${bg_color}
else
tmux set-option -g status-left "#[bg=${green},fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ${left_icon}"
fi
Expand Down Expand Up @@ -230,9 +247,13 @@ main()
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)"

elif [ $plugin = "kubernetes-context" ]; then
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray")
script="#($current_dir/kubernetes_context.sh $eks_hide_arn $eks_extract_account $hide_kubernetes_user $show_kubernetes_context_label)"
script="#($current_dir/kubernetes_context.sh $eks_hide_arn $eks_extract_account $hide_kubernetes_user $show_only_kubernetes_context $show_kubernetes_context_label)"

elif [ $plugin = "terraform" ]; then
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-terraform-colors" "light_purple dark_gray")
Expand All @@ -254,7 +275,7 @@ main()
if $show_day_month && $show_military ; then # military time and dd/mm
script="%a %d/%m %R ${timezone} "
elif $show_military; then # only military time
script="%a %m/%d %R ${timezone} "
script="%R ${timezone} "
elif $show_day_month; then # only dd/mm
script="%a %d/%m %I:%M %p ${timezone} "
else
Expand All @@ -265,6 +286,10 @@ main()
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-synchronize-panes-colors" "cyan dark_gray")
script="#($current_dir/synchronize_panes.sh $show_synchronize_panes_label)"

elif [ $plugin = "libreview" ]; then
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-libre-colors" "white dark_gray")
script="#($current_dir/libre.sh $show_libreview)"

elif [ $plugin = "ssh-session" ]; then
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-ssh-session-colors" "green dark_gray")
script="#($current_dir/ssh_session.sh $show_ssh_session_port)"
Expand All @@ -291,12 +316,12 @@ main()

# Window option
if $show_powerline; then
tmux set-window-option -g window-status-current-format "#[fg=${gray},bg=${dark_purple}]${left_sep}#[fg=${white},bg=${dark_purple}] #I #W${current_flags} #[fg=${dark_purple},bg=${gray}]${left_sep}"
tmux set-window-option -g window-status-current-format "#[fg=${window_sep_fg},bg=${window_sep_bg}]${window_sep}#[fg=${white},bg=${dark_purple}] #I #W${current_flags} #[fg=${dark_purple},bg=${bg_color}]${left_sep}"
else
tmux set-window-option -g window-status-current-format "#[fg=${white},bg=${dark_purple}] #I #W${current_flags} "
fi

tmux set-window-option -g window-status-format "#[fg=${white}]#[bg=${gray}] #I #W${flags}"
tmux set-window-option -g window-status-format "#[fg=${white}]#[bg=${bg_color}] #I #W${flags}"
tmux set-window-option -g window-status-activity-style "bold"
tmux set-window-option -g window-status-bell-style "bold"
}
Expand Down
Loading

0 comments on commit ac75148

Please sign in to comment.