From 3330dbda8f5cc50042e81fafdc8b23430b9089ed Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Tue, 20 Apr 2021 00:24:49 +0530 Subject: [PATCH] Intial scripts upload --- README.md | 3 ++- bluetooth-toogle | 10 +++++++ facebook-switch-to-desktop.user.js | 10 +++++++ firefox-local-auto-redirection-fix.user.js | 10 +++++++ latex-cleanup | 7 +++++ makebk | 9 +++++++ manjaro-forum-auto-redirect.user.js | 19 +++++++++++++ start-font-fix.sh | 7 +++++ totrash | 6 +++++ touch2 | 5 ++++ turbo-boost | 31 ++++++++++++++++++++++ turbo-boost-startup | 6 +++++ usb-autosuspend-fix | 7 +++++ wifi-toggle | 10 +++++++ 14 files changed, 139 insertions(+), 1 deletion(-) create mode 100755 bluetooth-toogle create mode 100644 facebook-switch-to-desktop.user.js create mode 100644 firefox-local-auto-redirection-fix.user.js create mode 100755 latex-cleanup create mode 100755 makebk create mode 100644 manjaro-forum-auto-redirect.user.js create mode 100755 start-font-fix.sh create mode 100755 totrash create mode 100755 touch2 create mode 100755 turbo-boost create mode 100755 turbo-boost-startup create mode 100755 usb-autosuspend-fix create mode 100755 wifi-toggle diff --git a/README.md b/README.md index 35a6ade..511a835 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Random Scripts -This repository is for random scripts I wrote mostly for personal use. If anyone else finds these useful, they're most welcome. +This repository is for random scripts I wrote mostly for personal use. +Although this is mostly for archival purposes, if anyone else finds these useful, they're most welcome. diff --git a/bluetooth-toogle b/bluetooth-toogle new file mode 100755 index 0000000..dfa09b6 --- /dev/null +++ b/bluetooth-toogle @@ -0,0 +1,10 @@ +# Toggles bluetooth on a Linux system. Make sure that you have bluetoothctl installed. +# I use it with a shortcut. + +#!/bin/bash + +if [ $(bluetoothctl show "A0:AF:BD:4F:D8:63" | grep Powered | grep -c yes) -eq 1 ]; then + bluetoothctl power off +else + bluetoothctl power on +fi diff --git a/facebook-switch-to-desktop.user.js b/facebook-switch-to-desktop.user.js new file mode 100644 index 0000000..66cf725 --- /dev/null +++ b/facebook-switch-to-desktop.user.js @@ -0,0 +1,10 @@ +// ==UserScript== +// @name Facebook Switch to Desktop +// @namespace Facebook +// @match *://m.facebook.com/* +// @grant none +// @version 1.2 +// @author SinTan +// @description 6/21/2020, 10:24:02 PM +// ==/UserScript== +window.location.href = window.location.href.replace("://m.", "://www.") \ No newline at end of file diff --git a/firefox-local-auto-redirection-fix.user.js b/firefox-local-auto-redirection-fix.user.js new file mode 100644 index 0000000..3767225 --- /dev/null +++ b/firefox-local-auto-redirection-fix.user.js @@ -0,0 +1,10 @@ +// ==UserScript== +// @name Firefox local auto-redirection fix +// @namespace Local +// @description A script for fixing the auto-redirection defined in local files in firefox +// @match file:///* +// @grant none +// @author SinTan +// @version 1.1 +// ==/UserScript== +window.location.href=document.getElementsByTagName("a")[0].href \ No newline at end of file diff --git a/latex-cleanup b/latex-cleanup new file mode 100755 index 0000000..37351bd --- /dev/null +++ b/latex-cleanup @@ -0,0 +1,7 @@ +# I use it to clean up latex build files from a directory after I'm done with the project. + +#!/bin/bash + +[ 0 -lt $(ls *.tex 2>/dev/null | wc -w) ] && find . -maxdepth 1 -type f -regex ".*\.\(aux\|log\|synctex.gz\|bbl\|blg\)" -exec totrash {} \; +echo "Done!" + diff --git a/makebk b/makebk new file mode 100755 index 0000000..2da5ee0 --- /dev/null +++ b/makebk @@ -0,0 +1,9 @@ +# This simply makes a backup of a file as filename.bak + +#!/bin/bash + +if [[ -n "$1" ]]; +then + cp "$1"{,.bak} +fi + diff --git a/manjaro-forum-auto-redirect.user.js b/manjaro-forum-auto-redirect.user.js new file mode 100644 index 0000000..a939a9c --- /dev/null +++ b/manjaro-forum-auto-redirect.user.js @@ -0,0 +1,19 @@ +// ==UserScript== +// @name Manjaro Forum auto-redirect to old site for missing pages +// @namespace Manjaro Linux Forum +// @match https://forum.manjaro.org/t/* +// @grant none +// @version 1.1 +// @author SinTan +// @description 9/4/2020, 1:36:13 PM +// ==/UserScript== +not_found = document.getElementsByClassName("page-not-found") +if (not_found) { + error_msg = not_found[0].getElementsByClassName("title")[0].innerHTML + if (error_msg == "Oops! That page doesn’t exist or is private.") { + redir_notif = document.createElement("h3") + redir_notif.innerHTML = "(Redirecting to old forum...)" + not_found[0].appendChild(redir_notif) + window.location.href = window.location.href.replace("://forum.", "://archived.forum.") + } +} \ No newline at end of file diff --git a/start-font-fix.sh b/start-font-fix.sh new file mode 100755 index 0000000..965cf5c --- /dev/null +++ b/start-font-fix.sh @@ -0,0 +1,7 @@ +# This was to fix an issue I was having where my terminal fonts were all over the place and tlp was autosuspending usb ports at startup. +# Anyone else probably won't need it. + +#! /bin/sh + +source ~/.profile +sudo ~/.local/bin/personal/usb-autosuspend-fix diff --git a/totrash b/totrash new file mode 100755 index 0000000..159ac10 --- /dev/null +++ b/totrash @@ -0,0 +1,6 @@ +# It simply moves files to trash:/ in KDE + +#!/bin/bash + +# Move files to trash:/ +kioclient5 move "$@" trash:/ diff --git a/touch2 b/touch2 new file mode 100755 index 0000000..90fc347 --- /dev/null +++ b/touch2 @@ -0,0 +1,5 @@ +# It makes the parent folders (if needed) while touch-ing. + +#!/bin/bash +mkdir -p "$(dirname "$1")" && + touch "$1" diff --git a/turbo-boost b/turbo-boost new file mode 100755 index 0000000..d7b6aa4 --- /dev/null +++ b/turbo-boost @@ -0,0 +1,31 @@ +# This is to toggle intel turbo boost. + +#!/bin/bash + +if [[ -z $(which rdmsr) ]]; then + echo "msr-tools is not installed. Run 'sudo apt-get install msr-tools' to install it." >&2 + exit 1 +fi + +if [[ ! -z $1 && $1 != "enable" && $1 != "disable" ]]; then + echo "Invalid argument: $1" >&2 + echo "" + echo "Usage: $(basename $0) [disable|enable]" + exit 1 +fi + +cores=$(cat /proc/cpuinfo | grep processor | awk '{print $3}') +for core in $cores; do + if [[ $1 == "disable" ]]; then + sudo wrmsr -p${core} 0x1a0 0x4000850089 + fi + if [[ $1 == "enable" ]]; then + sudo wrmsr -p${core} 0x1a0 0x850089 + fi + state=$(sudo rdmsr -p${core} 0x1a0 -f 38:38) + if [[ $state -eq 1 ]]; then + echo "core ${core}: disabled" + else + echo "core ${core}: enabled" + fi +done diff --git a/turbo-boost-startup b/turbo-boost-startup new file mode 100755 index 0000000..8f66bbf --- /dev/null +++ b/turbo-boost-startup @@ -0,0 +1,6 @@ +# This simply triggers the turbo-boost script at startup. +# I use it as a startup script. + +#!/bin/bash + +~/.local/bin/turbo-boost disable diff --git a/usb-autosuspend-fix b/usb-autosuspend-fix new file mode 100755 index 0000000..09d4cfe --- /dev/null +++ b/usb-autosuspend-fix @@ -0,0 +1,7 @@ +# This was to fix an issue where tlp was autosuspending usb ports at startup. + +#!/bin/sh + +echo 'on' > '/sys/bus/usb/devices/1-1/power/control' +echo 'on' > '/sys/bus/usb/devices/1-2/power/control' +echo 'on' > '/sys/bus/usb/devices/1-3/power/control' diff --git a/wifi-toggle b/wifi-toggle new file mode 100755 index 0000000..d13cd20 --- /dev/null +++ b/wifi-toggle @@ -0,0 +1,10 @@ +# Toggles WiFi on a Linux system. Make sure that you have nmcli installed. +# I use it with a shortcut. + +#!/bin/bash + +if [ $(nmcli r wifi | grep -c enabled) -eq 1 ]; then + nmcli r wifi off +else + nmcli r wifi on +fi