From c655e40f6d6a3114de58b807a5d917914708b75a Mon Sep 17 00:00:00 2001 From: thek4n Date: Mon, 19 May 2025 18:47:33 +0300 Subject: [PATCH 1/2] migrate to i3blocks --- TARGETS.sh | 2 +- home/user/.config/i3/config | 2 +- home/user/.config/i3blocks/config | 49 ++++++++++++++++++ home/user/.config/i3status/config | 82 ------------------------------- 4 files changed, 51 insertions(+), 84 deletions(-) create mode 100644 home/user/.config/i3blocks/config delete mode 100644 home/user/.config/i3status/config diff --git a/TARGETS.sh b/TARGETS.sh index f57026e..7664e19 100644 --- a/TARGETS.sh +++ b/TARGETS.sh @@ -11,7 +11,7 @@ ssh: git:.config/git ranger:.config/ranger gpg: -i3:.xinitrc .xprofile .Xresources .config/i3 .config/i3status .local/bin/i3status_wrapper .config/rofi .config/picom .local/bin/slm .local/bin/slm_rofi.sh .local/bin/power_rofi.sh .local/bin/i3_switch_workspace.sh .config/mimeapps.list .local/bin/screenshot +i3:.xinitrc .xprofile .Xresources .config/i3 .config/i3blocks .config/rofi .config/picom .local/bin/slm .local/bin/slm_rofi.sh .local/bin/power_rofi.sh .local/bin/i3_switch_workspace.sh .config/mimeapps.list .local/bin/screenshot bat:.config/bat font: termux:.termux diff --git a/home/user/.config/i3/config b/home/user/.config/i3/config index 7fba644..13a326e 100644 --- a/home/user/.config/i3/config +++ b/home/user/.config/i3/config @@ -221,7 +221,7 @@ bar { output primary output nonprimary tray_output primary - status_command exec ~/.local/bin/i3status_wrapper + status_command i3blocks } bindsym Print exec --no-startup-id screenshot select copy diff --git a/home/user/.config/i3blocks/config b/home/user/.config/i3blocks/config new file mode 100644 index 0000000..9c99bf2 --- /dev/null +++ b/home/user/.config/i3blocks/config @@ -0,0 +1,49 @@ +# Общие настройки +command=$SCRIPT_DIR/$BLOCK_NAME +separator_block_width=15 +markup=none + +# Цвета (в формате #RRGGBB) +color=#FFFFFF + +# Интервал обновления (в секундах) +interval=5 + +# Блоки (модули) + +[time] +command=date '+%H:%M:%S %d.%m.%Y' +label= +interval=5 +color=#f1fa8c + +[memory] +command=free -h | awk '/^Mem/ {print $3 "/" $2}' | sed 's/i//g' +label= +interval=5 +color=#50fa7b + +[cpu_usage] +command=top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}' +label= +interval=5 +color=#ff79c6 + +[disk] +command=df -h / | awk '/\// {print $4}' +label= +interval=30 +color=#8be9fd + +[network] +command=echo "$(LANG=C nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d: -f2) $(ip -o -4 addr show | awk '{print $4}' | cut -d/ -f1 | head -1)" +label= +interval=10 +color=#bd93f9 + +[volume] +command=amixer get Master | awk -F'[][]' '/%/ {print $2}' | head -n 1 +label= +interval=1 +signal=10 # Для обновления по сигналу (например, после изменения громкости) + diff --git a/home/user/.config/i3status/config b/home/user/.config/i3status/config deleted file mode 100644 index f781eea..0000000 --- a/home/user/.config/i3status/config +++ /dev/null @@ -1,82 +0,0 @@ -general { - colors = true - interval = 5 - output_format = i3bar -} - -order += "wireless _first_" -order += "ethernet _first_" -order += "disk /" -order += "disk /home" -order += "memory" -order += "cpu_usage" -order += "cpu_temperature 0" -order += "tztime holder__headphones" -order += "battery all" -order += "volume master" -order += "tztime local" - -wireless _first_ { - format_up = " (%quality at %essid %frequency) %ip" - format_down = " down" - color_bad = "#454545" -} - -ethernet _first_ { - format_up = " %ip" - format_down = " down" -} - -battery all { - format = "%status %percentage" - last_full_capacity = false - format_down = "" - status_chr = "⚡" - status_bat = "🔋" - status_unk = "?" - status_full = "" - path = "/sys/class/power_supply/BAT%d/uevent" - low_threshold = 15 -} - -disk "/" { - format = "/ %used/%total" -} - -disk "/home" { - format = " %used/%total" -} - -memory { - format = " %used/%total" - threshold_degraded = "1G" - threshold_critical = "200M" - format_degraded = "MEMORY < %available" -} - -cpu_usage { - format = " %usage" -} - -cpu_temperature 0 { - format = " %degrees°" - max_threshold = "80" - format_above_threshold = " %degrees" -} - -tztime local { - format = " %d.%m.%y %a  %H:%M" -} - -volume master { - format = " %volume" - format_muted = ": muted %volume" - device = "default" - mixer = "Master" - mixer_idx = 0 -} - - -tztime holder__headphones { - format = "holder__headphones" -} \ No newline at end of file From 3b7f374057614066c4f609fca872dffe2a768bfc Mon Sep 17 00:00:00 2001 From: thek4n Date: Thu, 23 Oct 2025 19:55:40 +0300 Subject: [PATCH 2/2] i3blocks --- home/user/.config/i3/config | 13 +++-- home/user/.config/i3blocks/config | 65 +++++++++++---------- home/user/.local/bin/i3blocks_helper | 87 ++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 35 deletions(-) create mode 100755 home/user/.local/bin/i3blocks_helper diff --git a/home/user/.config/i3/config b/home/user/.config/i3/config index 13a326e..bba9521 100644 --- a/home/user/.config/i3/config +++ b/home/user/.config/i3/config @@ -12,6 +12,7 @@ set $i3lock_cmd "i3lock -enf -c 1e1e1e" exec --no-startup-id xset s off exec --no-startup-id xset +dpms dpms 600 600 600 exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock -enf -c 1e1e1e +exec --no-startup-id pomodoro daemon # Notifications @@ -35,10 +36,10 @@ set $font_size 11 font xft:FiraCode $font_size # use pactl to adjust volume in PulseAudio. -set $refresh_i3status killall -SIGUSR1 i3status -bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status -bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status -bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status +set $refresh_i3blocks killall -10 i3blocks +bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3blocks +bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3blocks +bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3blocks bindsym XF86AudioPlay exec playerctl play-pause bindsym XF86AudioPause exec playerctl play-pause @@ -52,8 +53,8 @@ bindsym XF86MonBrightnessDown exec xbacklight -dec 20 bindsym $mod+z exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ 0 ## Hold to talk bindsym --release $mod+z exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ 1 ## Release to mute -bindsym $mod+Shift+z exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status -bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status +bindsym $mod+Shift+z exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3blocks +bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3blocks bindsym XF86PickupPhone exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ 0 ## Hold to talk bindsym --release XF86PickupPhone exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ 1 ## Release to mute diff --git a/home/user/.config/i3blocks/config b/home/user/.config/i3blocks/config index 9c99bf2..08db338 100644 --- a/home/user/.config/i3blocks/config +++ b/home/user/.config/i3blocks/config @@ -1,49 +1,56 @@ -# Общие настройки -command=$SCRIPT_DIR/$BLOCK_NAME separator_block_width=15 markup=none -# Цвета (в формате #RRGGBB) color=#FFFFFF -# Интервал обновления (в секундах) interval=5 -# Блоки (модули) +[wireless] +command=i3blocks_helper wireless +interval=10 -[time] -command=date '+%H:%M:%S %d.%m.%Y' -label= -interval=5 -color=#f1fa8c +[ethernet] +command=i3blocks_helper ethernet +interval=10 + +[diskroot] +command=i3blocks_helper disk_root +interval=30 + +[diskhome] +command=i3blocks_helper disk_home +interval=30 [memory] -command=free -h | awk '/^Mem/ {print $3 "/" $2}' | sed 's/i//g' -label= +command=i3blocks_helper memory interval=5 -color=#50fa7b [cpu_usage] -command=top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}' -label= +command=i3blocks_helper cpu_usage interval=5 -color=#ff79c6 -[disk] -command=df -h / | awk '/\// {print $4}' -label= -interval=30 -color=#8be9fd +[cpu_temp] +command=i3blocks_helper cpu_temp +interval=5 -[network] -command=echo "$(LANG=C nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d: -f2) $(ip -o -4 addr show | awk '{print $4}' | cut -d/ -f1 | head -1)" -label= -interval=10 -color=#bd93f9 +[bluetooth] +command=i3blocks_helper bluetooth_battery +interval=5 + +[battery] +command=i3blocks_helper battery +interval=5 [volume] -command=amixer get Master | awk -F'[][]' '/%/ {print $2}' | head -n 1 -label= +command=i3blocks_helper volume interval=1 -signal=10 # Для обновления по сигналу (например, после изменения громкости) +signal=10 +[pomodoro] +command=pomodoro formatted +interval=1 +signal=10 + +[time] +command=env LC_ALL=C date '+ %d.%m.%y %a  %H:%M' +interval=5 diff --git a/home/user/.local/bin/i3blocks_helper b/home/user/.local/bin/i3blocks_helper new file mode 100755 index 0000000..9dd856c --- /dev/null +++ b/home/user/.local/bin/i3blocks_helper @@ -0,0 +1,87 @@ +#!/bin/sh + +set -ue + + +readonly EXIT_SUCCESS=0 +readonly EXIT_FAILURE=1 + + +cmd_wireless() { + return 0 # todo  +} + +cmd_ethernet() { + return 0 # todo + echo "$(LANG=C nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d: -f2) $(ip -o -4 addr show | awk '{print $4}' | cut -d/ -f1 | head -1)" +} + +cmd_battery() { + return 0 # todo +} + +cmd_disk_root() { + df -h / | awk '/\// {print "/ "$2"/"$3}' +} + +cmd_disk_home() { + res="$(df -h /home)" + if [ "$(echo "${res}" | awk '/\// {print $6}')" != "/home" ]; then + return 1 + fi + df -h /home | awk '/\// {print " "$2"/"$3}' +} + +cmd_memory() { + free -h | awk '/^Mem/ {print " "$3"/"$2}' | sed 's/i//g' +} + +cmd_cpu_usage() { + top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print " "100 - $1"%"}' +} + +cmd_cpu_temp() { + temp_mC="$(cat /sys/class/thermal/thermal_zone0/temp)" + temp_C="$((temp_mC / 1000))" + + if [ "${temp_C}" -gt 80 ]; then + echo " ${temp_C}°C" + exit 33 # bad + else + echo " ${temp_C}°C" + fi +} + +cmd_time() { + LC_ALL=C date '+ %d.%m.%y %a  %H:%M' +} + +cmd_volume() { + amixer get Master | awk -F'[][]' '/%/ {print " "$2}' | head -n 1 +} + +cmd_pomodoro() { + pomodoro formatted +} + +cmd_bluetooth_battery() { + return 0 +} + +case "${1}" in + wireless) shift; cmd_wireless "$@" ;; + ethernet) shift; cmd_ethernet "$@" ;; + battery) shift; cmd_battery "$@" ;; + disk_root) shift; cmd_disk_root "$@" ;; + disk_home) shift; cmd_disk_home "$@" ;; + memory) shift; cmd_memory "$@" ;; + cpu_usage) shift; cmd_cpu_usage "$@" ;; + cpu_temp) shift; cmd_cpu_temp "$@" ;; + time) shift; cmd_time "$@" ;; + volume) shift; cmd_volume "$@" ;; + pomodoro) shift; cmd_pomodoro "$@" ;; + bluetooth_battery) shift; cmd_bluetooth_battery "$@" ;; + + *) exit "${EXIT_FAILURE}" ;; +esac +exit "${EXIT_SUCCESS}"