Add files via upload

This commit is contained in:
2025-11-24 19:46:30 +07:00
parent 90cc6d4253
commit a7ab7103a5
365 changed files with 17881 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
#!/bin/sh
#kitty --hold -e cal -y -m
kitty --hold -e calcurse

71
config/polybar/scripts/cava Executable file
View File

@@ -0,0 +1,71 @@
#!/bin/env python3
import argparse
import os
import signal
import subprocess
import sys
import tempfile
if len(sys.argv) > 1 and sys.argv[1] == '--subproc':
ramp_list = ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█']
colors = ['001F00','003F00','005F00','007F00','009F00','00BF00','00DF00','00FF00']
while True:
cava_input = input().strip().split()
cava_input = [int(i) for i in cava_input]
output = ''
for bar in cava_input:
if bar < len(ramp_list):
output += "%{F#"+colors[bar]+"}"+ramp_list[bar] + "%{F-}"
else:
output += "%{F#"+colors[-1]+"}"+ramp_list[-1] + "%{F-}"
print(output)
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--framerate', type=int, default=60,
help='Framerate to be used by cava, default is 60')
parser.add_argument('-b', '--bars', type=int, default=8,
help='Amount of bars, default is 8')
parser.add_argument('-e', '--extra_colors', default='fdd,fcc,fbb,faa',
help='Color gradient used on higher values, separated by commas, default is')
parser.add_argument('-c', '--channels', choices=['stereo', 'left', 'right', 'average'],
help='Audio channels to be used, defaults to stereo')
opts = parser.parse_args()
conf_channels = ''
if opts.channels != 'stereo':
conf_channels = (
'channels=mono\n'
f'mono_option={opts.channels}'
)
conf_ascii_max_range = 12 + len([i for i in opts.extra_colors.split(',') if i])
cava_conf = tempfile.mkstemp('','polybar-cava-conf.')[1]
with open(cava_conf, 'w') as cava_conf_file:
cava_conf_file.write(
'[general]\n'
f'framerate={opts.framerate}\n'
f'bars={opts.bars}\n'
'[output]\n'
'method=raw\n'
'data_format=ascii\n'
f'ascii_max_range={conf_ascii_max_range}\n'
'bar_delimiter=32\n'
+ conf_channels
)
cava_proc = subprocess.Popen(['cava', '-p', cava_conf], stdout=subprocess.PIPE)
self_proc = subprocess.Popen(['python3', __file__, '--subproc', opts.extra_colors], stdin=cava_proc.stdout)
def cleanup(sig, frame):
os.remove(cava_conf)
cava_proc.kill()
self_proc.kill()
sys.exit(0)
signal.signal(signal.SIGTERM, cleanup)
signal.signal(signal.SIGINT, cleanup)
self_proc.wait()

29
config/polybar/scripts/cava.sh Executable file
View File

@@ -0,0 +1,29 @@
#! /bin/bash
bar="▁▂▃▄▅▆▇█"
dict="s/;//g;"
# creating "dictionary" to replace char with bar
i=0
while [ $i -lt ${#bar} ]; do
dict="${dict}s/$i/${bar:$i:1}/g;"
i=$((i = i + 1))
done
# write cava config
config_file="/tmp/polybar_cava_config"
echo "
[general]
bars = 10
[output]
method = raw
raw_target = /dev/stdout
data_format = ascii
ascii_max_range = 7
" >$config_file
# read stdout from cava
cava -p $config_file | while read -r line; do
echo $line | sed $dict
done

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
updates=$(sysupdate)
if [ -z "$updates" ]; then
count=0
else
printf '%s\n' "$updates" >/tmp/bspwm-polybar-updates
count=$(wc -l "/tmp/bspwm-polybar-updates" | awk '{print $1}')
fi
echo "%{T1}%{T-} %{T2}$count %{T-}"

55
config/polybar/scripts/cns.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/bin/bash
function capslock() {
caps=$(xset -q | grep Caps | awk '{ print $4 }')
if [ $caps == 'off' ]; then
echo "%{T1}%{T-}"
else
echo "%{T1}בּ%{T-}"
fi
}
function numlock {
num=$(xset -q | grep Num | awk '{ print $8 }')
if [ $num == 'off' ]; then
echo "%{T1}%{T-}"
else
echo "%{T1}%{T-}"
fi
}
function scroll() {
scroll=$(xset -q | grep Scroll | awk '{ print $12 }')
if [ $scroll == 'off' ]; then
echo "%{T1}%{T-}"
else
echo "%{T1}%{T-}"
fi
}
main () {
if [ "$1" == "-c" ]; then
capslock
fi
if [ "$1" == "-n" ]; then
numlock
fi
if [ "$1" == "-s" ]; then
scroll
fi
}
main $1

View File

@@ -0,0 +1,23 @@
#!/bin/sh
case $BLOCK_BUTTON in
1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;;
3) notify-send " Internet module" "\- Click to connect
❌: wifi disabled
📡: no wifi connection
📶: wifi connection with quality
❎: no ethernet
🌐: ethernet working
🔒: vpn is active
" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then
wifiicon="$(awk '/^\s*w/ { print "", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then
grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon="📡 " || wifiicon="❌ "
fi
printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/;s/up/" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/" /sys/class/net/tun*/operstate 2>/dev/null)"

