deprecate unused scripts

Signed-off-by: Ferit Yiğit BALABAN <fyb@fybx.dev>
This commit is contained in:
2024-01-15 22:32:23 +03:00
parent b4565d76bb
commit 1dddc37e34
12 changed files with 22 additions and 0 deletions

24
deprecated/cdd.bash Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#
# Ferit Yiğit BALABAN, <fybalaban@fybx.dev>
#
# cd on steroids for Johnny.Decimal directories
# Define the cdd function
cdd() {
local input="$1"
local folder="$(basename "$PWD")"
if [[ "$input" =~ ^[0-9]{3}\.[0-9]{2}$ ]]; then
cd "$HOME/shoka/*/*/$input *"
elif [[ "$input" =~ ^[0-9]{3}$ ]]; then
cd "$HOME/shoka/*/$input *"
elif [[ "$input" =~ ^[0-9]{2}$ && "$folder" =~ ^[0-9]{3} ]]; then
cd "$HOME/shoka/*/*/${folder:0:3}.$input *"
else
echo "Invalid input: $input"
fi
}
# Use the cdd function with the input argument
cdd "$1"

18
deprecated/clear_html.py Normal file
View File

@@ -0,0 +1,18 @@
with open('test', 'r') as f:
l = f.readlines()
f.close()
ll = l[0].split('title="')
lt = []
for x in ll:
buffer = ''
cc = 0
while x[cc] != '"':
buffer += x[cc]
cc += 1
lt.append(buffer)
lt.remove('<div class=')
[print(x) for x in lt]
print(len(lt))

134
deprecated/fetchpy2 Executable file
View File

@@ -0,0 +1,134 @@
#!/usr/bin/env python3
#
# Ferit Yiğit BALABAN <fyb@duck.com>, 2022
#
# fetchpy, fetch script alternative to neofetch
import os
from subprocess import run
IMG_LOC = '/home/ferit/shoka/500-599 pictures/505 clipart/windowschan_s.png'
def clr(text: str):
dump = '\u001b[30m█\u001b[31m█\u001b[32m█\u001b[33m█\u001b[34m█\u001b[35m█\u001b[36m█\u001b[37m█'
frame = '\u001b[31m'
info = '\u001b[32m'
title = '\u001b[33m'
clr_dict = {
'╭': frame,
'╰': frame,
'╯': frame,
'─': frame,
'╮': frame,
'┤': frame,
'│': frame,
'├': frame,
'': info,
'': info,
'': info,
'': info,
'': info,
'󰢮': info,
'': info,
'': info,
'ferit@navi': title,
'Hardware': '',
}
iter = 0
while iter < len(text):
char = text[iter]
peekable = iter < len(text) - 1
peek = text[iter + 1] if peekable else ' '
if char == ' ':
if peekable and peek != ' ' and not clr_dict.__contains__(peek):
print(' ', end='')
word, jump_to = read_until_space(text, start_at=iter + 1)
if clr_dict.__contains__(word):
if word == 'Hardware':
print(dump, end='')
else:
print(f'{clr_dict[word]}{word}\u001b[0m', end='')
else:
print(word, end='')
iter = jump_to
print(' ', end='')
elif clr_dict.__contains__(char):
print(f'{clr_dict[char]}{char}\u001b[0m', end='')
else:
print(char, end='')
iter += 1
print('')
def read_until_space(text: str, start_at: int):
buffer = ''
iterator = start_at
while text[iterator] != ' ':
buffer += text[iterator]
iterator += 1
next_space_at = iterator
return buffer, next_space_at
def main():
padding_count = 23
distro_name = 'Arch GNU/Linux'
distro_name = distro_name.ljust(padding_count, ' ')
kernel_version = str(os.uname().release)
kernel_version = kernel_version.ljust(padding_count, ' ')
installed_packages = run(['pacman', '-Q'], text=True, capture_output=True).stdout.splitlines()
shell_name = 'fish'
for _ in installed_packages:
if shell_name in _:
shell_name = _.removesuffix('\n').ljust(padding_count, ' ')
package_count = str(len(installed_packages)).ljust(padding_count, ' ')
total_memory, used_memory, free_memory, d1, d2, d3 = map(int, os.popen('free -m').readlines()[1].split()[1:])
memory_usage = f'{round((used_memory / 1024), 1)} GB / {round((total_memory / 1024), 1)} GB'.ljust(padding_count, ' ')
with open('/proc/uptime', 'r') as f:
uptime_seconds = float(f.readline().split()[0])
f.close()
if uptime_seconds < 60:
uptime = str(uptime_seconds).split('.')[0] + ' seconds'
elif uptime_seconds < 3600:
number = str(uptime_seconds / 60).split('.')[0]
uptime = f'{number} minute' if number == '1' else f'{number} minutes'
else:
number = str(uptime_seconds / 3600).split('.')[0]
uptime = f'{number} hour' if number == '1' else f'{number} hours'
uptime = uptime.ljust(padding_count, ' ')
txt = f'''╭─────── ferit@navi ───────╮
│  {distro_name}│
│  {kernel_version}│
│  {shell_name}│
│  {package_count}│
├──────── Hardware ────────┤
│  AMD Ryzen 7 5800H │
│ 󰢮 NV GeForce RTX3050 Ti │
│  {memory_usage}│
│  {uptime}│
╰──────────────────────────╯
'''
txt_padded = ''
img_width = 16
line_count = 0
for line in txt.splitlines():
txt_padded += ((' ' * img_width) + line + '\n')
line_count += 1
print('')
run(['/usr/bin/kitty', 'icat', '--mirror', 'horizontal', '--align', 'left', IMG_LOC])
run(['printf', "\e[%sA\e[999999D", str(line_count)])
clr(txt_padded)
if __name__ == '__main__':
main()

