aboutsummaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/scripts/gsettings.sh26
-rw-r--r--.local/bin/scripts/install.sh19
-rwxr-xr-x.local/bin/scripts/neovim.sh395
-rwxr-xr-x.local/bin/scripts/random_data.py153
-rwxr-xr-x.local/bin/scripts/scratchpad88
5 files changed, 616 insertions, 65 deletions
diff --git a/.local/bin/scripts/gsettings.sh b/.local/bin/scripts/gsettings.sh
new file mode 100755
index 0000000..d4f6045
--- /dev/null
+++ b/.local/bin/scripts/gsettings.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# Disable screen lock
+gsettings set org.gnome.desktop.screensaver lock-enabled false
+gsettings set org.gnome.desktop.session idle-delay 0
+
+# Mutter Overlay Key
+gsettings set org.gnome.mutter overlay-key ''
+
+# Disable update notification
+gsettings set org.gnome.software download-updates false
+#gsettings set com.ubuntu.update-notifier no-show-notifications true
+#sudo rm /etc/xdg/autostart/upg-notifier-autostart.desktop
+sudo mv /etc/xdg/autostart/update-notifier.desktop /etc/xdg/autostart/update-notifier.desktop.old
+sudo mv /etc/xdg/autostart/gnome-software-service.desktop /etc/xdg/autostart/gnome-software-service.desktop.old
+
+# Custom Keybinding Names
+gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']"
+
+# Custom Keybinding 0
+gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding "<Alt>T"
+gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command "scratchpad"
+gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name "scratchpad"
+
+# Disable keyboard plugin
+gsettings set org.gnome.settings-daemon.plugins.keyboard active false
diff --git a/.local/bin/scripts/install.sh b/.local/bin/scripts/install.sh
deleted file mode 100644
index b811355..0000000
--- a/.local/bin/scripts/install.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-if [[ $EUID -eq 0 ]]; then
- echo "This script must not be run as root"
- exit 1
-fi
-
-# Install system packages
-packages=(
- "ripgrep"
- "xclip"
- "ctags"
-)
-
-for package in "${packages[@]}"; do
- if ! pacman -Qi "$package" > /dev/null 2>&1; then
- sudo pacman -S --noconfirm "$package"
- fi
-done
diff --git a/.local/bin/scripts/neovim.sh b/.local/bin/scripts/neovim.sh
new file mode 100755
index 0000000..4b67d48
--- /dev/null
+++ b/.local/bin/scripts/neovim.sh
@@ -0,0 +1,395 @@
+#!/bin/bash
+
+# Created By: srdusr
+# Created On: Sat 12 Aug 2023 13:11:39 CAT
+# Project: Install/update/downgrade/change version/uninstall Neovim script, primarily for Linux but may work in other platforms
+
+# Color definitions
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+NC='\033[0m' # No Color
+
+# Function to handle errors
+handle_error() {
+ local message="$1"
+ printf "${RED}Error: $message${NC}\n"
+}
+
+# Check if necessary dependencies are installed
+check_dependencies() {
+ if [ -x "$(command -v wget)" ]; then
+ DOWNLOAD_COMMAND="wget"
+ elif [ -x "$(command -v curl)" ]; then
+ DOWNLOAD_COMMAND="curl"
+ else
+ printf "${RED}Error: Neither wget nor curl found. Please install one of them to continue!${NC}\n"
+ exit 1
+ fi
+}
+
+# Check for privilege escalation tools
+check_privilege_tools() {
+ if [ -x "$(command -v sudo)" ]; then
+ PRIVILEGE_TOOL="sudo"
+ elif [ -x "$(command -v doas)" ]; then
+ PRIVILEGE_TOOL="doas"
+ elif [ -x "$(command -v pkexec)" ]; then
+ PRIVILEGE_TOOL="pkexec"
+ elif [ -x "$(command -v dzdo)" ]; then
+ PRIVILEGE_TOOL="dzdo"
+ elif [ "$(id -u)" -eq 0 ]; then
+ PRIVILEGE_TOOL="" # root
+ else
+ PRIVILEGE_TOOL="" # No privilege escalation mechanism found
+ printf "\n${RED}Error: No privilege escalation tool (sudo, doas, pkexec, dzdo, or root privileges) found. You may not have sufficient permissions to run this script.${NC}\n"
+ printf "\nAttempt to continue Installation (might fail without a privilege escalation tool)? [yes/no] "
+ read continue_choice
+ case $continue_choice in
+ [Yy] | [Yy][Ee][Ss]) ;;
+ [Nn] | [Nn][Oo]) exit ;;
+ *) handle_error "Invalid choice. Exiting..." && exit ;;
+ esac
+ fi
+}
+
+# Check if Neovim is already installed
+check_neovim_installed() {
+ if [ -x "$(command -v nvim)" ]; then
+ return 0 # Neovim is installed
+ else
+ return 1 # Neovim is not installed
+ fi
+}
+
+# Nightly version
+nightly_version() {
+ local url="https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage"
+ install_neovim "$url"
+ local version_output=$(nvim --version)
+ version_id="Nightly $(echo "$version_output" | grep -oP 'v\d+\.\d+\.\d+')"
+}
+
+# Stable version
+stable_version() {
+ local url="https://github.com/neovim/neovim/releases/download/stable/nvim.appimage"
+ install_neovim "$url"
+ local version_output=$(nvim --version)
+ version_id="Stable $(echo "$version_output" | grep -oP 'v\d+\.\d+\.\d+')"
+
+}
+
+# Specific version
+specific_version() {
+ local version="$1"
+
+ # Add 'v' prefix if not present
+ if [[ $version != v* ]]; then
+ version="v$version"
+ fi
+
+ local url="https://github.com/neovim/neovim/releases/download/$version/nvim.appimage"
+ install_neovim "$url"
+ local version_output=$(nvim --version)
+ version_id="Stable $(echo "$version_output" | grep -oP 'v\d+\.\d+\.\d+')"
+}
+
+# Function to download a file using wget or curl
+download_file() {
+ local url="$1"
+ local output="$2"
+
+ if [ "$DOWNLOAD_COMMAND" = "wget" ]; then
+ "$DOWNLOAD_COMMAND" -q --show-progress -O "$output" "$url"
+ elif [ "$DOWNLOAD_COMMAND" = "curl" ]; then
+ "$DOWNLOAD_COMMAND" --progress-bar -# -o "$output" "$url"
+ else
+ echo "Unsupported download command: $DOWNLOAD_COMMAND"
+ exit 1
+ fi
+}
+
+# Check if a specific version of Neovim exists
+version_exists() {
+ local version="$1"
+
+ # Add 'v' prefix if not present
+ if [[ $version != v* ]]; then
+ version="v$version"
+ fi
+
+ # Fetch all the release tags from GitHub
+ ALL_TAGS=$(curl -s "https://api.github.com/repos/neovim/neovim/tags" | grep '"name":' | cut -d '"' -f 4)
+
+ # Check if the desired version is in the list of release tags
+ if echo "$ALL_TAGS" | grep -q "$version"; then
+ return 0 # Version exists
+ else
+ return 1 # Version does not exist
+ fi
+}
+
+# Install Neovim
+install_neovim() {
+ local url="$1"
+ local install_type="$2" # Pass the install type as an argument
+ local install_action="$3"
+
+ if [ "$install_action" = "installed" ]; then
+ printf "Downloading and installing $install_type Neovim $version_id...\n"
+ else
+ printf "${GREEN}Updating $install_type Neovim to the latest version...${NC}\n"
+ fi
+
+ # Determine the platform-specific installation steps
+ case "$(uname -s)" in
+ Linux)
+ printf "Detected Linux OS.\n"
+ if [ -x "$(command -v fusermount)" ]; then
+ printf "FUSE is available. Downloading and running the AppImage...\n"
+ download_file "$url" "nvim.appimage"
+ chmod u+x nvim.appimage
+ "$PRIVILEGE_TOOL" cp nvim.appimage /usr/local/bin/nvim
+ "$PRIVILEGE_TOOL" mv nvim.appimage /usr/bin/nvim
+ else
+ printf "FUSE is not available. Downloading and extracting the AppImage...\n"
+ download_file "$url" "nvim.appimage"
+ chmod u+x nvim.appimage
+ ./nvim.appimage --appimage-extract
+ "$PRIVILEGE_TOOL" cp squashfs-root/usr/bin/nvim /usr/local/bin
+ "$PRIVILEGE_TOOL" mv squashfs-root/usr/bin/nvim /usr/bin
+ fi
+ ;;
+
+ Darwin)
+ printf "Detected macOS.\n"
+ download_file "$url" "nvim-macos.tar.gz"
+ xattr -c ./nvim-macos.tar.gz
+ tar xzvf nvim-macos.tar.gz
+ "$PRIVILEGE_TOOL" cp nvim-macos/bin/nvim /usr/local/bin
+ "$PRIVILEGE_TOOL" mv nvim-macos/bin/nvim /usr/bin/nvim
+ ;;
+
+ MINGW*)
+ printf "Detected Windows.\n"
+ download_file "$url" "nvim.appimage"
+ chmod +x nvim.appimage
+ if [ "$PRIVILEGE_TOOL" = "sudo" ]; then
+ "$PRIVILEGE_TOOL" cp nvim.appimage /usr/local/bin/nvim
+ "$PRIVILEGE_TOOL" mv /usr/local/bin/nvim /usr/bin
+ elif [ "$PRIVILEGE_TOOL" = "" ]; then
+ cp nvim.appimage /usr/local/bin/nvim
+ mv /usr/local/bin/nvim /usr/bin
+ else
+ printf "No privilege escalation tool found. Cannot install Neovim on Windows.\n"
+ fi
+ ;;
+
+ *)
+ printf "Unsupported operating system.\n"
+ exit 1
+ ;;
+ esac
+ if [ "$install_action" = "installed" ]; then
+ printf "${GREEN}$install_type Neovim $version_id has been installed successfully!${NC}\n"
+ else
+ printf "${GREEN}$install_type Neovim has been updated successfully to $version_id!${NC}\n"
+ fi
+}
+
+# Update Neovim to the latest version (nightly/stable)
+update_version() {
+ valid_choice=false
+ while [ "$valid_choice" = false ]; do
+ # Determine which version to update to (nightly/stable)
+ printf "Select version to update to:\n"
+ printf " 1. Nightly\n"
+ printf " 2. Stable\n"
+ printf " 3. Choose specific version by tag\n"
+ printf "Enter the number corresponding to your choice (1/2/3): "
+ read update_choice
+
+ case $update_choice in
+ 1)
+ action="updated"
+ nightly_version
+ valid_choice=true
+ ;;
+ 2)
+ action="updated"
+ stable_version
+ valid_choice=true
+ ;;
+ 3)
+ # Ask user for specific version
+ read -p "Enter the specific version (e.g., v0.1.0): " version
+ # Normalize version
+ if [[ $version != v* ]]; then
+ version="v$version"
+ fi
+ # Check if the specific version exists on GitHub releases
+ if version_exists "$version"; then
+ # Install specific version
+ specific_version "$version" # Pass the normalized version to the function
+ valid_choice=true
+ else
+ printf "${RED}The specified version $version does not exist.${NC}\n"
+ fi
+ ;;
+
+ *)
+ handle_error "Invalid choice. Please enter a valid option (1, 2 or 3)."
+ ;;
+ esac
+ done
+
+}
+
+# Uninstall Neovim
+uninstall_neovim() {
+ printf "${RED}Uninstalling Neovim...${NC}\n"
+
+ # Detect the operating system to determine the appropriate uninstallation method
+ case "$(uname -s)" in
+ Linux)
+ printf "Detected Linux OS.\n"
+ "$PRIVILEGE_TOOL" rm /usr/local/bin/nvim
+ "$PRIVILEGE_TOOL" rm /usr/bin/nvim
+ ;;
+
+ Darwin)
+ printf "Detected macOS.\n"
+ "$PRIVILEGE_TOOL" rm /usr/local/bin/nvim
+ "$PRIVILEGE_TOOL" rm /usr/bin/nvim
+ ;;
+
+ MINGW*)
+ printf "Detected Windows.\n"
+ if [ "$PRIVILEGE_TOOL" = "sudo" ]; then
+ "$PRIVILEGE_TOOL" rm /usr/local/bin/nvim
+ "$PRIVILEGE_TOOL" rm /usr/bin/nvim
+ else
+ [ "$PRIVILEGE_TOOL" = "" ]
+ rm /usr/local/bin/nvim
+ rm /usr/bin/nvim
+ fi
+ ;;
+ *)
+ printf "Unsupported operating system.\n"
+ ;;
+ esac
+
+ printf "${GREEN}Neovim has been uninstalled successfully!${NC}\n"
+}
+
+# Check if Neovim is running
+check_neovim_running() {
+ if pgrep nvim >/dev/null; then
+ printf "${RED}Error: Neovim is currently running. Please close Neovim before proceeding.${NC}\n"
+ read -p "Do you want to forcefully terminate Neovim and continue? [yes/no] " terminate_choice
+
+ case $terminate_choice in
+ [Yy] | [Yy][Ee][Ss])
+ pkill nvim # Forcefully terminate Neovim
+ ;;
+ [Nn] | [Nn][Oo])
+ echo "Exiting..."
+ exit 1
+ ;;
+ *)
+ handle_error "Invalid choice."
+ ;;
+ esac
+ fi
+}
+
+check_neovim_running
+
+# Define the variable to control the prompt
+SHOW_PROMPT=1
+
+# Check if necessary dependencies are installed
+check_dependencies
+
+# Check for privilege escalation tools
+check_privilege_tools
+
+# Check if Neovim is already installed
+if check_neovim_installed; then
+ printf "${GREEN}Neovim is already installed!${NC}\n"
+else
+ choose_version
+fi
+
+# Function to check for updates and display breaking changes
+check_version_updates() {
+ local latest_version_url="https://api.github.com/repos/neovim/neovim/releases/latest"
+ local latest_version=""
+
+ if [ -x "$(command -v curl)" ]; then
+ latest_version=$(curl -sSL "$latest_version_url" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
+ elif [ -x "$(command -v wget)" ]; then
+ latest_version=$(wget -qO - "$latest_version_url" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
+ else
+ printf "${RED}Error: Neither curl nor wget found. Please install one of them to continue!${NC}\n"
+ exit 1
+ fi
+
+ if version_exists "$latest_version"; then
+ printf "${GREEN}An update is available!${NC}\n"
+ display_breaking_changes "$latest_version"
+ else
+ printf "You have the latest version of Neovim.\n"
+ fi
+}
+
+# Function to display breaking changes for a specific version
+display_breaking_changes() {
+ local version="$1"
+ local changelog_url="https://github.com/neovim/neovim/releases/tag/$version"
+ local changelog=""
+
+ if [ -x "$(command -v curl)" ]; then
+ changelog=$(curl -sSL "$changelog_url" | grep -oE '<h1>Breaking Changes.*?</ul>' | sed 's/<[^>]*>//g')
+ elif [ -x "$(command -v wget)" ]; then
+ changelog=$(wget -qO - "$changelog_url" | grep -oE '<h1>Breaking Changes.*?</ul>' | sed 's/<[^>]*>//g')
+ else
+ printf "${RED}Error: Neither curl nor wget found. Please install one of them to continue!${NC}\n"
+ exit 1
+ fi
+
+ printf "\nBreaking Changes in Neovim $version:\n"
+ printf "$changelog\n"
+}
+
+# Main loop
+while [ "$SHOW_PROMPT" -gt 0 ]; do
+ printf "Select an option:\n"
+ printf " 1. Update Neovim\n"
+ printf " 2. Check for updates\n"
+ printf " 3. Uninstall Neovim\n"
+ printf " 4. Run Neovim\n"
+ printf " 5. Quit\n"
+ read -p "Enter a number or press 'q' to quit: " choice
+
+ case $choice in
+ 1)
+ update_version
+ ;;
+ 2)
+ check_version_updates
+ ;;
+ 3)
+ uninstall_neovim
+ ;;
+ 4)
+ nvim
+ ;;
+ 5 | [Qq])
+ echo "Exiting..."
+ exit
+ ;;
+ *)
+ handle_error "Invalid choice. Please choose a valid option by entering the corresponding number or press 'q' to 'quit'."
+ ;;
+ esac
+done
diff --git a/.local/bin/scripts/random_data.py b/.local/bin/scripts/random_data.py
new file mode 100755
index 0000000..071ab7c
--- /dev/null
+++ b/.local/bin/scripts/random_data.py
@@ -0,0 +1,153 @@
+#!/usr/bin/env python3
+
+import os
+import random
+import string
+import json
+import datetime
+import csv
+
+
+def generate_random_string(length, charset=string.ascii_letters):
+ """Generate a random string of given length and character set."""
+ return ''.join(random.choice(charset) for _ in range(length))
+
+
+def generate_random_number(min_value, max_value):
+ """Generate a random number within the specified range."""
+ return random.randint(min_value, max_value)
+
+
+def generate_random_date(start_date, end_date):
+ """Generate a random date within the specified range."""
+ time_between_dates = end_date - start_date
+ days_between_dates = time_between_dates.days
+ random_number_of_days = random.randrange(days_between_dates)
+ random_date = start_date + datetime.timedelta(days=random_number_of_days)
+ return random_date.strftime("%Y-%m-%d")
+
+
+def generate_sql_insert(table_name, columns, num_records):
+ """Generate SQL INSERT statements for populating a table."""
+ sql_statements = []
+ for _ in range(num_records):
+ values = [f"'{generate_random_string(int(input(f'Enter length for {column}: ')))}'" for column in columns]
+ sql = f"INSERT INTO {table_name} ({', '.join(columns)}) VALUES ({', '.join(values)});"
+ sql_statements.append(sql)
+ return sql_statements
+
+
+def generate_placeholder_data(num_records, data_format):
+ """Generate placeholder data based on user-defined format."""
+ placeholder_data = []
+ for _ in range(num_records):
+ record = {}
+ for field, field_data in data_format.items():
+ data_type = field_data['type']
+ if data_type == 'string':
+ length = field_data['length']
+ charset = field_data['charset']
+ record[field] = generate_random_string(length, charset)
+ elif data_type == 'number':
+ min_value = field_data['min']
+ max_value = field_data['max']
+ record[field] = generate_random_number(min_value, max_value)
+ elif data_type == 'date':
+ start_date = datetime.datetime.strptime(field_data['start_date'], "%Y-%m-%d")
+ end_date = datetime.datetime.strptime(field_data['end_date'], "%Y-%m-%d")
+ record[field] = generate_random_date(start_date, end_date)
+ elif data_type == 'boolean':
+ record[field] = random.choice([True, False])
+ placeholder_data.append(record)
+ return placeholder_data
+
+
+def get_data_format_from_user():
+ """Prompt the user for data format preferences."""
+ data_format = {}
+ while True:
+ field = input("Enter field name (or 'done' to finish): ").strip()
+ if field.lower() == 'done':
+ break
+
+ data_type = input(f"Enter data type for '{field}' (string/number/date/boolean): ").strip()
+ if data_type not in ['string', 'number', 'date', 'boolean']:
+ print("Invalid data type. Please enter 'string', 'number', 'date', or 'boolean'.")
+ continue
+
+ if data_type == 'string':
+ length = int(input(f"Enter length for '{field}' (integer): "))
+ charset = input(f"Enter character set for '{field}' (optional, press Enter for default): ").strip()
+ if not charset:
+ charset = string.ascii_letters
+ data_format[field] = {'type': 'string', 'length': length, 'charset': charset}
+ elif data_type == 'number':
+ min_value = int(input(f"Enter minimum value for '{field}' (integer): "))
+ max_value = int(input(f"Enter maximum value for '{field}' (integer): "))
+ data_format[field] = {'type': 'number', 'min': min_value, 'max': max_value}
+ elif data_type == 'date':
+ start_date = input(f"Enter start date for '{field}' (YYYY-MM-DD): ")
+ end_date = input(f"Enter end date for '{field}' (YYYY-MM-DD): ")
+ data_format[field] = {'type': 'date', 'start_date': start_date, 'end_date': end_date}
+ elif data_type == 'boolean':
+ data_format[field] = {'type': 'boolean'}
+
+ return data_format
+
+
+def get_file_type_from_user():
+ """Prompt the user for the desired file type (e.g., JSON, CSV, SQL, TXT, MD, HTML)."""
+ while True:
+ file_type = input("Enter the desired file type for saving the data (json/csv/sql/txt/md/html): ").strip().lower()
+ if file_type in ['json', 'csv', 'sql', 'txt', 'md', 'html']:
+ return file_type
+ else:
+ print("Invalid file type. Please enter 'json', 'csv', 'sql', 'txt', 'md', or 'html'.")
+
+
+def save_data_to_file(data, file_type):
+ """Save the generated data to a file of the specified type."""
+ if file_type == 'json':
+ with open('placeholder_data.json', 'w') as json_file:
+ json.dump(data, json_file, indent=4)
+ elif file_type == 'csv':
+ with open('placeholder_data.csv', 'w', newline='') as csv_file:
+ fieldnames = data[0].keys()
+ writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
+ writer.writeheader()
+ for record in data:
+ writer.writerow(record)
+ elif file_type == 'sql':
+ table_name = input("Enter the SQL table name: ")
+ columns = input("Enter column names separated by commas: ").split(',')
+ sql_statements = generate_sql_insert(table_name, columns, len(data))
+ with open('generated_data.sql', 'w') as sql_file:
+ sql_file.write('\n'.join(sql_statements))
+ elif file_type == 'txt':
+ with open('placeholder_data.txt', 'w') as txt_file:
+ for record in data:
+ txt_file.write(str(record) + '\n')
+ elif file_type == 'md':
+ with open('placeholder_data.md', 'w') as md_file:
+ for record in data:
+ md_file.write('- ' + ', '.join([f"{key}: {value}" for key, value in record.items()]) + '\n')
+ elif file_type == 'html':
+ with open('placeholder_data.html', 'w') as html_file:
+ html_file.write('<html>\n<head>\n<title>Placeholder Data</title>\n</head>\n<body>\n')
+ for record in data:
+ html_file.write('<ul>\n')
+ for key, value in record.items():
+ html_file.write(f'<li>{key}: {value}</li>\n')
+ html_file.write('</ul>\n')
+
+
+if __name__ == "__main__":
+ num_records = int(input("Enter the number of records to generate: "))
+ data_format = get_data_format_from_user()
+ file_type = get_file_type_from_user()
+
+ placeholder_data = generate_placeholder_data(num_records, data_format)
+
+ save_data_to_file(placeholder_data, file_type)
+
+ print(f"Data will be saved to: {os.path.abspath('generated_data.sql')}")
diff --git a/.local/bin/scripts/scratchpad b/.local/bin/scripts/scratchpad
index 1b3dfeb..8a1aea0 100755
--- a/.local/bin/scripts/scratchpad
+++ b/.local/bin/scripts/scratchpad
@@ -4,65 +4,61 @@
# Created On: Tue 07 Mar 2023 15:06:47 PM CAT
# Project: Agnostic scratchpad/dropdown terminal that works on most window managers
-# Set the GDK_BACKEND and QT_QPA_PLATFORM environment variables to x11 to allow working in Wayland
+# Dependencies: wmctrl, xprop, xdo, xdotool
+# NOTE: Ensure script is included in system's path and can therefore be invoked with the command 'scratchpad'.
+# Furthermore make sure the terminal is using x11 as a backend in wayland to allow this to work.
+# Example: wezterm.lua: enable_wayland = false,
+# kitty.conf: linux_display_server x11
+
+# Set the environment variables to x11 to allow working in Wayland
export GDK_BACKEND=x11
export QT_QPA_PLATFORM=xcb
+export WAYLAND_DISPLAY=""
+export WINIT_UNIX_BACKEND=x11
-# List of supported terminals with dropdown class
-supported_terminals=(
- "wezterm"
- "kitty"
- "alacritty"
-)
+# Supported terminals and dropdown class
+supported_terminals=("wezterm" "kitty" "alacritty")
-# Check if any of the supported terminals with scratchpad class are running
+# Check if any supported terminal with scratchpad class is running
for term in "${supported_terminals[@]}"; do
- if pgrep -f "$term.*--class scratchpad" >/dev/null; then
- my_term="$term"
- break
- fi
+ if pgrep -f "$term.*--class scratchpad" >/dev/null; then
+ my_term="$term"
+ break
+ fi
done
-# If none of the supported terminals are running, start the first available one
+# If no supported terminal is running, start the first available one
if [ "$my_term" = "" ]; then
- for term in "${supported_terminals[@]}"; do
- if command -v "$term" >/dev/null 2>&1; then
- my_term="$term"
- break
- fi
- done
- if [ "$my_term" = "" ]; then
- echo "No supported terminal found."
- exit 1
- fi
+ for term in "${supported_terminals[@]}"; do
+ if command -v "$term" >/dev/null 2>&1; then
+ my_term="$term"
+ break
+ fi
+ done
+ if [ "$my_term" = "" ]; then
+ echo "No supported terminal found." && exit 1
+ fi
- # Start the terminal with scratchpad class
- case "$my_term" in
- "wezterm")
- wezterm start --class scratchpad -e tmux new-session -A -s tmux -e bash >/dev/null 2>&1 &
- ;;
- "kitty")
- kitty --class scratchpad tmux new-session -A -s tmux -e bash >/dev/null 2>&1 &
- ;;
- "alacritty")
- alacritty --class scratchpad -e tmux new-session -A -s tmux -e bash >/dev/null 2>&1 &
- ;;
- esac
+ # Start terminal with scratchpad class
+ case "$my_term" in
+ "wezterm") wezterm start --class scratchpad -e tmux new-session -A -s tmux -e bash & ;;
+ "kitty") kitty --class scratchpad tmux new-session -A -s tmux -e bash & ;;
+ "alacritty") alacritty --class scratchpad -e tmux new-session -A -s tmux -e bash & ;;
+ esac
fi
# Get the window ID of the scratchpad terminal
id="$(xdo id -N scratchpad)"
-# Toggle the visibility of the scratchpad terminal
+# Toggle scratchpad terminal visibility
if [ "$id" != "" ]; then
- if xwininfo -id "$id" | grep "Map State: IsViewable" >/dev/null; then
- # The scratchpad window is visible, so hide it
- dimensions="$(xwininfo -id "$id" | awk '/Width:|Height:/ { printf("%s=%s;", tolower($1), $2) }')"
- xdo hide "$id" 2>/dev/null
- else
- # The scratchpad window is hidden, so show it
- xdo show "$id"
- # Restore the dimensions of the window
- xdotool windowsize "$id" "$(echo "$dimensions" | tr ';' ' ')" 2>/dev/null
- fi
+ if xwininfo -id "$id" | grep "Map State: IsViewable" >/dev/null; then
+ # Scratchpad is visible, hide it
+ dimensions="$(xwininfo -id "$id" | awk '/Width:|Height:/ { printf("%s=%s;", tolower($1), $2) }')"
+ xdo hide "$id" 2>/dev/null
+ else
+ # Scratchpad is hidden, show it and restore dimensions
+ xdo show "$id"
+ xdotool windowsize "$id" "$(echo "$dimensions" | tr ';' ' ')" 2>/dev/null
+ fi
fi