View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
WIN_CLASS="nvim_notes"
#ICON="  "
ICON="  "
# найти node id
find_node() {
for id in $(bspc query -N -n .window 2>/dev/null); do
if xprop -id "$id" WM_CLASS 2>/dev/null | grep -q "$WIN_CLASS"; then
echo "$id" && return 0
fi
done
return 1
}
NODE=$(find_node) || NODE=""
if [ -z "$NODE" ]; then
echo "$ICON"
exit 0
fi
# проверить флаг hidden через JSON (надежно)
if bspc query -T -n "$NODE" 2>/dev/null | grep -q '"hidden":[[:space:]]*true'; then
echo "%{T1}$ICON%{T-}%{T2}Скрыто%{T-} "
exit 0
fi
# если в фокусе — видно
FOC=$(bspc query -N -n focused.window 2>/dev/null || echo "")
if [ "$NODE" = "$FOC" ]; then
echo "%{T1}$ICON%{T-}%{T2}Фокус%{T-} "
exit 0
fi
# получить список окон текущего десктопа и проверить наличие
CUR_DESK_WINDOWS=$(bspc query -N -n .window.local 2>/dev/null || bspc query -N -n .window 2>/dev/null)
if echo "$CUR_DESK_WINDOWS" | grep -qx "$NODE"; then
echo "%{T1}$ICON%{T-}%{T2}ON%{T-} "
else
echo "%{T1}$ICON%{T-}%{T2}ON%{T-} "
fi

View File