104
deprecated/fetchpy3 Executable file
View File

@@ -0,0 +1,104 @@
#!/usr/bin/env python3
#
# Ferit Yiğit BALABAN <fybalaban@fybx.dev>, 2023
#
# fetchpy, fetch script alternative to neofetch
import os
from subprocess import run
def print_colored(text: str) -> None:
frame = '\u001b[31m'
info = '\u001b[32m'
title = '\u001b[33m'
clr_dict = {'╭': frame, '╰': frame, '╯': frame, '─': frame, '╮': frame, '│': frame,
'': info, '': info, '': info, '': info, '': info, '󰢮': info, '': info, '': info,
'ferit@navi': title,
'Hardware': ''}
i = 0
while i < len(text):
char = text[i]
peekable = i < len(text) - 1
peek = text[i + 1] if peekable else ' '
if char == ' ':
if peekable and peek != ' ' and peek not in clr_dict:
print(' ', end='')
word, jump_to = read_until_space(text, start_at=i + 1)
if word in clr_dict:
print(f'{clr_dict[word]}{word}\u001b[0m', end='')
else:
print(word, end='')
i = jump_to
print(' ', end='')
elif char in clr_dict:
print(f'{clr_dict[char]}{char}\u001b[0m', end='')
else:
print(char, end='')
i += 1
print('')
def read_until_space(text: str, start_at: int):
buffer = ''
iterator = start_at
while text[iterator] != ' ':
buffer += text[iterator]
iterator += 1
next_space_at = iterator
return buffer, next_space_at
def main():
padding_count = 23
distro_name = 'Arch GNU+Linux'
distro_name = distro_name.ljust(padding_count, ' ')
kernel_version = str(os.uname().release)
kernel_version = kernel_version.ljust(padding_count, ' ')
installed_packages = run(['pacman', '-Q'], text=True, capture_output=True).stdout.splitlines()
shell_name = 'fish'
for _ in installed_packages:
if shell_name in _:
shell_name = _.removesuffix('\n').ljust(padding_count, ' ')
package_count = str(len(installed_packages)).ljust(padding_count, ' ')
total_mem, used_mem, _, _, _, _ = map(int, os.popen('free -m').readlines()[1].split()[1:])
def rnd(x): return round(x, 1)
mem_usage = f'{rnd(used_mem / 1024)} GB / {rnd(total_mem / 1024)} GB'.ljust(padding_count, ' ')
with open('/proc/uptime', 'r', encoding='utf8') as file:
uptime_seconds = float(file.readline().split()[0])
file.close()
if uptime_seconds < 60:
uptime = str(uptime_seconds).split('.', maxsplit=1)[0] + ' seconds'
elif uptime_seconds < 3600:
number = str(uptime_seconds / 60).split('.', maxsplit=1)[0]
uptime = f'{number} minute' if number == '1' else f'{number} minutes'
else:
number = str(uptime_seconds / 3600).split('.', maxsplit=1)[0]
uptime = f'{number} hour' if number == '1' else f'{number} hours'
uptime = uptime.ljust(padding_count, ' ')
txt = \
f"""⣇⣿⠘⣿⣿⣿⡿⡿⣟⣟⢟⢟⢝⠵⡝⣿⡿⢂⣼⣿⣷⣌⠩⡫⡻⣝⠹⢿⣿⣷ ╭─────── ferit@navi ───────╮
⡆⣿⣆⠱⣝⡵⣝⢅⠙⣿⢕⢕⢕⢕⢝⣥⢒⠅⣿⣿⣿⡿⣳⣌⠪⡪⣡⢑⢝⣇ │  {distro_name}│
⡆⣿⣿⣦⠹⣳⣳⣕⢅⠈⢗⢕⢕⢕⢕⢕⢈⢆⠟⠋⠉⠁⠉⠉⠁⠈⠼⢐⢕⢽ │  {kernel_version}│
⡗⢰⣶⣶⣦⣝⢝⢕⢕⠅⡆⢕⢕⢕⢕⢕⣴⠏⣠⡶⠛⡉⡉⡛⢶⣦⡀⠐⣕⢕ │  {shell_name}│
⡝⡄⢻⢟⣿⣿⣷⣕⣕⣅⣿⣔⣕⣵⣵⣿⣿⢠⣿⢠⣮⡈⣌⠨⠅⠹⣷⡀⢱⢕ │  {package_count}│
⡝⡵⠟⠈⢀⣀⣀⡀⠉⢿⣿⣿⣿⣿⣿⣿⣿⣼⣿⢈⡋⠴⢿⡟⣡⡇⣿⡇⡀⢕ │  {mem_usage}│
⡝⠁⣠⣾⠟⡉⡉⡉⠻⣦⣻⣿⣿⣿⣿⣿⣿⣿⣿⣧⠸⣿⣦⣥⣿⡇⡿⣰⢗⢄ │  {uptime}│
⠁⢰⣿⡏⣴⣌⠈⣌⠡⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣬⣉⣉⣁⣄⢖⢕⢕⢕ ╰──────────────────────────╯
⡀⢻⣿⡇⢙⠁⠴⢿⡟⣡⡆⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣵⣵⣿
⡻⣄⣻⣿⣌⠘⢿⣷⣥⣿⠇⣿⣿⣿⣿⣿⣿⠛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣷⢄⠻⣿⣟⠿⠦⠍⠉⣡⣾⣿⣿⣿⣿⣿⣿⢸⣿⣦⠙⣿⣿⣿⣿⣿⣿⣿⣿⠟
⡕⡑⣑⣈⣻⢗⢟⢞⢝⣻⣿⣿⣿⣿⣿⣿⣿⠸⣿⠿⠃⣿⣿⣿⣿⣿⣿⡿⠁⣠
⡝⡵⡈⢟⢕⢕⢕⢕⣵⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⠿⠋⣀⣈⠙
⢿⡵⡕⡀⠑⠳⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⡠⡲⡫⡪⡪⡿"""
print_colored(txt)
if __name__ == '__main__':
main()

