DWM状态栏配置

DWM状态栏配置

显示更丰富的色彩可以用dwm-status2d-6.3.diff这个补丁,不过这个补丁似乎与alpha补丁冲突。
打上这个补丁后就可以用按照格式指定颜色了。

效果
下面给出脚本dwmbar.sh

#!/bin/sh


dwm_date () {
    printf "%s" "$SEP1"
    if [ "$IDENTIFIER" = "unicode" ]; then
        printf "📆 %s" "$(date +"%d-%m-%y %H:%M")"
    else
        printf " %s" "$(date +"%d-%m-%y 󰥔 %H:%M")"
    fi
    printf "%s\n" "$SEP2"
}

dwm_network () {
    CONNAME=$(nmcli -a | grep 'Wired connection' | awk 'NR==1{print $1}')
    if [ "$CONNAME" = "" ]; then
        CONNAME=$(nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -c 5-)
    fi

    PRIVATE=$(nmcli -a | grep 'inet4 192' | awk '{print $2}')
    PUBLIC=$(curl -s https://ipinfo.io/ip)

    printf "%s" "$SEP1"
    if [ "$IDENTIFIER" = "unicode" ]; then
        printf "🌐 %s %s | %s" "$CONNAME" "$PRIVATE" "$PUBLIC"
    else
        printf "󰖩%s%s %s""$CONNAME"
    fi
    printf "%s\n" "$SEP2"
}

dwm_battery () {
    # Change BAT1 to whatever your battery is identified as. Typically BAT0 or BAT1
    CHARGE=$(cat /sys/class/power_supply/BAT1/capacity)
    STATUS=$(cat /sys/class/power_supply/BAT1/status)
    # full Discharging
    printf "%s" "$SEP1"
    if [ "$IDENTIFIER" = "unicode" ]; then
        if [ "$STATUS" = "Charging" ]; then
            printf "🔌 %s%% %s" "$CHARGE" #"$STATUS"
        else
            printf "🔋 %s%% %s" "$CHARGE" #"$STATUS"
        fi
    else
        if [ "$STATUS" = "Charging" ]; then
            printf " 󰂄 %s%% %s" "$CHARGE" #"$STATUS"
        else
            printf "󰁹 %s%% %s" "$CHARGE" #"$STATUS"
        fi

    fi
    printf "%s\n" "$SEP2"
}

dwm_alsa () {
    VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/")
    printf "%s" "$SEP1"
    if [ "$VOL" -eq 0 ]; then
        printf "󰕿"
    elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then
        printf "󰖀 %s%%" "$VOL"
    elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then
        printf "󰕾 %s%%" "$VOL"
    else
        printf "󱄡 %s%%" "$VOL"
    fi
    printf "%s\n" "$SEP2"
}

dwm_cpu(){
    read cpu a b c previdle rest < /proc/stat
    prevtotal=$((a+b+c+previdle))
    sleep 0.5
    read cpu a b c idle rest < /proc/stat
    total=$((a+b+c+idle))
    cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
    echo -e "󰧨  $cpu% cpu"
}

print_mem(){
	memfree=$(($(grep -m1 'MemAvailable:' /proc/meminfo | awk '{print $2}') / 1024))

	echo -e " $memfree"
}
# 

black="#1e222a"
white="#D8DEE9"
grey="#373d49"
blue="#81A1C1"
blue2="#5E81AC"
blue3="#88C0D0"
blue4="#8FBCBB"
red="#d47d85"
green="#A3BE8C"
pink="#B48EAD"
yellow="#EBCB8B"
orange="#D08770"
darkblue="#7292b2"

xsetroot -name "^c$black^^b$blue^  󰤼: ^b$green^ $(print_mem) $(dwm_cpu) ^b$blue^^c$black^ $(dwm_network) ^c$black^^b$green^ $(dwm_alsa) [ $(dwm_battery)] ^b$pink^ $(dwm_date) ^b#81A1C1^  "

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值