@@ -0,0 +1,303 @@
#!/bin/bash
# __ _ _ _ _ _ _
# _ __ ___ / _(_) | |__ | |_ _ ___| |_ ___ ___ | |_| |__
# | '__/ _ \| |_| |_____| '_ \| | | | |/ _ \ __/ _ \ / _ \| __| '_ \
# | | | (_) | _| |_____| |_) | | |_| | __/ || (_) | (_) | |_| | | |
# |_| \___/|_| |_| |_.__/|_|\__,_|\___|\__\___/ \___/ \__|_| |_|
#
# Author: Nick Clyde (clydedroid)
#
# A script that generates a rofi menu that uses bluetoothctl to
# connect to bluetooth devices and display status info.
#
# Inspired by networkmanager-dmenu (https://github.com/firecat53/networkmanager-dmenu)
# Thanks to x70b1 (https://github.com/polybar/polybar-scripts/tree/master/polybar-scripts/system-bluetooth-bluetoothctl)
#
# Depends on:
# Arch repositories: rofi, bluez-utils (contains bluetoothctl)
# Checks if bluetooth controller is powered on
power_on() {
if bluetoothctl show | grep -q "Powered: yes"; then
return 0
else
return 1
fi
}
# Toggles power state
toggle_power() {
if power_on; then
bluetoothctl power off
else
bluetoothctl power on
fi
}
# Checks if controller is scanning for new devices
scan_on() {
if bluetoothctl show | grep -q "Discovering: yes"; then
echo "Scan: on"
return 0
else
echo "Scan: off"
return 1
fi
}
# Toggles scanning state
toggle_scan() {
if scan_on; then
kill $(pgrep -f "bluetoothctl scan on")
bluetoothctl scan off
else
bluetoothctl scan on &
fi
}
# Checks if controller is able to pair to devices
pairable_on() {
if bluetoothctl show | grep -q "Pairable: yes"; then
echo "Pairable: on"
return 0
else
echo "Pairable: off"
return 1
fi
}
# Toggles pairable state
toggle_pairable() {
if pairable_on; then
bluetoothctl pairable off
else
bluetoothctl pairable on
fi
}
# Checks if controller is discoverable by other devices
discoverable_on() {
if bluetoothctl show | grep -q "Discoverable: yes"; then
echo "Discoverable: on"
return 0
else
echo "Discoverable: off"
return 1
fi
}
# Toggles discoverable state
toggle_discoverable() {
if discoverable_on; then
bluetoothctl discoverable off
else
bluetoothctl discoverable on
fi
}
# Checks if a device is connected
device_connected() {
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Connected: yes"; then
return 0
else
return 1
fi
}
# Toggles device connection
toggle_connection() {
if device_connected $1; then
bluetoothctl disconnect $1
else
bluetoothctl connect $1
fi
}
# Checks if a device is paired
device_paired() {
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Paired: yes"; then
echo "Paired: yes"
return 0
else
echo "Paired: no"
return 1
fi
}
# Toggles device paired state
toggle_paired() {
if device_paired $1; then
bluetoothctl remove $1
else
bluetoothctl pair $1
fi
}
# Checks if a device is trusted
device_trusted() {
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Trusted: yes"; then
echo "Trusted: yes"
return 0
else
echo "Trusted: no"
return 1
fi
}
# Toggles device connection
toggle_trust() {
if device_trusted $1; then
bluetoothctl untrust $1
else
bluetoothctl trust $1
fi
}
# Prints a short string with the current bluetooth status
# Useful for status bars like polybar, etc.
print_status() {
if power_on; then
printf ''
mapfile -t paired_devices < <(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
counter=0
for device in "${paired_devices[@]}"; do
if device_connected $device; then
device_alias=$(bluetoothctl info $device | grep "Alias" | cut -d ' ' -f 2-)
if [ $counter -gt 0 ]; then
printf ", %s" "$device_alias"
else
printf " %s" "$device_alias"
fi
((counter++))
fi
done
if [ $counter -eq 0 ]; then
printf " On"
fi
else
echo " off"
fi
}
# A submenu for a specific device that allows connecting, pairing, and trusting
device_menu() {
device=$1
# Get device name and mac address
device_name=$(echo $device | cut -d ' ' -f 3-)
mac=$(echo $device | cut -d ' ' -f 2)
# Build options
if device_connected $mac; then
connected="Connected: yes"
else
connected="Connected: no"
fi
paired=$(device_paired $mac)
trusted=$(device_trusted $mac)
options="$connected\n$paired\n$trusted"
# Open rofi menu, read chosen option
chosen="$(echo -e "$options" | $rofi_command "$device_name")"
# Match chosen option to command
case $chosen in
"")
echo "No option chosen."
;;
$connected)
toggle_connection $mac
sleep 0.5
show_menu
;;
$paired)
toggle_paired $mac
sleep 0.5
show_menu
;;
$trusted)
toggle_trust $mac
sleep 0.5
show_menu
;;
esac
}
# Opens a rofi menu with current bluetooth status and options to connect
show_menu() {
# Get menu options
if power_on; then
power="Power: on"
# Human-readable names of devices, one per line
# If scan is off, will only list paired devices
devices=$(bluetoothctl devices | grep Device | cut -d ' ' -f 3-)
# Get controller flags
scan=$(scan_on)
pairable=$(pairable_on)
discoverable=$(discoverable_on)
divider="---------"
# Options passed to rofi
options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable"
else
power="Power: off"
options="$power"
fi
# Open rofi menu, read chosen option
chosen="$(echo -e "$options" | $rofi_command "Bluetooth")"
# Match chosen option to command
case $chosen in
"" | $divider)
echo "No option chosen."
;;
$power)
toggle_power
sleep 0.5
show_menu
;;
$scan)
toggle_scan
sleep 0.5
show_menu
;;
$discoverable)
toggle_discoverable
sleep 0.5
show_menu
;;
$pairable)
toggle_pairable
sleep 0.5
show_menu
;;
*)
device=$(bluetoothctl devices | grep "$chosen")
# Open a submenu if a device is selected
if [[ $device ]]; then device_menu "$device"; fi
;;
esac
}
# Rofi command to pipe into, can add any options here
rofi_command="rofi -dmenu -no-fixed-num-lines -yoffset -100 -i -p"
case "$1" in
--status)
print_status
;;
*)
show_menu
;;
esac

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
STATEFILE="/tmp/stop-screensaver.state"
LABEL="stop-scr"
ICON_ON=""
ICON_OFF=""
if [ -f "$STATEFILE" ]; then
state=$(cat "$STATEFILE")
else
state=""
fi
# fallback проверка процесса, если statefile отсутствует/неактуален
if pgrep -f "/usr/local/bin/stop-screensaver.sh" >/dev/null; then
state="running"
fi
if [ "$state" = "running" ]; then
echo " $ICON_ON "
else
echo " $ICON_OFF "
fi

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
SCRIPT="/usr/local/bin/stop-screensaver.sh"
STATEFILE="/tmp/stop-screensaver.state"
if pgrep -f "$SCRIPT" >/dev/null; then
pkill -f "$SCRIPT"
else
nohup "$SCRIPT" >/dev/null 2>&1 &
fi
# записать текущее состояние
if pgrep -f "$SCRIPT" >/dev/null; then
echo "running" >"$STATEFILE"
else
echo "stopped" >"$STATEFILE"
fi