3
deprecated/hypr_clip Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
cliphist list | wofi --show dmenu | cliphist decode | wl-copy

23
deprecated/keyboard Executable file
View File

@@ -0,0 +1,23 @@
#$/bin/bash
code=0
let counter=1
dt=$(date +'%d/%m/%y-%H.%M.%S')
function connect() {
bluetoothctl connect F4:73:35:67:32:0A
code=$?
}
while (( counter <= 5 ))
do
connect
if [ $code -eq 0 ]; then
echo "[$dt] Connected to keyboard" >> /home/ferit/navi.log
break
else
echo "[$dt] Couldn't connect to keyboard ($counter/5)" >> /home/ferit/navi.log
fi
sleep 5
((counter++))
done
exit 0

2
deprecated/launch_polybar Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env fish
ps -C polybar >/dev/null && : || polybar --quiet --reload &; disown

24
deprecated/push_lectures.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#
# Ferit Yiğit BALABAN <f@fybx.dev>, 2022
#
# Description
# This script is used to push all changes in lecture notes folder to GitHub
steps=6
notes="$HOME/notes/001_Education"
attch="$HOME/notes/009_Attachments"
atinn="$HOME/notes/001_Education/009_Attachments"
cmssg="$( date +"%d/%m/%y-%H.%M.%S" )"
echo "[1/$steps] Copy attachments to notes Git repository"
cp -r $attch $notes
echo "[2/$steps] Switch directory to $notes"
cd $notes
echo "[3/$steps] Add all changes to staging"
git add --all .
echo "[4/$steps] Commit changes"
git commit -m $cmssg
echo "[5/$steps] Push changes to remote"
git push origin main
echo "[6/$steps] Remove attachments from notes Git repository"
rm -r $atinn

