Skip to content

Commit

Permalink
fix: switched from i3status + custom script to i3blocks, converted us…
Browse files Browse the repository at this point in the history
…ing gptme
  • Loading branch information
ErikBjare committed Sep 16, 2024
1 parent a286815 commit 3b8f69f
Show file tree
Hide file tree
Showing 15 changed files with 546 additions and 48 deletions.
22 changes: 11 additions & 11 deletions home/.config/i3/config
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,22 @@ bindsym $mod+u exec 'bash ~/.config/i3/layouts.sh'
# Assign workspaces

# Notes on workspace 4
assign [class="Roam Research"] $ws4
assign [class="Standard Notes"] $ws4
assign [class="Logseq"] $ws4
assign [class="(?i)Roam Research"] $ws4
assign [class="(?i)Standard Notes"] $ws4
assign [class="(?i)Logseq"] $ws4

# Audio/music on workspace 5
assign [class="Pavucontrol"] $ws5
assign [class="Blueman-manager"] $ws5
for_window [class="Spotify"] move to workspace $ws5
assign [class="(?i)pavucontrol"] $ws5
assign [class="(?i)pwvucontrol"] $ws5
assign [class="(?i)Blueman-manager"] $ws5
for_window [class="(?i)Spotify"] move to workspace $ws5

# Chat on workspace 6
assign [class="discord"] $ws6
assign [class="(?i)discord"] $ws6
assign [class="(?i)webcord"] $ws6

# Steam on workspace 8
assign [class="steam"] $ws8
assign [class="(?i)steam"] $ws8


####################
Expand Down Expand Up @@ -280,9 +282,7 @@ client.background #ffffff
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
#status_command i3blocks
status_command i3status | ~/.config/i3status/wrapper.py

status_command i3blocks
font pango:Fira Code 10
separator_symbol " ∥ " # Alternative bar: ∣

Expand Down
178 changes: 141 additions & 37 deletions home/.config/i3blocks/config
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
# The top properties below are applied to every block, but can be overridden.
# Each block command defaults to the script name to avoid boilerplate.
# Change $SCRIPT_DIR to the location of your scripts!

command=/home/erb/.config/i3blocks-contrib/$BLOCK_NAME/$BLOCK_NAME
separator_block_width=40
separator_block_width=15
markup=none
separator=false

# Volume indicator
#
Expand All @@ -46,71 +48,173 @@ markup=none
#
# The type defaults to "mem" if the instance is not specified.
[memory]
label=🐏
label=🐏
percent=false
interval=5
PERCENT=false

#[memory]
#label=SWAP
#instance=swap
#interval=30
#PERCENT=false
# Idle time
[custom_idle]
command=~/.config/i3blocks/custom_scripts/idle.sh
interval=5

# Disk usage
#
# The directory defaults to $HOME if the instance is not specified.
# The script may be called with a optional argument to set the alert
# (defaults to 10 for 10%).
[disk]
label=💾
PERCENT=false
#DIR=/mnt/data
interval=30
[separator]
full_text=‖
color=#666666

# Network interface monitoring
#
# If the instance is not specified, use the interface used for default route.
# The address can be forced to IPv4 or IPv6 with -4 or -6 switches.
[iface]
#[iface]
#IFACE=wlan0
color=#00FF00
interval=10
#color=#00FF00
#interval=10

#[wifi]
#INTERFACE=wlp3s0
#label=📡
#interval=10
#separator=false

[bandwidth]
#
#[bandwidth]
#INTERFACE=eth0
#interval=5

# ETH Price
[custom_eth_price]
command=~/.config/i3blocks/custom_scripts/eth_price.sh
interval=60

[separator]
full_text=‖
color=#666666

# Gas Price
[custom_gas_price]
command=~/.config/i3blocks/custom_scripts/gas_price.sh
interval=60

[separator]
full_text=‖
color=#666666

# CPU Temperature
[cpu_temp]
command=~/.config/i3blocks/custom_scripts/cpu_temp.sh
interval=10

[separator]
full_text=‖
color=#666666

# CPU Usage
[cpu_usage]
command=~/.config/i3blocks/custom_scripts/cpu_usage.sh
interval=5

# CPU usage
[separator]
full_text=‖
color=#666666

# Load Average
[custom_load]
command=~/.config/i3blocks/custom_scripts/load_average.sh
interval=10

[separator]
full_text=‖
color=#666666

# RAM Usage
[memory]
command=~/.config/i3blocks/custom_scripts/memory.sh
interval=5

#[memory]
#label=SWAP
#instance=swap
#interval=30
#PERCENT=false

#[memory]
#label=SWAP
#instance=swap
#interval=30
#PERCENT=false
#
# The script may be called with -w and -c switches to specify thresholds,
# see the script for details.
[cpu_usage]
label=🏭
# Idle time
#[custom_idle]
#command=~/.config/i3blocks/custom_scripts/idle.sh
#interval=5