View File

@@ -0,0 +1,24 @@
#!/bin/sh
if ! updates_arch=$(checkupdates 2>/dev/null | wc -l); then
updates_arch=0
fi
if ! updates_aur=$(yay -Qum 2>/dev/null | wc -l); then
# if ! updates_aur=$(paru -Qum 2> /dev/null | wc -l); then
# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then
# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then
#if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then
# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then
updates_aur=0
fi
updates=$((updates_arch + updates_aur))
#if [ "$updates" -gt 0 ]; then
# echo "# $updates"
#else
# echo ""
#fi
#notify-send -i /home/$USER/.config/dunst/scripts/archlinux.svg "Доступно $updates обновлений"
echo "%{T1}%{T-} %{T2}$updates%{T-}"

View File

@@ -0,0 +1,10 @@
#!/bin/sh
#connection=$(pgrep -a openvpn$ | head -n 1 | awk '{print $NF }' | cut -d '.' -f 1)
connection=$(pgrep -a wg0 | head -n 1 | awk '{print $NF }' | cut -d '.' -f 1)
if [ -n "$connection" ]; then
echo "%{F#FFDE7D}%{T1}%{T-} %{T2}VPN: ON%{T-}"
else
echo "%{F#5f5f5f}%{T1}%{T-} %{T2}VPN: OFF%{T-}"
fi

View File

@@ -0,0 +1,54 @@
#! /bin/bash
connected_interface=$(awg show interfaces | grep -P "awg\d+" -o)
connect() {
# doas wg-quick up wg0 && doas route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.1 enp5s0 && notify-send -i /home/$USER/.config/dunst/scripts/vpn.png 'VPN connected'
doas awg-quick up awg0 && sleep 3 && doas route add -host 178.49.132.41 gw 192.168.1.1 enp5s0 && doas systemctl restart dnsproxy.service && notify-send -i /home/$USER/.config/dunst/scripts/vpn.png 'VPN connected'
# sudo wg-quick up wg0 && sudo route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.1 enp9s0 && notify-send -i /home/$USER/.config/dunst/scripts/vpn.png 'VPN connected'
# sudo wg-quick up wg0 && sudo route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.1 enp9s0 && sudo route add -host 78.47.125.180 gw 192.168.1.1 enp9s0 && notify-send -i /home/$USER/.config/dunst/scripts/vpn.png 'VPN connected'
}
disconnect() {
# Normally we should have a single connected interface but technically
# there's nothing stopping us from having multiple active intgerfaces so
# let's do this in a loop:
for connected_config in $(awg show interfaces | grep -P "awg\d+" -o); do
doas awg-quick down awg0 && notify-send -i /home/$USER/.config/dunst/scripts/vpn.png 'VPN disconnected'
done
}
toggle() {
if [[ $connected_interface ]]; then
disconnect
else
connect
fi
}
print() {
if [[ $connected_interface ]]; then
echo "%{T1}說%{T-} %{T2}VPN: ON%{T-}"
#echo "%{F#FFDE7D}%{T1}說%{T-} %{T2}VPN: ON%{T-}"
else
echo "%{T1}說%{T-} %{T2}VPN: OFF%{T-}"
#echo "%{F#5f5f5f}%{T1}說%{T-} %{T2}VPN: OFF%{T-}"
fi
}
case "$1" in
--connect)
connect
;;
--disconnect)
disconnect
;;
--toggle)
toggle
;;
*)
print
;;
esac