Dotfiles config update (2023-01-05)

This commit is contained in:
q3aql 2023-01-05 02:33:42 +01:00
parent 4f154bb78a
commit ba78a0959f
16 changed files with 330 additions and 145 deletions

View File

@ -1,141 +1,14 @@
#!/bin/bash #!/bin/bash
# baraction.sh for spectrwm status bar # baraction.sh for spectrwm status bar
status_bar=0
## DISK while [ ${status_bar} -eq 0 ] ; do
hdd() { updates=$(~/.config/spectrwm/scripts/checkUpdates.sh)
hdd="$(df -h | awk 'NR==4{print $3, $5}')" kernel=$(~/.config/spectrwm/scripts/kernel_version.sh)
echo -e "HDD: $hdd" cpuinfo=$(~/.config/spectrwm/scripts/cpu_info.sh)
} meminfo=$(~/.config/spectrwm/scripts/mem_info.sh)
volume=$(~/.config/spectrwm/scripts/get_volume.sh)
## RAM date=$(~/.config/spectrwm/scripts/current_date.sh)
mem() { echo "+@fg=3; ${updates} +@fg=0;+@fg=5; ${kernel} +@fg=0;+@fg=1; ${cpuinfo} +@fg=0;+@fg=2; ${meminfo} +@fg=0;+@fg=4; ${volume} +@fg=0;+@fg=5; ${date} +@fg=0;"
# Disable show meminfo sleep 2
#mem=`free | awk '/Mem/ {printf "%dM/%dM\n", $3 / 1024.0, $2 / 1024.0 }'`
#echo -e "$mem"
# Enable meminfo in GiB
memfile="/proc/meminfo"
size="G" # Change to M for MiB
# Variables
memTotal=$(cat ${memfile} | grep -i "memtotal:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(cat ${memfile} | grep -i "memavailable:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(expr ${memTotal} - ${memActive})
# Variables to calculate
memTotalM=$(expr ${memTotal} / 1024 )
memActiveM=$(expr ${memActive} / 1024)
memTotalG=$(calc ${memTotalM} / 1024 | tr -s " " | cut -c1-5)
memActiveG=$(calc ${memActiveM} / 1024 | tr -s " " | cut -c1-5)
# Variables to show
if [ "${size}" == "G" ] ; then
showMemTotal="${memTotalG}G"
showMemActive="${memActiveG}G"
elif [ "${size}" == "M" ] ; then
showMemTotal="${memTotalM}M"
showMemActive="${memActiveM}M"
else
showMemTotal="${memTotalG}G"
showMemActive="${memActiveG}G"
fi
show_mem_bar=$(echo ${showMemActive} /${showMemTotal})
echo -e ${show_mem_bar} | tr -s " "
}
## DATE AND TIME
date_today() {
#day_hour=$(date "+%a,%d %h %H:%M")
day_hour=$(date "+%d %h %H:%M")
echo -e "${day_hour}"
}
## DATE AND TIME (CUT)
date_today_cut() {
day_hour=$(date "+%H:%M")
echo -e "${day_hour}"
}
# KERNEL
kernel() {
# Parameters
longNumber=2
kernelCommand="uname -r"
# Kernel version
kernelVersion=""
count=1
# Extract numbers of kernel version
kernelVersionTemp=$(uname -r | cut -d "." -f ${count})
kernelVersionTempDot="${kernelVersionTemp}"
kernelVersion="${kernelVersion}${kernelVersionTempDot}"
count=$(expr ${count} + 1)
while [ ${count} -le ${longNumber} ] ; do
kernelVersionTemp=$(uname -r | cut -d "." -f ${count})
kernelVersionTempDot=".${kernelVersionTemp}"
kernelVersion="${kernelVersion}${kernelVersionTempDot}"
count=$(expr ${count} + 1)
done
kernelVersionTemp=$(uname -r | cut -d "." -f ${count} | cut -d "-" -f 1)
kernelVersionTempDot=".${kernelVersionTemp}"
kernelVersion=${kernelVersion}${kernelVersionTempDot}
# Apply arch
kernelVersion=${kernelVersion}
echo -e "Linux ${kernelVersion}"
}
## CPU
cpu() {
check_sensor=$(sensors | grep "Tdie:" 2> /dev/null)
if [ -z "${check_sensor}" ] ; then
check_sensor=$(sensors | grep "Tctl:" 2> /dev/null)
if [ -z "${check_sensor}" ] ; then
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%"
else
TEMP=$(sensors | grep 'Package id 0:\|Tctl' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o)
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% @ ${TEMP}"
fi
else
TEMP=$(sensors | grep 'Package id 0:\|Tdie' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o)
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% @ ${TEMP}"
fi
}
## VOLUME
vol() {
vol=`amixer get Master | awk -F'[][]' 'END{ print $4":"$2 }' | sed 's/on://g'`
echo -e "VOL: $vol"
}
SLEEP_SEC=3
#loops forever outputting a line every SLEEP_SEC secs
# It seems that we are limited to how many characters can be displayed via
# the baraction script output. And the the markup tags count in that limit.
# So I would love to add more functions to this script but it makes the
# echo output too long to display correctly.
while :; do
#echo "+@fg=5; $(kernel) +@fg=0; | +@fg=1; $(cpu) +@fg=0; | +@fg=2; $(mem) +@fg=0; | +@fg=3; $(hdd) +@fg=0; | +@fg=4; $(vol) +@fg=0; | +@fg=5; $(date_today_cut) +@fg=0;"
echo "+@fg=5; $(kernel) +@fg=0; | +@fg=1; $(cpu) +@fg=0; | +@fg=2; $(mem) +@fg=0; | +@fg=3; $(hdd) +@fg=0; | +@fg=4; $(vol) +@fg=0; | +@fg=5; $(date_today) +@fg=0;"
#echo "+@fg=5; +@fn=1;+@fn=0; $(kernel) +@fg=0; | +@fg=1; +@fn=1;💻+@fn=0; $(cpu) +@fg=0; | +@fg=2; +@fn=1;💾+@fn=0; $(mem) +@fg=0; | +@fg=3; +@fn=1;💿+@fn=0; $(hdd) +@fg=0; | +@fg=4; +@fn=1;🔈+@fn=0; $(vol) +@fg=0; |"
sleep $SLEEP_SEC
done done

View File

@ -0,0 +1,22 @@
#!/bin/bash
# Check updates on Arch Linux
# Note: Create cron on /etc/cron.d/checkupdates with the following lines:
# 0 * * * * root /usr/bin/pacman -Sy
# 30 * * * * root /usr/bin/pacman -Sy
if [ -f /usr/bin/pacman ] ; then
num_packages=$(pacman -Qu | wc -l)
echo "${num_packages} "
# Check updates on Ubuntu/Debian/Devuan
# Note: Create cron on /etc/cron.d/checkupdates with the following lines:
# 0 * * * * root /usr/bin/aptitude update
# 30 * * * * root /usr/bin/aptitude update
elif [ -f /usr/bin/aptitude ] ; then
num_packages=$(aptitude search "~U" | wc -l)
echo "${num_packages} "
# Disable for other distros
else
echo " 0 "
fi

View File

@ -0,0 +1,20 @@
#!/bin/sh
check_sensor=$(sensors | grep "Tdie:" 2> /dev/null)
if [ -z "${check_sensor}" ] ; then
check_sensor=$(sensors | grep "Tctl:" 2> /dev/null)
if [ -z "${check_sensor}" ] ; then
CPU_USAGE=$(~/.config/spectrwm/scripts/cpu_load.sh -p)
echo "$CPU_USAGE" | awk '{ printf("%6s \n"), $1, $2 }'
else
TEMP=$(sensors | grep 'Package id 0:\|Tctl' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o)
#CPU_USAGE=$(mpstat 1 1 | awk '/Average:/ {printf("%s\n", $(NF-9))}')
CPU_USAGE=$(~/.config/spectrwm/scripts/cpu_load.sh -p)
echo "$CPU_USAGE $TEMP" | awk '{ printf("%6s @ %s \n"), $1, $2 }'
fi
else
TEMP=$(sensors | grep 'Package id 0:\|Tdie' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o)
#CPU_USAGE=$(mpstat 1 1 | awk '/Average:/ {printf("%s\n", $(NF-9))}')
CPU_USAGE=$(~/.config/spectrwm/scripts/cpu_load.sh -p)
echo "$CPU_USAGE $TEMP" | awk '{ printf("%6s @ %s \n"), $1, $2 }'
fi

View File

@ -0,0 +1,83 @@
#!/bin/bash
# Script to show cpu
# Created by q3aql (q3aql@protonmail.ch)
# Licensed by GPL v.2
# Date: 10-01-2020
# --------------------------------------
VERSION="1.0"
# Variables
cpuPercentage=$(top -b -n1 | grep \%Cpu | awk '{print 100-$8}')
showCpuPercentage=$(echo ${cpuPercentage})
showCpuPercentageInteger=$(echo ${showCpuPercentage} | cut -d "." -f 1)
# Show percentage bar
if [ ${showCpuPercentageInteger} -ge 0 ] ; then
showCpuPercentageBar="="
fi
if [ ${showCpuPercentageInteger} -ge 3 ] ; then
showCpuPercentageBar="=="
fi
if [ ${showCpuPercentageInteger} -ge 12 ] ; then
showCpuPercentageBar="==="
fi
if [ ${showCpuPercentageInteger} -ge 18 ] ; then
showCpuPercentageBar="===="
fi
if [ ${showCpuPercentageInteger} -ge 25 ] ; then
showCpuPercentageBar="====="
fi
if [ ${showCpuPercentageInteger} -ge 35 ] ; then
showCpuPercentageBar="======"
fi
if [ ${showCpuPercentageInteger} -ge 40 ] ; then
showCpuPercentageBar="======="
fi
if [ ${showCpuPercentageInteger} -ge 45 ] ; then
showCpuPercentageBar="========"
fi
if [ ${showCpuPercentageInteger} -ge 50 ] ; then
showCpuPercentageBar="=========="
fi
if [ ${showCpuPercentageInteger} -ge 62 ] ; then
showCpuPercentageBar="============="
fi
if [ ${showCpuPercentageInteger} -ge 75 ] ; then
showCpuPercentageBar="==============="
fi
if [ ${showCpuPercentageInteger} -ge 85 ] ; then
showCpuPercentageBar="================="
fi
if [ ${showCpuPercentageInteger} -ge 90 ] ; then
showCpuPercentageBar="=================="
fi
if [ ${showCpuPercentageInteger} -ge 95 ] ; then
showCpuPercentageBar="==================="
fi
if [ ${showCpuPercentageInteger} -ge 100 ] ; then
showCpuPercentageBar="===================="
fi
# Show results
if [ "$1" == "-p" ]; then
echo ${showCpuPercentage}%
elif [ "$1" == "-b" ]; then
echo ${showCpuPercentageBar}
else
echo ""
echo " cpuinfo v$VERSION"
echo " ------------"
echo ""
echo " CpuPercentage Use:"
echo " ${showCpuPercentageBar} ${showCpuPercentage}%"
echo ""
echo " Available commands:"
echo ""
echo " cpuinfo.sh -p | Show CpuPercentage"
echo " cpuinfo.sh -b | Show CpuPercentage Bar"
echo ""
echo " Note: Conky require 'maximum_width = 240'"
echo ""
fi

View File

@ -0,0 +1,4 @@
#!/bin/bash
current_date=$(date "+%d/%m/%Y %H:%M")
echo "${current_date} "

View File

@ -0,0 +1,3 @@
#!/bin/bash
df -h / | awk '/\//{ printf(" %4s / %s \n", $4, $2) }'

View File

@ -0,0 +1,4 @@
#!/bin/bash
get_volume=$(amixer | grep "%" | head -1 | cut -d "%" -f 1 | cut -d "[" -f 2)
echo "${get_volume}% "

View File

@ -0,0 +1,34 @@
#!/bin/bash
# Parameters
longNumber=2
kernelCommand="uname -r"
archCommand=$(uname -m)
# Kernel version
kernelVersion=""
count=1
# Extract numbers of kernel version
kernelVersionTemp=$(uname -r | cut -d "." -f ${count})
kernelVersionTempDot="${kernelVersionTemp}"
kernelVersion="${kernelVersion}${kernelVersionTempDot}"
count=$(expr ${count} + 1)
while [ ${count} -le ${longNumber} ] ; do
kernelVersionTemp=$(uname -r | cut -d "." -f ${count})
kernelVersionTempDot=".${kernelVersionTemp}"
kernelVersion="${kernelVersion}${kernelVersionTempDot}"
count=$(expr ${count} + 1)
done
kernelVersionTemp=$(uname -r | cut -d "." -f ${count} | cut -d "-" -f 1)
kernelVersionTempDot=".${kernelVersionTemp}"
kernelVersion=${kernelVersion}${kernelVersionTempDot}
# Apply arch
#kernelVersion=${kernelVersion}-${archCommand}
kernelVersion=${kernelVersion}
#echo "Kernel: Linux ${kernelVersion} "
echo "${kernelVersion} "

View File

@ -0,0 +1,34 @@
#!/bin/bash
# Parameters
longNumber=2
kernelCommand="uname -r"
archCommand=$(uname -m)
# Kernel version
kernelVersion=""
count=1
# Extract numbers of kernel version
kernelVersionTemp=$(uname -r | cut -d "." -f ${count})
kernelVersionTempDot="${kernelVersionTemp}"
kernelVersion="${kernelVersion}${kernelVersionTempDot}"
count=$(expr ${count} + 1)
while [ ${count} -le ${longNumber} ] ; do
kernelVersionTemp=$(uname -r | cut -d "." -f ${count})
kernelVersionTempDot=".${kernelVersionTemp}"
kernelVersion="${kernelVersion}${kernelVersionTempDot}"
count=$(expr ${count} + 1)
done
kernelVersionTemp=$(uname -r | cut -d "." -f ${count} | cut -d "-" -f 1)
kernelVersionTempDot=".${kernelVersionTemp}"
kernelVersion=${kernelVersion}${kernelVersionTempDot}
# Apply arch
#kernelVersion=${kernelVersion}-${archCommand}
kernelVersion=${kernelVersion}
#echo "Kernel: Linux ${kernelVersion} "
echo "${kernelVersion} "

View File

@ -0,0 +1,47 @@
#!/bin/bash
# Configuration variable
python_bin="/usr/bin/python3"
memfile="/proc/meminfo"
size="G" # Change to M for MiB
# Variables
memTotal=$(cat ${memfile} | grep -i "memtotal:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(cat ${memfile} | grep -i "memavailable:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(expr ${memTotal} - ${memActive})
# Variables to calculate
memTotalM=$(expr ${memTotal} / 1024 )
memActiveM=$(expr ${memActive} / 1024)
if [ -f ${python_bin} ] ; then
memPercentage=$(echo "n=${memActive}/${memTotal}*100 ; print(n)" | ${python_bin})
memTotalG=$(echo "n=${memTotalM}/1024 ; print(n)" | ${python_bin} | tr -s " " | cut -c1-4)
memActiveG=$(echo "n=${memActiveM}/1024 ; print(n)" | ${python_bin} | tr -s " " | cut -c1-4)
elif [ -f /usr/bin/calc ] ; then
memPercentage=$(calc ${memActive} / ${memTotal} \* 100)
memTotalG=$(calc ${memTotalM} / 1024 | tr -s " " | cut -c1-5)
memActiveG=$(calc ${memActiveM} / 1024 | tr -s " " | cut -c1-5)
else
memPercentage=$(expr ${memActive} / ${memTotal} \* 100)
memTotalG=$(expr ${memTotalM} / 1024 | tr -s " " | cut -c1-5)
memActiveG=$(expr ${memActiveM} / 1024 | tr -s " " | cut -c1-5)
fi
# Variables to show
showMemPercentage=$(echo ${memPercentage} | cut -d "~" -f 2 | cut -d "." -f 1)
if [ "${size}" == "G" ] ; then
showMemTotal="${memTotalG}Gi"
showMemActive="${memActiveG}Gi"
elif [ "${size}" == "M" ] ; then
showMemTotal="${memTotalM}Mi"
showMemActive="${memActiveM}Mi"
else
showMemTotal="${memTotalG}Gi"
showMemActive="${memActiveG}Gi"
fi
echo -n " "
memshowactive=$(echo ${showMemActive})
memshowtotal=$(echo ${showMemTotal})
echo -n ${memshowactive}/${memshowtotal}
echo " "

View File

@ -0,0 +1,42 @@
#!/bin/bash
# Configuration variables
memfile="/proc/meminfo"
size="G" # Change to M for MiB
# Variables
memTotal=$(cat ${memfile} | grep -i "memtotal:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(cat ${memfile} | grep -i "memavailable:" | head -1 | tr -s " " | cut -d " " -f 2)
memActive=$(expr ${memTotal} - ${memActive})
# Variables to calculate
memTotalM=$(expr ${memTotal} / 1024 )
memActiveM=$(expr ${memActive} / 1024)
if [ -f /usr/bin/calc ] ; then
memPercentage=$(calc ${memActive} / ${memTotal} \* 100)
memTotalG=$(calc ${memTotalM} / 1024 | tr -s " " | cut -c1-5)
memActiveG=$(calc ${memActiveM} / 1024 | tr -s " " | cut -c1-5)
else
memPercentage=$(expr ${memActive} / ${memTotal} \* 100)
memTotalG=$(expr ${memTotalM} / 1024 | tr -s " " | cut -c1-5)
memActiveG=$(expr ${memActiveM} / 1024 | tr -s " " | cut -c1-5)
fi
# Variables to show
showMemPercentage=$(echo ${memPercentage} | cut -d "~" -f 2 | cut -d "." -f 1)
if [ "${size}" == "G" ] ; then
showMemTotal="${memTotalG}Gi"
showMemActive="${memActiveG}Gi"
elif [ "${size}" == "M" ] ; then
showMemTotal="${memTotalM}Mi"
showMemActive="${memActiveM}Mi"
else
showMemTotal="${memTotalG}Gi"
showMemActive="${memActiveG}Gi"
fi
echo -n " "
memshowactive=$(echo ${showMemActive})
memshowtotal=$(echo ${showMemTotal})
echo -n ${memshowactive}/${memshowtotal}
echo " "

View File

@ -0,0 +1,6 @@
#!/bin/bash
mem_info=$(free -h | awk '/Mem:/ { printf(" %5s/%s \n", $3, $2) }')
echo -n " "
echo -n ${mem_info}
echo " "

View File

@ -0,0 +1,14 @@
#!/bin/bash
status_bar=0
while [ ${status_bar} -eq 0 ] ; do
updates=$(~/.config/spectrwm/scripts/checkUpdates.sh)
kernel=$(~/.config/spectrwm/scripts/kernel_version.sh)
cpuinfo=$(~/.config/spectrwm/scripts/cpu_info.sh)
meminfo=$(~/.config/spectrwm/scripts/mem_info.sh)
volume=$(~/.config/spectrwm/scripts/get_volume.sh)
date=$(~/.config/spectrwm/scripts/current_date.sh)
echo "${updates} ${kernel} ${cpuinfo} ${meminfo} ${volume} ${date}"
sleep 2
done

View File

@ -30,10 +30,10 @@ tile_gap = 8
# disable_border = 1 # disable_border = 1
# Bar Settings # Bar Settings
bar_action = ~/.config/polybar/launch-spectrwm.sh bar_action = ~/.config/spectrwm/baraction.sh
bar_action_expand = 1 bar_action_expand = 200
bar_enabled = 1 bar_enabled = 1
bar_border_width = 5 bar_border_width = 6
bar_border[1] = rgb:28/2a/36 bar_border[1] = rgb:28/2a/36
bar_border_unfocus[1] = rgb:28/2a/36 bar_border_unfocus[1] = rgb:28/2a/36
bar_color[1] = rgb:28/2a/36, rgb:00/80/80 bar_color[1] = rgb:28/2a/36, rgb:00/80/80
@ -43,7 +43,7 @@ bar_font_color[1] = rgb:bb/c5/ff, rgb:e1/ac/ff, rgb:dd/ff/a7, rgb:ff/8b/92
bar_font_color_selected = black bar_font_color_selected = black
#bar_font = Mononoki Nerd Font:size=9, JoyPixels:size=9 #bar_font = Mononoki Nerd Font:size=9, JoyPixels:size=9
#bar_font = Mononoki Nerd Font:size=9 #bar_font = Mononoki Nerd Font:size=9
bar_font = Noto Sans Font:size=9 bar_font = UbuntuMono Nerd Font:size=11.5
bar_justify = center # Don't touch bar_justify = center # Don't touch
#bar_format = +|L+1<+N:+I +S (+D) +P +|R+A+1< # Bars on the sides #bar_format = +|L+1<+N:+I +S (+D) +P +|R+A+1< # Bars on the sides
@ -82,7 +82,7 @@ autorun = ws[1]:~/.config/spectrwm/startwallpaper.sh
autorun = ws[1]:~/.config/spectrwm/startxrandr.sh autorun = ws[1]:~/.config/spectrwm/startxrandr.sh
# Load compton of picom # Load compton of picom
autorun = ws[1]:~/.config/spectrwm/startcompositor.sh #autorun = ws[1]:~/.config/spectrwm/startcompositor.sh
# Start screensaver # Start screensaver
autorun = ws[1]:~/.config/spectrwm/startscreensaver.sh autorun = ws[1]:~/.config/spectrwm/startscreensaver.sh
@ -91,7 +91,7 @@ autorun = ws[1]:~/.config/spectrwm/startscreensaver.sh
autorun = ws[1]:~/.config/spectrwm/autostart.sh autorun = ws[1]:~/.config/spectrwm/autostart.sh
# Autostart tray on Workspace 7 # Autostart tray on Workspace 7
#autorun = ws[7]:~/.config/spectrwm/showtray.sh autorun = ws[7]:~/.config/spectrwm/showtray.sh
# Customize workspace layout at start # Customize workspace layout at start
# layout = ws[1]:4:0:0:0:vertical # layout = ws[1]:4:0:0:0:vertical
@ -324,7 +324,7 @@ bind[xfce4-screenshooter] = MOD+s
program[nitrogen] = nitrogen program[nitrogen] = nitrogen
bind[nitrogen] = MOD+z bind[nitrogen] = MOD+z
program[showtray] = ~/.config/polybar/launch-spectrwm.sh program[showtray] = ~/.config/spectrwm/showtray.sh
bind[showtray] = MOD+Shift+t bind[showtray] = MOD+Shift+t
# QUIRKS # QUIRKS

View File

@ -26,7 +26,6 @@ dotfiles - My tiling Sway configuration (for Arch/Devuan/Debian)
$ cd dotfiles $ cd dotfiles
$ chmod +x install-config.sh $ chmod +x install-config.sh
$ ./install-config.sh $ ./install-config.sh
$ cp -rfv ~/.config/waybar/config.icons ~/.config/waybar/config
```` ````
### Configuration: ### Configuration:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 230 KiB