View File

@@ -0,0 +1,21 @@
import os
import git
from datetime import datetime
folder_path = "/home/ferit/shoka/400-499 vault"
if not os.path.exists(os.path.join(folder_path, ".git")):
repo = git.Repo.init(folder_path)
else:
repo = git.Repo(folder_path)
os.chdir(folder_path)
repo.remotes.origin.pull()
repo.index.add("*")
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
repo.index.commit(f"{timestamp} ewdows usual")
repo.remote("origin").push()

60
deprecated/rnm Executable file
View File

@@ -0,0 +1,60 @@
#!/usr/bin/env python3
#
# Ferit Yiğit BALABAN <fyb@duck.com>, 2022
#
import os
def f_c(l: list[str], p: int, n: int, i: str):
r = []
if p == 0:
r = [i + x[n:] for x in l]
elif p > 0:
r = [x[:n + 1] + i for x in l]
return r
def f_r(l: list[str], p: str, i: str):
r = [x.replace(p, i) for x in l]
return r
def main():
d = os.getcwd()
f = []
r = []
m = 0
f = os.listdir(d)
while True:
q = input('# ').strip()
e = q.split(' ')
m = 1 if e[0] == 'sr' else 0
if e[0] == 'fn' and e[1].isnumeric():
r = f_c(*(f, 0, int(e[1]), '') if m == 0 else (f, 0, int(e[1]), e[2]))
elif e[0] == 'ln' and e[1].isnumeric():
r = f_c(*(f, 1, int(e[1]), '') if m == 0 else (f, 1, int(e[1]), e[2]))
elif e[0] == 'em':
r = f_r(*(f, e[1], '') if m == 0 else (f, e[1], e[2]))
elif e[0] == 'pd':
print(d)
elif e[0] == 'cd':
os.chdir(e[1])
f = os.listdir(d)
elif e[0] == 'lf':
print(*f, sep='\n')
elif e[0] == 'lr':
print(*r, sep='\n')
elif e[0] == 'rf' and e[1].isalnum() and e[1] in f:
f.remove(e[1])
elif e[0] == 'rr' and e[1].isalnum() and e[1] in r:
r.remove(e[1])
elif e[0] == 'ex' or e[0] == 'qq':
break
[print(f'{f[c]} => {r[c]}') if f[c] != r[c] else False for c in range(0, len(f))]
if input('# ?').lower() == 'y':
[os.rename(f[c], r[c]) if f[c] != r[c] else False for c in range(0, len(f))]
if __name__ == '__main__':
main()

231
deprecated/source_polybar.py Executable file
View File

