feat(scripts): Removed Scripts which I don't use.
This commit is contained in:
1 parent
72b6efc817
commit
a05fbd8b2d
8 files changed
+303
-361
No files matched your search
+82
-200
@@ -6,23 +6,12 @@ CONFIG_FILE=~/.config/hypr/scripts/Ref.sh
|
||||
source "$CONFIG_FILE"
|
||||
|
||||
|
||||
# Todo List (SHIFT ALT T)
|
||||
todo() {
|
||||
while cmd=$(rofi -dmenu -p "$prompt" -lines "$height" "$@" < "$file"); [ -n "$cmd" ]; do
|
||||
if grep -q "^$cmd\$" "$file"; then
|
||||
grep -v "^$cmd\$" "$file" > "$file.$$"
|
||||
mv "$file.$$" "$file"
|
||||
((height--))
|
||||
else
|
||||
echo "$cmd" >> "$file"
|
||||
((height++))
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
}
|
||||
######################################
|
||||
# #
|
||||
# Calculator #
|
||||
# #
|
||||
######################################
|
||||
|
||||
|
||||
# Function For Calculator (ALT C)
|
||||
calc() {
|
||||
roficmd="rofi -dmenu -p Calc $@"
|
||||
|
||||
@@ -37,8 +26,12 @@ calc() {
|
||||
done
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Tmux Session #
|
||||
# #
|
||||
######################################
|
||||
|
||||
# Funtion for Tmux Sessions (ALT t)
|
||||
tmux(){
|
||||
tmux_sessions() {
|
||||
tmux list-sessions | sed 's/: /| /' | column -t -s'|' -o' | '
|
||||
@@ -74,96 +67,12 @@ main() {
|
||||
main
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Clipboard Manager #
|
||||
# #
|
||||
######################################
|
||||
|
||||
# Take note (ALT B)
|
||||
note() {
|
||||
if [[ ! -d "${NOTES_FOLDER}" ]]; then
|
||||
mkdir -p "$NOTES_FOLDER"
|
||||
fi
|
||||
get_notes() {
|
||||
ls "${NOTES_FOLDER}"
|
||||
}
|
||||
edit_note() {
|
||||
note_location=$1
|
||||
$NOTES_EDITOR "$note_location"
|
||||
}
|
||||
delete_note() {
|
||||
local note=$1
|
||||
local action=$(echo -e "Yes\nNo" | rofi -dmenu -p "Are you sure you want to delete $note? ")
|
||||
case $action in
|
||||
"Yes")
|
||||
rm "$NOTES_FOLDER/$note"
|
||||
main
|
||||
;;
|
||||
"No")
|
||||
main
|
||||
esac
|
||||
}
|
||||
note_context() {
|
||||
local note=$1
|
||||
local note_location="$NOTES_FOLDER/$note"
|
||||
local action=$(echo -e "Edit\nDelete" | rofi -dmenu -p "$note > ")
|
||||
case $action in
|
||||
"Edit")
|
||||
edit_note "$note_location"
|
||||
exit 0;;
|
||||
"Delete")
|
||||
delete_note "$note"
|
||||
exit 0;;
|
||||
esac
|
||||
exit 1
|
||||
}
|
||||
new_note() {
|
||||
local title=$(echo -e "Cancel" | rofi -dmenu -p "Input title: ")
|
||||
|
||||
case "$title" in
|
||||
"Cancel")
|
||||
main
|
||||
;;
|
||||
*)
|
||||
local file=$(echo "$title" | sed 's/ /_/g;s/\(.*\)/\L\1/g')
|
||||
local template=$(cat <<- END
|
||||
---
|
||||
title: $title
|
||||
date: $(date --rfc-3339=seconds)
|
||||
author: $AUTHOR
|
||||
---
|
||||
|
||||
# $title
|
||||
END
|
||||
)
|
||||
note_location="$NOTES_FOLDER/$file.md"
|
||||
if [ "$title" != "" ]; then
|
||||
echo "$template" > "$note_location" | edit_note "$note_location"
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
main()
|
||||
{
|
||||
local all_notes="$(get_notes)"
|
||||
local first_menu="New"
|
||||
if [ "$all_notes" ];then
|
||||
first_menu="New\n${all_notes}"
|
||||
fi
|
||||
local note=$(echo -e "$first_menu" | rofi -dmenu -p " Notes")
|
||||
case $note in
|
||||
"New")
|
||||
new_note
|
||||
;;
|
||||
"")
|
||||
exit 1;;
|
||||
*)
|
||||
note_context "$note" && exit 0 # handle esc key in note_context
|
||||
esac
|
||||
exit 1
|
||||
}
|
||||
main
|
||||
}
|
||||
|
||||
|
||||
# Clipboard Manager. This script uses cliphist, rofi, and wl-copy. (SHIFT ALT C)
|
||||
clip() {
|
||||
while true; do
|
||||
result=$(rofi -dmenu -kb-custom-1 "Control-Delete" -kb-custom-2 "Alt-Delete" -p "CTRL Del - Cliphist del || Alt Del - cliphist wipe" -config ~/.config/rofi/config-long.rasi < <(cliphist list))
|
||||
@@ -178,7 +87,12 @@ clip() {
|
||||
}
|
||||
|
||||
|
||||
# Rofi menu for Quick Edit / View of Settings (SUPER E)
|
||||
######################################
|
||||
# #
|
||||
# Quick Edit #
|
||||
# #
|
||||
######################################
|
||||
|
||||
edit() {
|
||||
menu() {
|
||||
options=("Env-variables" "Window-Rules" "Startup_Apps" "User-Keybinds" "Monitors" "Laptop-Keybinds" "User-Settings" "Default-Settings" "Default-Keybinds")
|
||||
@@ -195,7 +109,12 @@ edit() {
|
||||
}
|
||||
|
||||
|
||||
# Powermenu (SUPER X)
|
||||
######################################
|
||||
# #
|
||||
# Powermenu #
|
||||
# #
|
||||
######################################
|
||||
|
||||
powermenu() {
|
||||
uptime_info=$(uptime -p | sed -e 's/up //g')
|
||||
host=$(hostnamectl hostname)
|
||||
@@ -223,35 +142,48 @@ powermenu() {
|
||||
esac
|
||||
}
|
||||
|
||||
# Keybinds (SUPER F1 )
|
||||
######################################
|
||||
# #
|
||||
# Keybinds #
|
||||
# #
|
||||
######################################
|
||||
|
||||
keybind() {
|
||||
CONFIG=$(rofi -show file-browser-extended -file-browser-stdout -file-browser-dir "$HOME"/.config/keyb/bindings -config ~/.config/rofi/config-long.rasi)
|
||||
|
||||
hyprctl dispatch exec "[float;size 45% 80%;center 1] kitty keyb -k '$CONFIG'"
|
||||
}
|
||||
|
||||
# Emoji (ALT SLASH)
|
||||
######################################
|
||||
# #
|
||||
# Emoji #
|
||||
# #
|
||||
######################################
|
||||
|
||||
emoji() {
|
||||
A="$(rofi -dmenu -p "Emoji:" -config ~/.config/rofi/config-long.rasi < "$HOME/.config/hypr/configs/emojis" | cut -d ' ' -f 1 | tr -d '\n')"
|
||||
[[ -n "$A" ]] && wl-copy -- "$A"
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Bluetooth #
|
||||
# #
|
||||
######################################
|
||||
|
||||
bluetooth(){
|
||||
divider="—————————————————————————————————————————————————————————"
|
||||
goback=" Back"
|
||||
theme=~/.config/rofi/config-long.rasi
|
||||
|
||||
# Checks if bluetooth controller is powered on
|
||||
power_on() {
|
||||
power_on() { # Checks if bluetooth controller is powered on
|
||||
if bluetoothctl show | grep -q "Powered: yes"; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Toggles power state
|
||||
toggle_power() {
|
||||
toggle_power() { # Toggles power state
|
||||
if power_on; then
|
||||
bluetoothctl power off
|
||||
show_menu
|
||||
@@ -263,9 +195,7 @@ toggle_power() {
|
||||
show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if controller is scanning for new devices
|
||||
scan_on() {
|
||||
scan_on() { # Checks if controller is scanning for new devices
|
||||
if bluetoothctl show | grep -q "Discovering: yes"; then
|
||||
echo " Scan: ON"
|
||||
return 0
|
||||
@@ -274,9 +204,7 @@ scan_on() {
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Toggles scanning state
|
||||
toggle_scan() {
|
||||
toggle_scan() { # Toggles scanning state
|
||||
if scan_on; then
|
||||
kill $(pgrep -f "bluetoothctl scan on")
|
||||
bluetoothctl scan off
|
||||
@@ -288,9 +216,7 @@ toggle_scan() {
|
||||
show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if controller is able to pair to devices
|
||||
pairable_on() {
|
||||
pairable_on() { # Checks if controller is able to pair to devices
|
||||
if bluetoothctl show | grep -q "Pairable: yes"; then
|
||||
echo " Pairable: ON"
|
||||
return 0
|
||||
@@ -299,9 +225,7 @@ pairable_on() {
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Toggles pairable state
|
||||
toggle_pairable() {
|
||||
toggle_pairable() { # Toggles pairable state
|
||||
if pairable_on; then
|
||||
bluetoothctl pairable off
|
||||
show_menu
|
||||
@@ -310,9 +234,7 @@ toggle_pairable() {
|
||||
show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if controller is discoverable by other devices
|
||||
discoverable_on() {
|
||||
discoverable_on() { # Checks if controller is discoverable by other devices
|
||||
if bluetoothctl show | grep -q "Discoverable: yes"; then
|
||||
echo " Discoverable: ON"
|
||||
return 0
|
||||
@@ -321,9 +243,7 @@ discoverable_on() {
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Toggles discoverable state
|
||||
toggle_discoverable() {
|
||||
toggle_discoverable() { # Toggles discoverable state
|
||||
if discoverable_on; then
|
||||
bluetoothctl discoverable off
|
||||
show_menu
|
||||
@@ -332,9 +252,7 @@ toggle_discoverable() {
|
||||
show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if a device is connected
|
||||
device_connected() {
|
||||
device_connected() { # Checks if a device is connected
|
||||
device_info=$(bluetoothctl info "$1")
|
||||
if echo "$device_info" | grep -q "Connected: yes"; then
|
||||
return 0
|
||||
@@ -342,9 +260,7 @@ device_connected() {
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Toggles device connection
|
||||
toggle_connection() {
|
||||
toggle_connection() { # Toggles device connection
|
||||
if device_connected $1; then
|
||||
bluetoothctl disconnect $1
|
||||
device_menu "$device"
|
||||
@@ -353,9 +269,7 @@ toggle_connection() {
|
||||
device_menu "$device"
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if a device is paired
|
||||
device_paired() {
|
||||
device_paired() { # Checks if a device is paired
|
||||
device_info=$(bluetoothctl info "$1")
|
||||
if echo "$device_info" | grep -q "Paired: yes"; then
|
||||
echo "Paired: "
|
||||
@@ -365,9 +279,7 @@ device_paired() {
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Toggles device paired state
|
||||
toggle_paired() {
|
||||
toggle_paired() { # Toggles device paired state
|
||||
if device_paired $1; then
|
||||
bluetoothctl remove $1
|
||||
device_menu "$device"
|
||||
@@ -376,9 +288,7 @@ toggle_paired() {
|
||||
device_menu "$device"
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if a device is trusted
|
||||
device_trusted() {
|
||||
device_trusted() { # Checks if a device is trusted
|
||||
device_info=$(bluetoothctl info "$1")
|
||||
if echo "$device_info" | grep -q "Trusted: yes"; then
|
||||
echo "Trusted: "
|
||||
@@ -388,9 +298,7 @@ device_trusted() {
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Toggles device connection
|
||||
toggle_trust() {
|
||||
toggle_trust() { # Toggles device connection
|
||||
if device_trusted $1; then
|
||||
bluetoothctl untrust $1
|
||||
device_menu "$device"
|
||||
@@ -399,10 +307,7 @@ toggle_trust() {
|
||||
device_menu "$device"
|
||||
fi
|
||||
}
|
||||
|
||||
# Prints a short string with the current bluetooth status
|
||||
# Useful for status bars like polybar, etc.
|
||||
print_status() {
|
||||
print_status() { # Prints a short string with the current bluetooth status
|
||||
if power_on; then
|
||||
printf ''
|
||||
|
||||
@@ -427,30 +332,23 @@ print_status() {
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# A submenu for a specific device that allows connecting, pairing, and trusting
|
||||
device_menu() {
|
||||
device_menu() { # A submenu for a specific device that allows connecting, pairing, and trusting
|
||||
device=$1
|
||||
|
||||
# Get device name and mac address
|
||||
device_name=$(echo $device | cut -d ' ' -f 3-)
|
||||
device_name=$(echo $device | cut -d ' ' -f 3-) # Get device name and mac address
|
||||
mac=$(echo $device | cut -d ' ' -f 2)
|
||||
|
||||
# Build options
|
||||
if device_connected $mac; then
|
||||
if device_connected $mac; then # Build options
|
||||
connected="Connected: "
|
||||
else
|
||||
connected="Connected: "
|
||||
fi
|
||||
paired=$(device_paired $mac)
|
||||
trusted=$(device_trusted $mac)
|
||||
options="$connected\n$paired\n$trusted\n$goback\n Exit"
|
||||
|
||||
# Open rofi menu, read chosen option
|
||||
chosen="$(echo -e "$options" | $rofi_command "$device_name")"
|
||||
|
||||
# Match chosen option to command
|
||||
case $chosen in
|
||||
options="$connected\n$paired\n$trusted\n$divider\n$goback\n Exit"n
|
||||
chosen="$(echo -e "$options" | $rofi_command "$device_name")" # Open rofi menu, read chosen optio
|
||||
case $chosen in # Match chosen option to command
|
||||
"" | $divider)
|
||||
echo "No option chosen."
|
||||
;;
|
||||
$connected)
|
||||
toggle_connection $mac
|
||||
;;
|
||||
@@ -465,34 +363,23 @@ device_menu() {
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Opens a rofi menu with current bluetooth status and options to connect
|
||||
show_menu() {
|
||||
# Get menu options
|
||||
if power_on; then
|
||||
show_menu() { # Opens a rofi menu with current bluetooth status and options to connect
|
||||
if power_on; then # Get menu options
|
||||
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)
|
||||
devices=$(bluetoothctl devices | grep Device | cut -d ' ' -f 3-)s # Human-readable names of devices, one per line. If scan is off, will only list paired devices
|
||||
scan=$(scan_on) # Get controller flag
|
||||
pairable=$(pairable_on)
|
||||
discoverable=$(discoverable_on)
|
||||
|
||||
# Options passed to rofi
|
||||
options="$devices\n$power\n$scan\n$pairable\n$discoverable\n Exit"
|
||||
options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\n Exit" # Options passed to rofi
|
||||
else
|
||||
power=" Power: OFF"
|
||||
options="$power\n Exit"
|
||||
fi
|
||||
|
||||
# Open rofi menu, read chosen option
|
||||
chosen="$(echo -e "$options" | $rofi_command " Bluetooth")"
|
||||
|
||||
# Match chosen option to command
|
||||
case $chosen in
|
||||
chosen="$(echo -e "$options" | $rofi_command " Bluetooth")" # Open rofi menu, read chosen option
|
||||
case $chosen in # Match chosen option to command
|
||||
"" | $divider)
|
||||
echo "No option chosen."
|
||||
;;
|
||||
$power)
|
||||
toggle_power
|
||||
;;
|
||||
@@ -507,15 +394,11 @@ show_menu() {
|
||||
;;
|
||||
*)
|
||||
device=$(bluetoothctl devices | grep "$chosen")
|
||||
# Open a submenu if a device is selected
|
||||
if [[ $device ]]; then device_menu "$device"; fi
|
||||
if [[ $device ]]; then device_menu "$device"; fi # Open a submenu if a device is selected
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Rofi command to pipe into, can add any options here
|
||||
rofi_command="rofi -dmenu -no-fixed-num-lines -yoffset -100 -i -theme $theme -p"
|
||||
|
||||
rofi_command="rofi -dmenu -no-fixed-num-lines -yoffset -100 -i -theme $theme -p" # Rofi command to pipe into, can add any options here
|
||||
case "$1" in
|
||||
--status)
|
||||
print_status
|
||||
@@ -524,5 +407,4 @@ case "$1" in
|
||||
show_menu
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user