major restructuring for using snowfall

This commit is contained in:
2024-02-01 12:42:15 +01:00
parent d8e53f1f78
commit 67d23bcd9e
87 changed files with 24 additions and 164 deletions

30
non-nix/i3/i3blocks/activity Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
NONE="None"
get_current_activity() {
activity=$(hamster current)
if [ "$activity" = "No activity" ]; then
echo $NONE
else
IFS=' '
read -ra ADDR <<< "$activity"
echo "${ADDR[2]}"
fi
}
case "$BLOCK_BUTTON" in
1|2|3)
current_activity=$(get_current_activity)
if [ "$current_activity" = "$NONE" ]; then
hamster start "Comu@Work#Flexibill App"
else
hamster stop
fi
esac
current_activity=$(get_current_activity)
echo "$LABEL $current_activity"
echo "$LABEL $current_activity"

35
non-nix/i3/i3blocks/calendar Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
DATEFMT=${DATEFMT:-"+%a %d.%m.%Y %H:%M:%S"}
SHORTFMT=${SHORTFMT:-"+%H:%M:%S"}
OPTIND=1
while getopts ":f:" opt; do
case $opt in
f) DATEFMT="$OPTARG" ;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
case "$BLOCK_BUTTON" in
1|2|3)
# Try to focus Thunderbird
i3-msg -q [class="Thunderbird" instance="Mail"] focus
if [ $? == 2 ]
then
# Open Thunderbird if it was not open
i3-msg -q "exec thunderbird -mail -calendar"
else
# Open calendar
xdotool key --clearmodifiers --delay 5 ctrl+shift+c
fi
esac
echo "$LABEL$(date "$DATEFMT")"
echo "$LABEL$(date "$SHORTFMT")"

View File

@ -0,0 +1,36 @@
# i3blocks configuration file
#
# The i3blocks man page describes the usage of the binary,
# and its website describes the configuration:
#
# https://vivien.github.io/i3blocks
# Sources:
# https://github.com/hastinbe/i3blocks-battery-plus
# https://github.com/zakariaGatter/i3blocks-gate
# Global properties
separator=true
separator_block_width=15
[activity]
command=./activity
interval=10
LABEL=
[dunst]
command=./dunst
markup=pango
interval=once
format=json
[volume]
command=./volume
LABEL=
interval=10
signal=1
[calendar]
command=./calendar
interval=1

60
non-nix/i3/i3blocks/dunst Executable file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env python3
"""
A do-not-disturb button for muting Dunst notifications in i3 using i3blocks
Mute is handled by passing 'DUNST_COMMAND_PAUSE' and 'DUNST_COMMAND_RESUME' to
the notify-send script and the 'DUNST_MUTE' environment variable is set to keep
track of the toggle.
"""
__author__ = "Jessey White-Cinis <j@cin.is>"
__copyright__ = "Copyright (c) 2019 Jessey White-Cinis"
__license__ = "MIT"
__version__ = "1.1.0"
import os
import subprocess
import json
def mute_on():
'''Turns off dunst notifications'''
subprocess.run(["dunstctl", "set-paused", "true"], check=True)
return {
"full_text":"<span font='Font Awesome 5 Free Solid' color='#BE616E'>\uf1f6</span>",
"DUNST_MUTE":"on"
}
def mute_off():
'''Turns back on dunst notifications'''
subprocess.run(["dunstctl", "set-paused", "false"], check=True)
return {
"full_text":"<span font='Font Awesome 5 Free Solid' color='#FFFFFF'>\uf0f3</span>",
"DUNST_MUTE":"off"
}
def clicked():
'''Returns True if the button was clicked'''
button = "BLOCK_BUTTON" in os.environ and os.environ["BLOCK_BUTTON"]
return bool(button)
def muted():
'''Returns True if Dunst is muted'''
cmd = ['dunstctl', 'is-paused']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
output = proc.communicate()[0]
return u'true' == output.strip().decode("UTF-8")
if clicked():
# toggle button click to turn mute on and off
if muted():
RTN = mute_off()
else:
RTN = mute_on()
else:
# Set default state using 'DUNST_MUTE' environment variable
if muted():
RTN = mute_on()
else:
RTN = mute_off()
print(json.dumps(RTN))

462
non-nix/i3/i3blocks/i3b-gate Executable file
View File