@@ -0,0 +1,231 @@
#!/usr/bin/env python3
import os.path
import subprocess
import sys
def main():
primary_color = '#c38ccf'
prc_frmstring = f'F{primary_color}'
prc_fwrappers = f'{{{prc_frmstring}}}'
backg_colour = '#0f0f14'
backg_clralt = '#0f0f14'
foreg_colour = '#FFEBFF'
interface_wlan = 'wlp3s0'
interface_ethr = 'enp2s0'
config_text = f"""[colors]
background = {backg_colour}
background-alt = {backg_clralt}
foreground = {foreg_colour}
primary = {primary_color}
secondary = ${{colors.primary}}
alert = #A54242
disabled = #707880
[bar/example]
width = 100%
height = 2.5%
radius = 0
font-0 = "JetBrainsMono Nerd Font:pixelsize=12;2"
font-1 = "IPAGothic:pixelsize=13;2"
background = ${{colors.background}}
foreground = ${{colors.foreground}}
line-size = 0
border-size = 0
border-color = ${{colors.primary}}
padding-left = 0
padding-right = 1
module-margin = 1
;separator = |
separator-foreground = ${{colors.disabled}}
modules-left = arch xworkspaces xwindow
modules-center = date
modules-right = aud bat mem cpu temp wlan eth music
cursor-click = pointer
enable-ipc = true
[module/music]
type = custom/script
exec = /home/ferit/scripts/nowplaying
tail = false
interval = 2
click-left = playerctl play-pause
click-right = playerctl stop
double-click-left = playerctl next
double-click-right = playerctl previous
scroll-up = playerctl position 5+
scroll-down = playerctl position 5-
format-prefix = ""
format-prefix-foreground = {primary_color}
format = <label>
[module/arch]
type = custom/text
content = ""
content-foreground = {primary_color}
[module/xworkspaces]
type = internal/xworkspaces
label-active = 
label-active-foreground = ${{colors.primary}}
label-active-background = ${{colors.background-alt}}
label-active-underline= ${{colors.primary}}
label-active-padding = 1
label-occupied = 
label-occupied-padding = 1
label-urgent = ●
label-urgent-background = ${{colors.alert}}
label-urgent-padding = 1
label-empty = ●
label-empty-foreground = ${{colors.disabled}}
label-empty-padding = 1
[module/xwindow]
type = internal/xwindow
label = %title:0:30:…%
[module/aud]
type = internal/pulseaudio
format-volume-prefix = ""
format-volume-prefix-foreground = ${{colors.primary}}
format-volume = <label-volume>
label-volume = %percentage%%
label-muted = 
label-muted-foreground = ${{colors.disabled}}
[module/bat]
type = internal/battery
full-at = 100
battery = BAT0
adapter = ADP0
poll-interval = 60
ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-3 = 
ramp-capacity-4 = 
ramp-capacity-5 = 
ramp-capacity-6 = 
ramp-capacity-7 = 
ramp-capacity-8 = 
animation-charging-0 = 
animation-charging-1 = 
animation-charging-2 = 
animation-charging-3 = 
animation-charging-4 = 
animation-charging-5 = 
animation-charging-6 = 
animation-charging-framerate = 750
format-charging = %{prc_fwrappers}<animation-charging>%{{F-}} <label-charging>
format-discharging = %{prc_fwrappers}<ramp-capacity>%{{F-}} <label-discharging>
format-full = %{prc_fwrappers}%{{F-}}
;format-full = %{prc_fwrappers}%{{F-}} <label-full>
label-full = %percentage%%
label-charging = %percentage%%
label-discharging = %percentage%%
[module/mem]
type = internal/memory
interval = 2
format-prefix = ""
format-prefix-foreground = ${{colors.primary}}
label = %percentage_used%%
[module/cpu]
type = internal/cpu
interval = 2
format-prefix = ""
format-prefix-foreground = ${{colors.primary}}
label = %percentage%%
[module/temp]
type = internal/temperature
interval = 10
thermal-zone = 0
hwmon-path = /sys/class/hwmon/hwmon1/temp1_input
format-prefix = ""
format-prefix-foreground = ${{colors.primary}}
label = %temperature-c%
[module/wlan]
type = internal/network
interval = 5
interface = {interface_wlan}
label-connected = %essid%
label-disconnected =
format-connected = %{prc_fwrappers}直%{{F-}} <label-connected>
;format-disconnected = %{prc_fwrappers}睊%{{F-}} <label-disconnected>
[module/eth]
type = internal/network
interval = 5
interface = {interface_ethr}
label-connected = UP
label-disconnected =
format-connected = %{prc_fwrappers}%{{F-}} <label-connected>
format-disconnected = <label-disconnected>
[module/date]
type = internal/date
interval = 60
date = %H.%M
date-alt = %d/%m/%y
label = %date%
label-foreground = ${{colors.primary}}
[settings]
screenchange-reload = true
pseudo-transparency = true"""
if 'source_polybar.py' in sys.argv:
sys.argv.remove('source_polybar.py')
sys.argv.reverse()
location = ''
lct_home = os.environ.get('HOME')
flag_print = False
flag_locset = False
flag_deploy = False
flag_restrt = False
# flag_print: -p or --print
# flag_locset: -l or --location followed by valid path to file or directory
# flag_deploy: -d or --deploy
while len(sys.argv) != 0:
item = sys.argv.pop()
flag_print = item == '-p' or item == '--print' or flag_print
flag_deploy = item == '-d' or item == '--deploy' or flag_deploy
flag_restrt = item == '-r' or item == '--restart' or flag_restrt
if item == '-l' or item == '--location':
if len(sys.argv) > 0:
_ = sys.argv.pop()
if os.path.isdir(_) and os.path.isfile(_) is False:
flag_locset = True
location = _
if flag_print:
print(config_text)
if flag_deploy:
with open(lct_home + '/.config/polybar/config.ini', 'w') as file:
file.write(config_text)
print('deployed config')
if flag_restrt:
process = subprocess.Popen(['sh', 'launch_polybar.sh'])
_ = process.communicate()[0]
print('restarted polybar')
if flag_locset:
with open(location, 'w') as file:
file.write(config_text)
print(f'saved config to {location}/config.ini')
main()

