diff --git a/bin/bin/battery-alert b/bin/bin/battery-alert new file mode 100755 index 0000000..56397b9 --- /dev/null +++ b/bin/bin/battery-alert @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# https://github.com/asapdotid/battery-alert-linux/blob/main/LICENSE +#Copyright (c) 2022 Asapdotid +# +#Permission is hereby granted, free of charge, to any person obtaining a copy +#of this software and associated documentation files (the "Software"), to deal +#in the Software without restriction, including without limitation the rights +#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +#copies of the Software, and to permit persons to whom the Software is +#furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all +#copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +#IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +#DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +#OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +#OR OTHER DEALINGS IN THE SOFTWARE. + +sleep 10 +while true; do + export DISPLAY=:0.0 + + while read line; do + value=$(echo $line | sed 's/%//g' | cut -d " " -f 2) + key=$(echo $line | sed 's/%//g' | cut -d ":" -f 1) + + if [ $key = 'state' ]; then + bat_state=$value + else + bat_percent=$value + fi + done < <(upower -i $(upower -e | grep BAT) | grep -E "percentage|state") + + if [ $bat_state == 'discharging' ]; then + if [ $bat_percent -lt 30 ]; then + notify-send --urgency=CRITICAL "Battery Low" "Level: ${bat_percent}%" + paplay /usr/share/sounds/freedesktop/stereo/suspend-error.oga + fi + else + if [ $bat_percent -ge 100 ]; then + notify-send --urgency=NORMAL "Battery Full" "Level: ${bat_percent}%" + fi + fi + + sleep 10 +done diff --git a/bin/bin/battery-check.sh b/bin/bin/battery-check.sh new file mode 100755 index 0000000..3d0c529 --- /dev/null +++ b/bin/bin/battery-check.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +: "${BAT_TMP:=/tmp/batterytmp}" +: "${THRESHOLD:=15}" + +let bat="$(cat /sys/class/power_supply/BAT1/capacity)" +if [[ -f "$BAT_TMP" ]]; then + ((bat > THRESHOLD)) && rm -f "$BAT_TMP" +else + ((bat <= THRESHOLD)) && { + notify-send -u critical "WARNING: low battery" + touch "$BAT_TMP" + } +fi + +echo "$bat%" diff --git a/bin/bin/gw_ide.sh b/bin/bin/gw_ide.sh new file mode 100755 index 0000000..b99a59d --- /dev/null +++ b/bin/bin/gw_ide.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +LD_PRELOAD=/usr/lib/libfreetype.so ~/Programs/Gowin_V1.9.9.03_Education_linux/IDE/bin/gw_ide diff --git a/bin/bin/litex_setup.py b/bin/bin/litex_setup.py new file mode 100755 index 0000000..bb71aba --- /dev/null +++ b/bin/bin/litex_setup.py @@ -0,0 +1,483 @@ +#!/usr/bin/env python3 + +import os +import sys +import time +import subprocess +import shutil +import hashlib +import argparse + +import urllib.request + +start_time = time.time() +current_path = os.path.abspath(os.curdir) +python3 = sys.executable + +# Helpers ------------------------------------------------------------------------------------------ + +def colorer(s, color="bright"): + header = { + "bright" : "\x1b[1m", + "green" : "\x1b[1m\x1b[32m", + "cyan" : "\x1b[1m\x1b[36m", + "red" : "\x1b[1m\x1b[31m", + "yellow" : "\x1b[1m\x1b[33m", + "underline" : "\x1b[1m\x1b[4m"}[color] + trailer = "\x1b[0m" + return header + str(s) + trailer + +def print_banner(): + b = [] + b.append(" __ _ __ _ __ ") + b.append(" / / (_) /____ | |/_/ ") + b.append(" / /__/ / __/ -_)> < ") + b.append(" /____/_/\\__/\\__/_/|_| ") + b.append(" Build your hardware, easily! ") + b.append(" LiteX Setup utility. ") + b.append("") + print("\n".join(b)) + +def print_status(status, underline=False): + exec_time = (time.time() - start_time) + print(colorer(f"[{exec_time:8.3f}]", color="green") + " " + colorer(status)) + if underline: + print(colorer(f"[{exec_time:8.3f}]", color="green") + " " + colorer("-"*len(status))) + +def print_error(status): + exec_time = (time.time() - start_time) + print(colorer(f"[{exec_time:8.3f}]", color="red") + " " + colorer(status)) + +class SetupError(Exception): + def __init__(self): + sys.stderr = None # Error already described, avoid traceback/exception. + +# Git repositories --------------------------------------------------------------------------------- + +# Get SHA1: git rev-parse --short=7 HEAD + +class GitRepo: + def __init__(self, url, clone="regular", develop=True, sha1=None, branch="master", tag=None): + assert clone in ["regular", "recursive"] + self.url = url + self.clone = clone + self.develop = develop + self.sha1 = sha1 + self.branch = branch + self.tag = tag + + +git_repos = { + # HDL. + # ---- + "migen": GitRepo(url="https://github.com/m-labs/", clone="recursive", sha1=0xccaee68e14d3636e1d8fb2e0864dd89b1b1f7384), + + # LiteX SoC builder. + # ------------------ + "pythondata-software-picolibc": GitRepo(url="https://github.com/litex-hub/", clone="recursive"), + "pythondata-software-compiler_rt": GitRepo(url="https://github.com/litex-hub/"), + "litex": GitRepo(url="https://github.com/enjoy-digital/", tag=True), + + # LiteX Cores Ecosystem. + # ---------------------- + "liteiclink": GitRepo(url="https://github.com/enjoy-digital/", tag=True), + "liteeth": GitRepo(url="https://github.com/enjoy-digital/", tag=True), + "litedram": GitRepo(url="https://github.com/enjoy-digital/", tag=True), + "litepcie": GitRepo(url="https://github.com/enjoy-digital/", tag=True), + "litesata": GitRepo(url="https://github.com/enjoy-digital/", tag=True), + "litesdcard": GitRepo(url="https://github.com/enjoy-digital/", tag=True), + "litescope": GitRepo(url="https://github.com/enjoy-digital/", tag=True), + "litejesd204b": GitRepo(url="https://github.com/enjoy-digital/", tag=True), + "litespi": GitRepo(url="https://github.com/litex-hub/", tag=True), + + # LiteX Misc Cores. + # ----------------- + "valentyusb": GitRepo(url="https://github.com/litex-hub/", branch="hw_cdc_eptri"), + + # LiteX Boards. + # ------------- + "litex-boards": GitRepo(url="https://github.com/litex-hub/", clone="regular", tag=True), + + # LiteX pythondata. + # ----------------- + # Generic. + "pythondata-misc-tapcfg": GitRepo(url="https://github.com/litex-hub/"), + "pythondata-misc-usb_ohci": GitRepo(url="https://github.com/litex-hub/"), + + # LM32 CPU(s). + "pythondata-cpu-lm32": GitRepo(url="https://github.com/litex-hub/"), + + # OpenRISC CPU(s). + "pythondata-cpu-mor1kx": GitRepo(url="https://github.com/litex-hub/"), + "pythondata-cpu-marocchino": GitRepo(url="https://github.com/litex-hub/"), + + # OpenPower CPU(s). + "pythondata-cpu-microwatt": GitRepo(url="https://github.com/litex-hub/", sha1=0xc69953aff92), + + # RISC-V CPU(s). + "pythondata-cpu-blackparrot": GitRepo(url="https://github.com/litex-hub/"), + "pythondata-cpu-cv32e40p": GitRepo(url="https://github.com/litex-hub/", clone="recursive"), + "pythondata-cpu-cv32e41p": GitRepo(url="https://github.com/litex-hub/", clone="recursive"), + "pythondata-cpu-cva5": GitRepo(url="https://github.com/litex-hub/"), + "pythondata-cpu-cva6": GitRepo(url="https://github.com/litex-hub/", clone="recursive"), + "pythondata-cpu-ibex": GitRepo(url="https://github.com/litex-hub/", clone="recursive", sha1=0xd3d53df), + "pythondata-cpu-minerva": GitRepo(url="https://github.com/litex-hub/"), + "pythondata-cpu-naxriscv": GitRepo(url="https://github.com/litex-hub/", branch="smp"), + "pythondata-cpu-picorv32": GitRepo(url="https://github.com/litex-hub/"), + "pythondata-cpu-rocket": GitRepo(url="https://github.com/litex-hub/"), + "pythondata-cpu-serv": GitRepo(url="https://github.com/litex-hub/"), + "pythondata-cpu-vexriscv": GitRepo(url="https://github.com/litex-hub/"), + "pythondata-cpu-vexriscv-smp": GitRepo(url="https://github.com/litex-hub/", clone="recursive"), +} + +# Installs ----------------------------------------------------------------------------------------- + +# Minimal: Only Migen + LiteX. +minimal_repos = ["migen", "litex"] + +# Standard: Migen + LiteX + Cores + Software + Popular CPUs (LM32, Mor1kx, SERV, VexRiscv). +standard_repos = list(git_repos.keys()) +standard_repos.remove("pythondata-cpu-blackparrot") +standard_repos.remove("pythondata-cpu-cv32e40p") +standard_repos.remove("pythondata-cpu-cv32e41p") +standard_repos.remove("pythondata-cpu-cva5") +standard_repos.remove("pythondata-cpu-cva6") +standard_repos.remove("pythondata-cpu-ibex") +standard_repos.remove("pythondata-cpu-marocchino") +standard_repos.remove("pythondata-cpu-minerva") +standard_repos.remove("pythondata-cpu-microwatt") +standard_repos.remove("pythondata-cpu-picorv32") +standard_repos.remove("pythondata-cpu-rocket") + +# Full: Migen + LiteX + Cores + Software + All CPUs. +full_repos = list(git_repos.keys()) + +# Installs: +install_configs = { + "minimal" : minimal_repos, + "standard" : standard_repos, + "full" : full_repos, +} + +# Script location / auto-update -------------------------------------------------------------------- + +def litex_setup_location_check(): + # Check if script is executed inside a cloned LiteX repository or alongside? + if os.path.exists(".gitignore"): + global current_path + current_path = os.path.join(current_path, "../") + +def litex_setup_auto_update(): + litex_setup_url = "https://raw.githubusercontent.com/enjoy-digital/litex/master/litex_setup.py" + current_sha1 = hashlib.sha1(open(os.path.realpath(__file__)).read().encode("utf-8")).hexdigest() + print_status("LiteX Setup auto-update...") + try: + import requests + r = requests.get(litex_setup_url) + if r.status_code != 404: + upstream_sha1 = hashlib.sha1(r.content).hexdigest() + if current_sha1 != upstream_sha1: + print_status("LiteX Setup is obsolete, updating.") + with open(os.path.realpath(__file__), "wb") as f: + f.write(r.content) + os.execl(python3, python3, *sys.argv) + else: + print_status("LiteX Setup is up to date.") + except: + pass + +# Git helpers -------------------------------------------------------------------------------------- + +def git_checkout(sha1=None, tag=None): + assert not ((sha1 is None) and (tag is None)) + if sha1 is not None: + os.system(f"git checkout {sha1:07x}") + if tag is not None: + sha1_tag_cmd = ["git", "rev-list", "-n 1", tag] + sha1_tag = subprocess.check_output(sha1_tag_cmd).decode("UTF-8")[:-1] + os.system(f"git checkout {sha1_tag}") + +def git_tag(tag=None): + assert tag is not None + os.system(f"git tag {tag}") + os.system(f"git push --tags") + +# Git repositories initialization ------------------------------------------------------------------ + +def litex_setup_init_repos(config="standard", tag=None, dev_mode=False): + print_status("Initializing Git repositories...", underline=True) + for name in install_configs[config]: + repo = git_repos[name] + os.chdir(os.path.join(current_path)) + if not os.path.exists(name): + # Clone Repo. + print_status(f"Cloning {name} Git repository...") + repo_url = repo.url + if dev_mode: + repo_url = repo_url.replace("https://github.com/", "git@github.com:") + subprocess.check_call("git clone {url} {options}".format( + url = repo_url + name + ".git", + options = "--recursive" if repo.clone == "recursive" else "" + ), shell=True) + os.chdir(os.path.join(current_path, name)) + # Use specific Branch. + subprocess.check_call("git checkout " + repo.branch, shell=True) + # Use specific Tag (Optional). + if repo.tag is not None: + # Priority to passed tag (if specified). + if tag is not None: + git_checkout(tag=tag) + continue + # Else fallback to repo tag (if specified). + if isinstance(repo.tag, str): + git_checkout(tag=tag) + continue + # Use specific SHA1 (Optional). + if repo.sha1 is not None: + git_checkout(sha1=repo.sha1) + else: + print_status(f"{name} Git Repo already present.") + +# Git repositories update -------------------------------------------------------------------------- + +def litex_setup_update_repos(config="standard", tag=None): + print_status("Updating Git repositories...", underline=True) + for name in install_configs[config]: + repo = git_repos[name] + os.chdir(os.path.join(current_path)) + # Check if Repo is present. + if not os.path.exists(name): + print_error(f"{name} Git repository is not initialized, please run --init first.") + raise SetupError + # Update Repo. + print_status(f"Updating {name} Git repository...") + os.chdir(os.path.join(current_path, name)) + subprocess.check_call("git checkout " + repo.branch, shell=True) + subprocess.check_call("git pull --ff-only", shell=True) + # Recursive Update (Optional). + if repo.clone == "recursive": + subprocess.check_call("git submodule update --init --recursive", shell=True) + # Use specific Tag (Optional). + if repo.tag is not None: + # Priority to passed tag (if specified). + if tag is not None: + git_checkout(tag=tag) + continue + # Else fallback to repo tag (if specified). + if isinstance(repo.tag, str): + git_checkout(tag=tag) + continue + # Use specific SHA1 (Optional). + if repo.sha1 is not None: + git_checkout(sha1=repo.sha1) + +# Git repositories install ------------------------------------------------------------------------- + +def litex_setup_install_repos(config="standard", user_mode=False): + print_status("Installing Git repositories...", underline=True) + for name in install_configs[config]: + repo = git_repos[name] + os.chdir(os.path.join(current_path)) + # Install Repo. + if repo.develop: + print_status(f"Installing {name} Git repository...") + os.chdir(os.path.join(current_path, name)) + subprocess.check_call("\"{python3}\" -m pip install --editable . {options}".format( + python3 = sys.executable, + options = "--user" if user_mode else "", + ), shell=True) + if user_mode: + if ".local/bin" not in os.environ.get("PATH", ""): + print_status("Make sure that ~/.local/bin is in your PATH") + print_status("export PATH=$PATH:~/.local/bin # temporary (limited to the current terminal)") + print_status("or add the previous line into your ~/.bashrc to permanently update PATH") + +# Git repositories freeze -------------------------------------------------------------------------- + +def litex_setup_freeze_repos(config="standard"): + print_status("Freezing config of Git repositories...", underline=True) + r = "git_repos = {\n" + for name in install_configs[config]: + repo = git_repos[name] + os.chdir(os.path.join(current_path, name)) + git_sha1_cmd = ["git", "rev-parse", "--short=7", "HEAD"] + git_sha1 = subprocess.check_output(git_sha1_cmd).decode("UTF-8")[:-1] + git_url_cmd = ["git", "remote", "get-url", "origin"] + git_url = subprocess.check_output(git_url_cmd).decode("UTF-8")[:-1] + git_url = git_url.replace(f"{name}.git", "") + r += " "*4 + r += f'"{name}" : GitRepo(url="{git_url}",\n' + r += f'{" "*8}clone = "{repo.clone}",\n' + r += f'{" "*8}develop = {repo.develop},\n' + r += f'{" "*8}sha1 = 0x{git_sha1},\n' + r += f'{" "*8}branch = "{repo.branch}"' + r += f'\n{" "*4}),\n' + r += "}\n" + print(r) + +# Git repositories release ------------------------------------------------------------------------- + +def litex_setup_release_repos(tag): + print_status(f"Making release {tag}...", underline=True) + confirm = input("Please confirm by pressing Y:") + if confirm.upper() == "Y": + for name in install_configs["full"]: + if name in ["migen"]: + continue + repo = git_repos[name] + os.chdir(os.path.join(current_path, name)) + # Tag Repo. + print_status(f"Tagging {name} Git repository as {tag}...") + git_tag(tag=tag) + else: + print_status(f"Not confirmed, exiting.") + +# GCC toolchains install --------------------------------------------------------------------------- + +# RISC-V toolchain. +# ----------------- + +def riscv_gcc_install(): + # Linux. + # ------ + if sys.platform.startswith("linux"): + os_release = (open("/etc/os-release").read()).lower() + # Fedora. + if "fedora" in os_release: + os.system("dnf install gcc-riscv64-linux-gnu") + # Arch. + elif "arch" in os_release: + os.system("pacman -S riscv64-linux-gnu-gcc") + # Ubuntu. + else: + os.system("apt install gcc-riscv64-unknown-elf") + + # Mac OS. + # ------- + elif sys.platform.startswith("darwin"): + os.system("brew install riscv-tools") + + # Manual installation. + # -------------------- + else: + NotImplementedError(f"RISC-V GCC requires manual installation on {sys.platform}.") + +# PowerPC toolchain. +# ----------------- + +def powerpc_gcc_install(): + # Linux. + # ------ + if sys.platform.startswith("linux"): + os_release = (open("/etc/os-release").read()).lower() + # Fedora. + if "fedora" in os_release: + os.system("dnf install gcc-powerpc64le-linux-gnu") # FIXME: binutils-multiarch? + # Arch (AUR repository). + elif "arch" in os_release: + os.system("yay -S powerpc64le-linux-gnu-gcc") + # Ubuntu. + else: + os.system("apt install gcc-powerpc64le-linux-gnu binutils-multiarch") + + # Manual installation. + # -------------------- + else: + NotImplementedError(f"PowerPC GCC requires manual installation on {sys.platform}.") + +# OpenRISC toolchain. +# ------------------- + +def openrisc_gcc_install(): + # Linux. + # ------ + if sys.platform.startswith("linux"): + os_release = (open("/etc/os-release").read()).lower() + # Fedora. + if "fedora" in os_release: + os.system("dnf install gcc-or1k-elf") + # Arch. + elif "arch" in os_release: + os.system("pacman -S or1k-elf-gcc") + # Ubuntu. + else: + os.system("apt install gcc-or1k-elf") + + # Manual installation. + # -------------------- + else: + NotImplementedError(f"OpenRISC GCC requires manual installation on {sys.platform}.") + +# Run ---------------------------------------------------------------------------------------------- + +def main(): + print_banner() + parser = argparse.ArgumentParser() + + # Git Repositories. + parser.add_argument("--init", action="store_true", help="Initialize Git repositories.") + parser.add_argument("--update", action="store_true", help="Update Git repositories.") + parser.add_argument("--install", action="store_true", help="Install Git repositories.") + parser.add_argument("--user", action="store_true", help="Install in User-Mode.") + parser.add_argument("--config", default="standard", help="Install config (minimal, standard, full).") + parser.add_argument("--tag", default=None, help="Use version from release tag.") + + # GCC toolchains. + parser.add_argument("--gcc", default=None, help="Install GCC Toolchain (riscv, powerpc or openrisc).") + + # Development mode. + parser.add_argument("--dev", action="store_true", help="Development-Mode (no Auto-Update of litex_setup.py / Switch to git@github.com URLs).") + parser.add_argument("--freeze", action="store_true", help="Freeze and display current config.") + parser.add_argument("--release", default=None, help="Make release.") + + # Retro-compatibility. + parser.add_argument("compat_args", nargs="*", help="Retro-Compatibility arguments (init, update, install or gcc).") + args = parser.parse_args() + + # Handle compat_args. + if args.compat_args is not None: + for arg in args.compat_args: + if arg in ["init", "update", "install"]: + setattr(args, arg, True) + if arg in ["gcc"]: + args.gcc = "riscv" + + # Location/Auto-Update. + litex_setup_location_check() + if not args.dev: + litex_setup_auto_update() + + # Init. + if args.init: + ci_run = (os.environ.get("GITHUB_ACTIONS") == "true") + dev_mode = args.dev and (not ci_run) + litex_setup_init_repos(config=args.config, tag=args.tag, dev_mode=dev_mode) + + # Update. + if args.update: + litex_setup_update_repos(config=args.config, tag=args.tag) + + # Install. + if args.install: + litex_setup_install_repos(config=args.config, user_mode=args.user) + + # Freeze. + if args.freeze: + litex_setup_freeze_repos(config=args.config) + + # Release. + if args.release: + litex_setup_release_repos(tag=args.release) + + # GCC. + os.chdir(os.path.join(current_path)) + if args.gcc == "riscv": + riscv_gcc_install() + if args.gcc == "powerpc": + powerpc_gcc_install() + if args.gcc == "openrisc": + openrisc_gcc_install() + +if __name__ == "__main__": + main() + diff --git a/bin/bin/matlab b/bin/bin/matlab new file mode 100755 index 0000000..00fc29c --- /dev/null +++ b/bin/bin/matlab @@ -0,0 +1,10 @@ +#!/bin/bash + +# FOR openGL from arch wiki +export LD_PRELOAD=/usr/lib/libstdc++.so +export LD_LIBRARY_PATH=/usr/lib/xorg/modules/dri/ +#export _JAVA_AWT_WM_NONREPARENTING=1 + + +~/Programs/MATLAB/R2024a/bin/matlab "$@" + diff --git a/bin/bin/rofi-spellcheck.sh b/bin/bin/rofi-spellcheck.sh new file mode 100755 index 0000000..4094dde --- /dev/null +++ b/bin/bin/rofi-spellcheck.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# https://github.com/Fumon/rofi-spellcheck/blob/main/rofi-spellcheck.sh +# +#MIT License +#Copyright (c) 2022 Jade Bilkey + +#Permission is hereby granted, free of charge, to any person obtaining a copy +#of this software and associated documentation files (the "Software"), to deal +#in the Software without restriction, including without limitation the rights +#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +#copies of the Software, and to permit persons to whom the Software is +#furnished to do so, subject to the following conditions: + +#The above copyright notice and this permission notice shall be included in all +#copies or substantial portions of the Software. + +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +#SOFTWARE. +# Select "wayland" or "x11" +display_server="x11" + + +case $ROFI_RETV in + 0) + # Get Version + version=$(echo -en | enchant-2 -a) + echo -en "\0prompt\x1fspell\n\0message\x1f$version\n";; + 1) + if [ $display_server == "wayland" ]; then wl-copy $@ + elif [ $display_server == "x11" ]; then echo -en $@ | xclip -i -selection clipboard > /dev/null + else exit 1; fi ;; + 2) + + spell=$(echo -en $@ | LANG=en_US enchant-2 -a); + output=$(echo -en "$spell" | sed -E "/^@/d; /^$/d; s/&/&/g; s/^(.+): /\\\\0message\x1f\1\n/; s/\\*/\\\\0message\x1fCorrect!\n$@\n/; s/, /\n/g; "); + echo -en "$output";; +esac +exit 0 + diff --git a/bin/bin/set-custom-res.sh b/bin/bin/set-custom-res.sh new file mode 100755 index 0000000..0fa93f5 --- /dev/null +++ b/bin/bin/set-custom-res.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/guides/app_examples.html + +# Get params and set any defaults +width=${1:-1920} +height=${2:-1080} +refresh_rate=${3:-60} + +# You may need to adjust the scaling differently so the UI/text isn't too small / big +scale=${4:-1.0} + +# Get the name of the active display +connected_display_output=$(xrandr | grep " connected" | awk '{ print $1 }') +display_output=${5:-$connected_display_output} + +echo "Display:" "$display_output" + +# Get the modeline info from the 2nd row in the cvt output +modeline=$(cvt ${width} ${height} ${refresh_rate} | awk 'FNR == 2') +xrandr_mode_str=${modeline//Modeline \"*\" /} +mode_alias="${width}x${height}" + +echo "xrandr setting new mode ${mode_alias} ${xrandr_mode_str}" +xrandr --newmode ${mode_alias} ${xrandr_mode_str} +xrandr --addmode ${display_output} ${mode_alias} + +# Reset scaling +xrandr --output ${display_output} --scale 1 + +# Apply new xrandr mode +xrandr --output ${display_output} --primary --mode ${mode_alias} --pos 0x0 --rotate normal --scale ${scale} + +# Optional reset your wallpaper to fit to new resolution +# xwallpaper --zoom /path/to/wallpaper.png +# diff --git a/bin/bin/sunshine-setup.sh b/bin/bin/sunshine-setup.sh new file mode 100755 index 0000000..649d788 --- /dev/null +++ b/bin/bin/sunshine-setup.sh @@ -0,0 +1 @@ +chown lambda:lambda /dev/uinput diff --git a/bin/bin/sunshine.sh b/bin/bin/sunshine.sh new file mode 100755 index 0000000..bf6c4ab --- /dev/null +++ b/bin/bin/sunshine.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +export DISPLAY=:2 + +dpi=${1:-144} + +# Check existing X server +ps -e | grep X >/dev/null +[[ ${?} -ne 0 ]] && { + echo "DPI: ${dpi}" + echo "Xft.dpi: ${dpi}" > $HOME/.Xresources + echo "Starting X server" + startx &>/dev/null & + [[ ${?} -eq 0 ]] && { + echo "X server started successfully" + } || echo "X server failed to start" +} || echo "X server already running" + +# Give some time for X server to startup +sleep 3 + +# Check if sunshine is already running +ps -e | grep -e .*sunshine$ >/dev/null +[[ ${?} -ne 0 ]] && { + sudo ~/bin/sunshine-setup.sh + #sudo ~/bin/sunshine-setup.sh + echo "Starting Sunshine!" + sunshine > /dev/null & + [[ ${?} -eq 0 ]] && { + echo "Sunshine started successfully" + } || echo "Sunshine failed to start" +} || echo "Sunshine is already running" + +# Add any other Programs that you want to startup automatically +# e.g. +~/.fehbg +# steam &> /dev/null & +# firefox &> /dev/null & +# kdeconnect-app &> /dev/null & diff --git a/bin/bin/virtual-x11vnc.sh b/bin/bin/virtual-x11vnc.sh new file mode 100755 index 0000000..01659df --- /dev/null +++ b/bin/bin/virtual-x11vnc.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +## gtf output +#Modeline "2560x1600_60.00" 348.16 2560 2752 3032 3504 1600 1601 1604 1656 -HSync +Vsync + +mode=$(gtf 1600 2560 60 | grep Modeline | sed 's/\s*Modeline\s*//') +# mode = "2560x1600_60.00" 348.16 2560 2752 3032 3504 1600 1601 1604 1656 -HSync +Vsync + + +mode_string=$(echo "$mode" | sed -E 's/.*\"(.*)\".*/\1/g') +# mode_string = "2560x1600_60.00" + +echo "====================" +echo "$mode" +echo "$mode_string" +echo "====================" + +xrandr --newmode $(echo "$mode") +xrandr --addmode VIRTUAL1 "$mode_string" + +#xrandr --output VIRTUAL1 --mode "$mode_string" --below eDP1 +xrandr --output VIRTUAL1 --mode 1600x2560_60.00 --below eDP1 + + +x11vnc -clip 1600x2560+0+1080 -usepw -repeat +