@ -0,0 +1,462 @@
#!/usr/bin/env bash
# Zakaria Barkouk ( Zakaria.gatter@gmail.com)
#---------------------#
# SHOW CPU INFO (TOP) #
#---------------------#
_BLOCK_1_(){ #{{{
mpstat | awk '/all/{print "'"${1:-} "'"$4}'
} #}}}
#--------------------#
# SHOW ALL CPUS INFO #
#--------------------#
_BLOCK_2_(){ #{{{
mpstat -P ALL | awk -v icon=${1:-} 'BEGIN{printf "%s ", icon} {
if($3 ~ /^[0-9]/){
printf "%s ", $4
}
}'
} #}}}
#--------------------------#
# SHOW MEMORY USAGE (FREE) #
#--------------------------#
_BLOCK_3_(){ #{{{
free -h | awk '/^Mem:/{print "'"${1:-} "'"$3}'
} #}}}
#------------------------#
# SHOW SWAP USAGE (FREE) #
#------------------------#
_BLOCK_4_(){ #{{{
free -h | awk '/^Swap:/{print "'"${1:-}"' "$3}'
} #}}}
#---------------------------#
# SHOW DATE AND TIME (DATE) #
#---------------------------#
_BLOCK_5_(){ #{{{
date +"${1:-} %R %D"
} #}}}
#----------------------------#
# SHOW BATTERY STATUS (ACPI) #
#----------------------------#
_BLOCK_6_(){ #{{{
Bat=$(acpi | awk '{gsub(",|%","",$4); print $4}');
adapt=$(acpi -a | awk '{print $3}');
if [ "$adapt" = "on-line" -a -n "$Bat" ];then
icon0=" "
icon1=" "
icon2=" "
icon3=" "
icon4=" "
elif [ "$adapt" = "on-line" ];then
icon0=""
icon1=""
icon2=""
icon3=""
icon4=""
else
icon0=""
icon1=""
icon2=""
icon3=""
icon4=""
fi
[ -z "$Bat" ] && echo "$icon0 $adapt" && return
[ "$Bat" -gt "100" ] && echo "$icon4 Full"
[ "$Bat" -gt "90" ] && echo "$icon3 $Bat%"
[ "$Bat" -gt "60" ] && echo "$icon2 $Bat%"
[ "$Bat" -gt "30" ] && echo "$icon1 $Bat%"
[ "$Bat" -lt "30" ] && echo "$icon0 $Bat%"
} #}}}
#----------------------#
# SHOW DISK USAGE (DF) #
#----------------------#
_BLOCK_7_() { #{{{
df -h "${1:-/}" | awk '/\/dev\//{print "'"${2:-}"' "$3-G"/"$2}'
} #}}}
#----------------------#
# SHOW KEYBOARD LAYOUT #
#----------------------#
_BLOCK_8_() { #{{{
awk -F '"' '/XKBLAYOUT/{print "'"${1:-} "'"$2}' /etc/default/keyboard
} #}}}
#----------------------#
# SHOW SYSTEM LANGUAGE #
#----------------------#
_BLOCK_9_(){ #{{{
echo "${1:-} ${LANG/.UTF-8/}"
} #}}}
#------------------------------#
# SHOW MACHINE UPTIME (UPTIME) #
#------------------------------#
_BLOCK_10_() { #{{{
uptime | awk '{sub(",","",$4); print "'"${1:- } "'"$3 " " $4}'
} #}}}
#----------------------#
# SHOW TRASH SIZE (DU) #
#----------------------#
_BLOCK_11_() { #{{{
[ -d "$HOME/.local/share/Trash/files" ] && {
du -hc $HOME/.local/share/Trash/files | awk '/total$/{print "'"${1:-} "'"$1}'
} || {
echo "${1:-} ---"
}
} #}}}
#-------------------#
# SHOW WINDOW USAGE #
#-------------------#
_BLOCK_12_() { #{{{
focus=$(xprop -id `xprop -root | awk '/^_NET_ACTIVE_WINDOW/{print $5}'` | awk -F '"' '/^WM_NAME/{print $2}')
if [ -z "$focus" ];then
echo "${1:-} Welcome"
else
[ "${#focus}" -gt "${2:-30}" ] && echo "${1:-} ${focus::${2:-30}} ..." || echo "${1:-} $focus"
fi
} #}}}
#-----------------------------------------#
# SHOW MOCP PLAYING SONG AND STATUS (MOC) #
#-----------------------------------------#
_BLOCK_13_() { # {{{
Title=$(mocp -Q %title)
F_Title=$(basename `mocp -Q %file | tr " " "_"`)
Status=$(mocp -Q %state)
if [ "$Status" != "PLAY" ];then
echo "${1:-} Pause"
elif [ -z "$Title" ];then
echo "${1:-} ${F_Title::30}"
else
echo "${1:-} $Title"
fi
} #}}}
#------------------------------------------------------#
# SHOW MPD PLAYING SONG AND STATUS (MPD; NCMPCCP, MPC) #
#------------------------------------------------------#
_BLOCK_14_() { #{{{
local NCMP=$(mpc | awk '/^\[playing\]/{print $1}')
if [ "$NCMP" = "[playing]" ];then
echo "${1:-} $(basename $(mpc current)) "
else
echo "${1:-} Pause "
fi
} #}}}
#-------------------------#
# SHOW CPU TEMP (XSENSER) #
#-------------------------#
_BLOCK_15_() { #{{{
sensors | awk '/^CPU/{gsub("\+",""); print "'"${1:-} "'"$2}'
} #}}}
#-------------------------#
# SHOW GPU TEMP (XSENSER) #
#-------------------------#
_BLOCK_16_() { #{{{
sensors | awk '/^GPU/{gsub("\+",""); print "'"${1:-} "'"$2}' | tail -1
} #}}}
#----------------------------------#
# SHOW TOUCHPAD STATUS (SYSCLIENT) #
#----------------------------------#
_BLOCK_17_() { #{{{
[ "$(synclient -l | awk '/Touchpad/{print $3}')" = "0" ] && echo "${1:-} Enable" || echo "${1:-} Disable"
} #}}}
#---------------------------#
# SHOW VOLUME STATUS (ALSA) #
#---------------------------#
_BLOCK_18_() { #{{{
local Vol=$(amixer get Master | awk '/Mono:/{gsub("\[|\%|\]",""); print $4}')
local Mute=$(amixer get Master | awk '/Mono:/{gsub("\[|\]",""); print $6}')
if [ "$Mute" = "off" ];then
echo -e " --"
else
if [ "$Vol" -gt "60" ];then
echo -e " $Vol%"
elif [ "$Vol" -gt "30" ];then
echo -e " $Vol%"
elif [ "$Vol" -lt "30" ];then
echo -e " $Vol%"
fi
fi
} #}}}
#----------------------------------------------#
# SHOW WIFI INFO ; IP ; CONNECTED NAME (NMCLI) #
#----------------------------------------------#
_BLOCK_19_() { #{{{
while read -a W ;do
[ "${W[2]}" = "connected" ] && {
_ip=$(nmcli device show ${W[0]} | awk '/^IP4.ADDRESS/{print $NF}')
_name=$(nmcli device show ${W[0]} | awk '/^GENERAL.CONNECTION:/{$1=""; print $0}')
echo -n "${1:-} ${_ip%/*} (${_name} )"
} || {
echo -n "${1:-} ---"
}
done< <(nmcli d | grep -w "wifi")
echo -e ""
} #}}}
#-------------------------------------------#
# SHOW ETHERNET INFO ; IP ; CONNECTED NAME #
#-------------------------------------------#
_BLOCK_20_() { #{{{
while read -a W ;do
[ "${W[2]}" = "connected" ] && {
_ip=$(nmcli device show ${W[0]} | awk '/^IP4.ADDRESS/{print $NF}')
_name=$(nmcli device show ${W[0]} | awk '/^GENERAL.CONNECTION:/{$1=""; print $0}')
echo -n "${1:-} ${_ip%/*} (${_name} ) "
} || {
echo -n "${1:-} ---"
}
done< <(nmcli d | grep "ethernet")
echo -e ""
} #}}}
#-----------------------------------------------#
# SHOW WIFI INFO ; IP6 ; CONNECTED NAME (NMCLI) #
#-----------------------------------------------#
_BLOCK_21_() { #{{{
while read -a W ;do
[ "${W[2]}" = "connected" ] && {
_ip=$(nmcli device show ${W[0]} | awk '/^IP6.ADDRESS/{print $NF}')
_name=$(nmcli device show ${W[0]} | awk '/^GENERAL.CONNECTION:/{$1=""; print $0}')
echo -n "${1:-} ${_ip%/*} (${_name} ) "
} || {
echo -n "${1:-} ---"
}
done< <(nmcli d | grep "wifi")
echo -e ""
} #}}}
#--------------------------------------------#
# SHOW ETHERNET INFO ; IP6 ; CONNECTED NAME #
#--------------------------------------------#
_BLOCK_22_() { #{{{
while read -a W ;do
[ "${W[2]}" = "connected" ] && {
_ip=$(nmcli device show ${W[0]} | awk '/^IP6.ADDRESS/{print $NF}')
_name=$(nmcli device show ${W[0]} | awk '/^GENERAL.CONNECTION:/{$1=""; print $0}')
echo -n "${1:-} ${_ip%/*} (${_name} ) "
} || {
echo -n "${1:-} ---"
}
done< <(nmcli d | grep "ethernet")
echo -e ""
} #}}}
#-------------------------------#
# SHOW PROSSES USE BY THIS USER #
#-------------------------------#
_BLOCK_23_() { #{{{
echo "${1:-} $(ps -U $USER | wc -l)"
} #}}}
#---------------------#
# SHOW SYSTEM KERENEL #
#---------------------#
_BLOCK_24_() { #{{{
echo "${1:-} $(uname -r)"
} #}}}
#-----------------------------#
# SHOW USB PLUG IN UR COMPUTE #
#-----------------------------#
_BLOCK_25_() { #{{{
echo "${1:-} $(lsblk -l -o 'TRAN' | grep -c "usb")"
} #}}}
#---------------------------------------#
# SHOW TOTAL PKGS INSTALL IN YOUR SYSTE #
#---------------------------------------#
_BLOCK_26_() { #{{{
echo "${1:-} $(dpkg -l | grep -c "^ii")"
} #}}}
#--------------------------------------------#
# CHECK IF THERE IS ANY UPDATE IN UR SYSTEM #
#--------------------------------------------#
_BLOCK_27_() { #{{{
local U_PKGS=$(apt-get -s -o APT::Get::Show-User-Simulation-Note=0 dist-upgrade | grep "^\s\s" | wc -w);
echo "${1:-} $U_PKGS"
} #}}}
#-----------------#
# SHOW UFW STATUS #
#-----------------#
_BLOCK_28_() { #{{{
[ "$(systemctl status ufw | awk '/Active:/{print $2}')" == "active" ] && echo "${1:-} On" || echo "${1:-} Off"
} #}}}
#-------------------------#
# SHOW NUMBER LOCK STATUS #
#-------------------------#
_BLOCK_29_() { #{{{
[ "$(xset -q | awk '/00:/{print $8}')" == "on" ] && echo "${1:-} On" || echo "${1:-} Off"
} #}}}
#-----------------------#
# SHOW BLUETOOTH STATUS #
#-----------------------#
_BLOCK_30_() { #{{{
[ "$(systemctl status bluetooth.target | awk '/Active:/{print $2}')" == "active" ] && echo "${1:-} On" || echo "${1:-} Off"
} #}}}
#------------------------#
# SHOW CAPS LOCK STATUS #
#------------------------#
_BLOCK_31_() { #{{{
[ "$(xset -q | awk '/00:/{print $4}')" == "on" ] && echo "${1:-} On" || echo "${1:-} Off"
} #}}}
#-----------------------------#
# DISPLAY X SCREENSAVER STATE #
#-----------------------------#
_BLOCK_32_() { #{{{
[ "$(xdg-screensaver status)" != "enabled" ] && echo "${1:-} Off" || echo "${1:-} On"
} #}}}
#--------------------------------#
# CALCULE MOUNT POINTS ON SYSTEM #
#--------------------------------#
_BLOCK_33_() { #{{{
echo "${1:-} $(cat /proc/mounts | grep -c "^/dev/sd*") "
} #}}}
#-------------------------#
# SHOW CMUS PLAYING SONG #
#-------------------------#
_BLOCK_34_() { #{{{
local CMUS_P=$(cmus-remote -Q | awk '/^status/{print $2}')
local CMUS_F=$(cmus-remote -Q | awk '/^file/{$1=""; print $2}')
if [ "$CMUS_P" = "Playing" ];then
echo "${1:-} $(basename $CMUS_F)"
else
echo "${1:-} Pause"
fi
} #}}}
#----------------------#
# SHOW APPARMOR STATUS #
#----------------------#
_BLOCK_35_() { #{{{
[ "$(aa-enabled)" = "Yes" ] && {
echo "${1:-} On"
}||{
echo "${1:-} Off"
}
} #}}}
#-----------------------------#
# SHOW TOTAL PACKAGES IN ARCH #
#-----------------------------#{{{
_BLOCK_36_(){
echo "${1:-} $(pacman -Q | grep -c "*")"
}
#}}}
#--------------------#
# SHOW I3 WORKSPACES #
#--------------------#
_BLOCK_37_() { #{{{
i3-msg -t get_workspaces | awk -F , '{
for(i=1;i<=NF;i++){
if($i~"name"){
gsub("\"name\":|\"","",$i)
WK=$i
}
if($i~"focused"){
gsub("\"focused\":","",$i)
WKF=$i
}
if($i~"urgent"){
gsub("\"urgent\":|\]|\}","",$i)
if($i=="false" && WKF=="true"){
printf "%s ", WK
}
if($i=="false" && WKF=="false"){
printf"[%s] ", WK
}
if($i=="true" && WKF=="false"){
printf "[*%s] ", WK
}
if($i=="true" && WKF=="true"){
printf "*%s ", WK
}
}
}
}'
} #}}}
#-----------------#
# SHOW USER NAME #
#-----------------#
_BLOCK_38_(){ #{{{
echo -e "${1:-} $USER"
} #}}}
#-------------------#
# SHOW VOLUME PULSE #
#-------------------#
_BLOCK_39_(){
local Vol=$(pactl list sinks | awk '/Volume: front/{print $5-"%"}')
local Mute=$(amixer get Master | awk '/Mono:/{gsub("\[|\]",""); print $6}')
if [ "$Mute" = "off" ];then
echo -e " --"
else
if [ "$Vol" -gt "60" ];then
echo -e " $Vol%"
elif [ "$Vol" -gt "30" ];then
echo -e " $Vol%"
elif [ "$Vol" -lt "30" ];then
echo -e " $Vol%"
fi
fi
}
#------------------------#
# USAGE AND HELP DIALOG #
#------------------------#
_USAGE_(){ #{{{
echo -e "
i3b-gate : is a all in one collaction of small script
show you useful unformation about your system
There is 39 deffirent script to use
for more information you can see the 'README' file
or visite 'https://gitlab.com/zakariagatter/i3blocks-gate'
SYNTAX :
i3b-gate [NUMBER] ...
"
} #}}}
#----------------#
# MAIN ARGUMENT #
#----------------#
if [ "$1" -gt "39" ] || [ -z "$1" ] ;then
_USAGE_
elif [ "$1" = "-h" ]; then
_USAGE_
else
eval $(echo "_BLOCK_$1_ $2 $3")
fi