# Disk usage
#
# The directory defaults to $HOME if the instance is not specified.
# The script may be called with a optional argument to set the alert
# (defaults to 10 for 10%).
#[disk]
#label=💾
#PERCENT=false
#DIR=/mnt/data
#interval=30

[separator]
full_text=‖
color=#666666

# GPU Load
[gpu_load]
command=~/.config/i3blocks/custom_scripts/gpu_load.sh
interval=10
min_width=CPU 100.00%
#separator=false

[load_average]
label=⚖️
[separator]
full_text=‖
color=#666666

# GPU VRAM
[gpu_vram]
command=~/.config/i3blocks/custom_scripts/gpu_vram.sh
interval=10

[separator]
full_text=‖
color=#666666

# Disk Usage
[disk]
command=~/.config/i3blocks/custom_scripts/disk_usage.sh
interval=30

[separator]
full_text=‖
color=#666666

# Network
[custom_network]
command=~/.config/i3blocks/custom_scripts/network.sh
interval=5

[separator]
full_text=‖
color=#666666

# Battery indicator
#
# The battery instance defaults to 0.
[battery]
label=BAT
#[battery]
#label=BAT
#label=⚡
interval=30

# Date Time
#
# Power Draw
[custom_power]
command=~/.config/i3blocks/custom_scripts/power_draw.sh
interval=5

[separator]
full_text=‖
color=#666666

# Date and Time
[time]
command=date '+%Y-%m-%d %H:%M:%S'
interval=1
Expand Down
29 changes: 29 additions & 0 deletions home/.config/i3blocks/custom_scripts/brightness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Find the first available backlight device
backlight_dir=$(find /sys/class/backlight -type d | head -n 1)

if [ -n "$backlight_dir" ] && [ -f "$backlight_dir/max_brightness" ] && [ -f "$backlight_dir/brightness" ]; then
max_brightness=$(cat "$backlight_dir/max_brightness")
current_brightness=$(cat "$backlight_dir/brightness")
if [ "$max_brightness" -ne 0 ]; then
brightness_percent=$((current_brightness * 100 / max_brightness))

echo "🌞 ${brightness_percent}%"
echo "🌞 ${brightness_percent}%"

# Color calculation
r=$((136 + (255 - 136) * brightness_percent / 100))
g=$((51 + (255 - 51) * brightness_percent / 100))
b=0
printf "#%02X%02X%02X\n" $r $g $b
else
echo "🌞 N/A"
echo "🌞 N/A"
echo "#FFFFFF"
fi
else
echo "🌞 N/A"
echo "🌞 N/A"
echo "#FFFFFF"
fi
23 changes: 23 additions & 0 deletions home/.config/i3blocks/custom_scripts/cpu_temp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Get the CPU Package temperature
temp=$(sensors | awk '/^CPU Package:/ {print $3; exit}' | tr -d '+°C')

if [ -n "$temp" ]; then
temp=${temp%.*} # Remove decimal part
echo "🌡️ ${temp}°C"
echo "🌡️ ${temp}°C"

# Color based on temperature
if [ $temp -gt 80 ]; then
echo "#FF0000"
elif [ $temp -gt 60 ]; then
echo "#FFFF00"
else
echo "#00FF00"
fi
else
echo "🌡️ N/A"
echo "🌡️ N/A"
echo "#FFFFFF"
fi
37 changes: 37 additions & 0 deletions home/.config/i3blocks/custom_scripts/cpu_usage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Read the first line of /proc/stat
read cpu user nice system idle iowait irq softirq steal guest guest_nice <<< "$(grep '^cpu ' /proc/stat)"

# Calculate the total CPU time
total=$((user + nice + system + idle + iowait + irq + softirq + steal + guest + guest_nice))

# Calculate the CPU usage since we last checked
if [[ -f /tmp/cpu_usage.prev ]]; then
prev_total=$(< /tmp/cpu_usage.prev)
prev_idle=$(< /tmp/cpu_idle.prev)
diff_idle=$((idle - prev_idle))
diff_total=$((total - prev_total))
diff_usage=$((1000 * (diff_total - diff_idle) / diff_total + 5))
usage=$((diff_usage / 10))
else
usage=0
fi

# Save the current values for the next check
echo "${total}" > /tmp/cpu_usage.prev
echo "${idle}" > /tmp/cpu_idle.prev

echo "🏭 ${usage}%"
echo "🏭 ${usage}%"

# Color calculation
if [ $usage -ge 80 ]; then
echo "#FF0000"
elif [ $usage -ge 60 ]; then
echo "#FFFF00"
elif [ $usage -ge 40 ]; then
echo "#FFFFFF"
else
echo "#00FF00"
fi
10 changes: 10 additions & 0 deletions home/.config/i3blocks/custom_scripts/disk_usage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Get disk usage for root partition
disk_info=$(df -h / | awk '/\/$/ {print $4}')

echo "💾 ${disk_info}"
echo "💾 ${disk_info}"

# Color is always white for disk usage
echo "#FFFFFF"
Loading

0 comments on commit 3b8f69f

Please sign in to comment.