77
deprecated/wal_to_chromium.sh Executable file
View File

@@ -0,0 +1,77 @@
#!/bin/bash
#
# Apply pywal-generated color palette to Chromium
# code from https://github.com/metafates/ChromiumPywal
#
. ~/.cache/wal/colors.sh # import colors from pywal
THEME_NAME="Pywal"
DIR=$(dirname "${BASH_SOURCE[0]}")
THEME_DIR="$DIR/$THEME_NAME"
# Converts hex colors into rgb joined with comma
# #fff -> 255, 255, 255
hexToRgb() {
# Remove '#' character from hex color #fff -> fff
plain=${1#*#}
printf "%d, %d, %d" 0x${plain:0:2} 0x${plain:2:2} 0x${plain:4:2}
}
prepare() {
if [ -d $THEME_DIR ]; then
rm -rf $THEME_DIR
fi
mkdir $THEME_DIR
mkdir "$THEME_DIR/images"
# Copy wallpaper so it can be used in theme
background_image="images/theme_ntp_background_norepeat.png"
cp "$wallpaper" "$THEME_DIR/$background_image"
}
background=$(hexToRgb $background)
foreground=$(hexToRgb $foreground)
accent=$(hexToRgb $color11)
secondary=$(hexToRgb $color8)
generate() {
# Theme template
cat > "$THEME_DIR/manifest.json" << EOF
{
"manifest_version": 3,
"version": "1.0",
"name": "$THEME_NAME Theme",
"theme": {
"images": {
"theme_ntp_background" : "$background_image"
},
"colors": {
"frame": [$background],
"frame_inactive": [$background],
"toolbar": [$accent],
"ntp_text": [$foreground],
"ntp_link": [$accent],
"ntp_section": [$secondary],
"button_background": [$foreground],
"toolbar_button_icon": [$foreground],
"toolbar_text": [$foreground],
"omnibox_background": [$background],
"omnibox_text": [$foreground]
},
"properties": {
"ntp_background_alignment": "bottom"
}
}
}
EOF
}
prepare
generate
echo "Pywal Chrome theme generated at $THEME_DIR"