26
non-nix/i3/i3blocks/keyboard Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
get_current_layout () {
setxkbmap -print | grep -q dvorak
if [ "$?" -eq "0" ]; then
echo dvorak
else
echo qwertz
fi
}
case "$BLOCK_BUTTON" in
1|2|3)
# Switch layout
current_layout=$(get_current_layout)
if [ $current_layout == dvorak ]; then
setxkbmap -layout de
else
setxkbmap -layout de -variant dvorak
fi
esac
current_layout=$(get_current_layout)
echo "$LABEL $current_layout"
echo "$LABEL $current_layout"

91
non-nix/i3/i3blocks/volume Executable file
View File

@ -0,0 +1,91 @@
#!/usr/bin/env bash
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# Copyright (C) 2014 Alexander Keller <github@nycroth.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------
# The second parameter overrides the mixer selection
# For PulseAudio users, eventually use "pulse"
# For Jack/Jack2 users, use "jackplug"
# For ALSA users, you may use "default" for your primary card
# or you may use hw:# where # is the number of the card desired
if [[ -z "$MIXER" ]] ; then
MIXER="default"
if command -v pulseaudio >/dev/null 2>&1 && pulseaudio --check ; then
# pulseaudio is running, but not all installations use "pulse"
if amixer -D pulse info >/dev/null 2>&1 ; then
MIXER="pulse"
fi
fi
[ -n "$(lsmod | grep jack)" ] && MIXER="jackplug"
MIXER="${2:-$MIXER}"
fi
# The instance option sets the control to report and configure
# This defaults to the first control of your selected mixer
# For a list of the available, use `amixer -D $Your_Mixer scontrols`
if [[ -z "$SCONTROL" ]] ; then
SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols |
sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" |
head -n1
)}"
fi
# The first parameter sets the step to change the volume by (and units to display)
# This may be in in % or dB (eg. 5% or 3dB)
if [[ -z "$STEP" ]] ; then
STEP="${1:-5%}"
fi
# AMIXER(1):
# "Use the mapped volume for evaluating the percentage representation like alsamixer, to be
# more natural for human ear."
NATURAL_MAPPING=${NATURAL_MAPPING:-0}
if [[ "$NATURAL_MAPPING" != "0" ]] ; then
AMIXER_PARAMS="-M"
fi
#------------------------------------------------------------------------
capability() { # Return "Capture" if the device is a capture device
amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL |
sed -n "s/ Capabilities:.*cvolume.*/Capture/p"
}
volume() {
amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL $(capability)
}
format() {
perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)'
perl_filter+='{CORE::say $4 eq "off" ? "MUTE" : "'
# If dB was selected, print that instead
perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1')
perl_filter+='"; exit}'
output=$(perl -ne "$perl_filter")
echo "$LABEL $output"
}
#------------------------------------------------------------------------
case $BLOCK_BUTTON in
1|2|3) pavucontrol ;; # right click, open gui
4) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase
5) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease
esac
volume | format