From 46ba941d0e3df93c243429551bd5101b0c1c172e Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 8 Mar 2023 18:09:07 +0800 Subject: update --- autofuck.sh | 7 +++ autostart | 10 ++++ backgroundblur | 5 ++ cleanfullscreen | 97 ++++++++++++++++++++++++++++++++++ debinstall | 3 ++ extract-from-app-image | 1 + ga | 6 +++ gccd | 7 +++ gcco | 7 +++ hidetophoto | 2 + installmod | 7 +++ path | 1 + pipreqsi | 1 + playbannedmod | 2 + randomimage.sh | 3 ++ reflector.sh | 6 +++ sleep_program | 33 ++++++++++++ spotify.script | 141 +++++++++++++++++++++++++++++++++++++++++++++++++ squashfs-extract | 1 + ufetch | 83 +++++++++++++++++++++++++++++ unhidefromphoto | 2 + vim | 64 ++++++++++++++++++++++ vimake | 3 ++ 23 files changed, 492 insertions(+) create mode 100755 autofuck.sh create mode 100755 autostart create mode 100755 backgroundblur create mode 100755 cleanfullscreen create mode 100755 debinstall create mode 100755 extract-from-app-image create mode 100755 ga create mode 100755 gccd create mode 100755 gcco create mode 100755 hidetophoto create mode 100755 installmod create mode 100755 path create mode 100755 pipreqsi create mode 100755 playbannedmod create mode 100755 randomimage.sh create mode 100755 reflector.sh create mode 100755 sleep_program create mode 100755 spotify.script create mode 100755 squashfs-extract create mode 100755 ufetch create mode 100755 unhidefromphoto create mode 100755 vim create mode 100755 vimake diff --git a/autofuck.sh b/autofuck.sh new file mode 100755 index 0000000..fc69050 --- /dev/null +++ b/autofuck.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +$@ +if [ $? -eq 0 ]; then + echo "git status exited successfully" +else + echo "git status exited with error code" +fi diff --git a/autostart b/autostart new file mode 100755 index 0000000..98edf23 --- /dev/null +++ b/autostart @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +#ln -s /mnt/DATA ~/DATA +#ln -s /mnt/DATA/Code ~/Code +#ln -s /mnt/DATA/Code/Random ~/Random +#ln -s /mnt/DATA/Games ~/Games +#ln -s /mnt/DATA/Applications ~/Applications +#ln -s /mnt/DATA/Downloads ~/Downloads + +#rm -rf ~/Downloads/* + diff --git a/backgroundblur b/backgroundblur new file mode 100755 index 0000000..b14a566 --- /dev/null +++ b/backgroundblur @@ -0,0 +1,5 @@ +#!/bin/sh +while true; do + $HOME/.config/bspwm/scripts/backgroundblur -i $(shuf -n 1 -e $(find /home/system/Pictures/wallpapers) | head -n 1) & + sleep 1800 +done diff --git a/cleanfullscreen b/cleanfullscreen new file mode 100755 index 0000000..0e94ad8 --- /dev/null +++ b/cleanfullscreen @@ -0,0 +1,97 @@ +#!/bin/sh +# Clean fullscreen aims to provide a means to have a clean desktop when using +# transparency in bspwm, the issue I found was that when a window entered, +# fullscreen mode I was still able to see the windows behind it, I think this +# looks kind of gross so that's why this exists. + +HideBar() { + polybar-msg cmd hide +} + +ShowBar() { + polybar-msg cmd show +} + +HideNodes() { + for node in $1; do + bspc node "$node" -g hidden=on + done +} + +HideTiled() { + Nodes=$(bspc query -N -n .tiled -d "$1") + HideNodes "$Nodes" +} + +ShowNodes() { + Nodes=$(bspc query -N -n .hidden -d "$1") + + for node in $Nodes; do + bspc node "$node" -g hidden=off + done +} + +bspc subscribe node_state | while read -r Event Monitor Desktop Node State Active +do + PrimaryMonitor=$(bspc query -M -m primary) + # Hide bar and nodes when node becomes fullscreen, otherwise show + if [ "$State" = "fullscreen" ] && [ "$Active" = "on" ]; then + # Only consider nodes on primary monitor + if [ "$PrimaryMonitor" = "$Monitor" ]; then + HideBar + fi + HideTiled "$Desktop" + else + if [ "$PrimaryMonitor" = "$Monitor" ]; then + ShowBar + fi + ShowNodes "$Desktop" + fi +done & + +bspc subscribe node_remove | while read Event Monitor Desktop Node +do + PrimaryMonitor="$(bspc query -M -m primary)" + + # Show bar if no nodes are fullscreen on current desktop + if [ "$Monitor" = "$PrimaryMonitor" ] && \ + [ -z "$(bspc query -N -n .fullscreen -d "$Desktop")" ]; then + ShowBar + fi + ShowNodes "$Desktop" +done & + +bspc subscribe node_transfer | while read -r Event SrcMonitor SrcDesktop SrcNode DestMonitor Dest Desktop DestNode +do + # Show nodes on src desktop and hide nodes on dest desktop + # If src node is in full screen mode + if [ -n "$(bspc query -N -n "$SrcNode".fullscreen)" ]; then + ShowNodes "$SrcDesktop" + HideTiled "$DestDesktop" + ShowBar + fi + + # Hide any fullscreen nodes on destination desktop + FullscreenDest=$(bspc query -N -n .fullscreen -d "$DestDesktop" \ + | sed "/$SrcNode/d") + if [ -n "$FullscreenDest" ]; then + HideNodes "$FullscreenDest" + fi +done & + +bspc subscribe desktop_focus | while read -r Event Monitor Desktop +do + PrimaryMonitor="$(bspc query -M -m primary)" + FullscreenNode="$(bspc query -N -n .fullscreen -d "$Desktop")" + + # Only consider nodes on primary monitor + if [ "$PrimaryMonitor" = "$Monitor" ]; then + # Hide bar if desktop contains fullscreen node + if [ -n "$FullscreenNode" ]; then + HideBar + # Otherwise show the bar + else + ShowBar + fi + fi +done & diff --git a/debinstall b/debinstall new file mode 100755 index 0000000..a9276a0 --- /dev/null +++ b/debinstall @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +debtap ${1} +sudo /usr/bin/pacman -U ${1}*.pkg.tar.zst diff --git a/extract-from-app-image b/extract-from-app-image new file mode 100755 index 0000000..1566202 --- /dev/null +++ b/extract-from-app-image @@ -0,0 +1 @@ +./$1 -appimage-extract diff --git a/ga b/ga new file mode 100755 index 0000000..8484eb5 --- /dev/null +++ b/ga @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +if [[ -n "${1+x}" ]]; then + git add $1 -f +else + git add . -f +fi diff --git a/gccd b/gccd new file mode 100755 index 0000000..ddac492 --- /dev/null +++ b/gccd @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +if [ -n "${2+x}" ]; then + gcc -Wall -Wextra -std=c11 -g -c $1 -o $2 +else + gcc -Wall -Wextra -std=c11 -g -c $1 -o ${1%.*}.o +fi + diff --git a/gcco b/gcco new file mode 100755 index 0000000..699deb6 --- /dev/null +++ b/gcco @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +if [ -n "${2+x}" ]; then + gcc -Wall -Wextra -std=c11 -g $1 -o $2 +else + gcc -Wall -Wextra -std=c11 -g $1 -o ${1%.*}.o +fi + diff --git a/hidetophoto b/hidetophoto new file mode 100755 index 0000000..875b98c --- /dev/null +++ b/hidetophoto @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +[[ -v "$1" ]] && [[ -v "$2" ]] && steghide embed -cd $1 -ef $2 || printf "Usage: \n\t$(basename "$0") " diff --git a/installmod b/installmod new file mode 100755 index 0000000..77d3929 --- /dev/null +++ b/installmod @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if [ -e "$1" ]; then + cp $1 "$HOME/Games/Minecraft(Mod)/Normal-Fabric/mods/" && rm "$1" && echo "Install Successed!" +else + echo "$1: file does not exist" +fi diff --git a/path b/path new file mode 100755 index 0000000..57db961 --- /dev/null +++ b/path @@ -0,0 +1 @@ +echo "$(pwd)/${1}" diff --git a/pipreqsi b/pipreqsi new file mode 100755 index 0000000..f6a0d65 --- /dev/null +++ b/pipreqsi @@ -0,0 +1 @@ +pip install -r requirements.txt diff --git a/playbannedmod b/playbannedmod new file mode 100755 index 0000000..3de0d8c --- /dev/null +++ b/playbannedmod @@ -0,0 +1,2 @@ +#!/usr/bin/bash +rm -rf ~/Games/Minecraft\(Mod\)/Banned-Mods.tmp && cp -r ~/Games/Minecraft\(Mod\)/Normal-Fabric/ ~/Games/Minecraft\(Mod\)/Banned-Mods.tmp && cp ~/Games/Minecraft\(Mod\)/Banned-Mods/* ~/Games/Minecraft\(Mod\)/Banned-Mods.tmp/mods/ && echo && echo "install sussfull!" && echo "Please add a new profile in minecraft launcher, directory copied in clipboard" && echo "~/Games/Minecraft\(Mod\)/Banned-Mods.tmp" | xclip -selection clipboard; echo && echo "~/Games/Minecraft\(Mod\)/Banned-Mods.tmp" && $SHELL && rm -rf ~/Games/Minecraft\(Mod\)/Banned-Mods.tmp diff --git a/randomimage.sh b/randomimage.sh new file mode 100755 index 0000000..bb18b7e --- /dev/null +++ b/randomimage.sh @@ -0,0 +1,3 @@ +# Select a random file name from the list +random_file=$(shuf -n 1 -e $(find /home/system/Pictures/wallpapers) | head -n 1) +echo $random_file diff --git a/reflector.sh b/reflector.sh new file mode 100755 index 0000000..524994b --- /dev/null +++ b/reflector.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh +while true; do + sudo /usr/bin/reflector @/etc/xdg/reflector/reflector.conf + update + sleep 1080 +done diff --git a/sleep_program b/sleep_program new file mode 100755 index 0000000..128d9a5 --- /dev/null +++ b/sleep_program @@ -0,0 +1,33 @@ +#!/usr/bin/bash + +suspend () +{ + killall -STOP "$1" > /dev/null 2>&1 & +} + +resume () +{ + killall -CONT "$1" > /dev/null 2>&1 & +} + +stop () +{ + suspend caja + suspend Discord + suspend code + suspend chat-gpt + suspend backgroundblur + killall -15 brave > /dev/null 2>&1 || nobrave=true +} + +cont () +{ + if [[ $nobrave = true ]]; then + setsid brave --restore-last-session > /dev/null 2>&1 & + fi + resume chat-gpt + resume code + resume Discord + resume caja + resume backgroundblur +} diff --git a/spotify.script b/spotify.script new file mode 100755 index 0000000..7199f4e --- /dev/null +++ b/spotify.script @@ -0,0 +1,141 @@ +#!/usr/bin/env python + +import sys +import dbus +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument( + '-t', + '--trunclen', + type=int, + metavar='trunclen' +) +parser.add_argument( + '-f', + '--format', + type=str, + metavar='custom format', + dest='custom_format' +) +parser.add_argument( + '-p', + '--playpause', + type=str, + metavar='play-pause indicator', + dest='play_pause' +) +parser.add_argument( + '--font', + type=str, + metavar='the index of the font to use for the main label', + dest='font' +) +parser.add_argument( + '--playpause-font', + type=str, + metavar='the index of the font to use to display the playpause indicator', + dest='play_pause_font' +) +parser.add_argument( + '-q', + '--quiet', + action='store_true', + help="if set, don't show any output when the current song is paused", + dest='quiet', +) + +args = parser.parse_args() + + +def fix_string(string): + # corrects encoding for the python version used + if sys.version_info.major == 3: + return string + else: + return string.encode('utf-8') + + +def truncate(name, trunclen): + if len(name) > trunclen: + name = name[:trunclen] + name += '...' + if ('(' in name) and (')' not in name): + name += ')' + return name + + + +# Default parameters +output = fix_string(u'{play_pause} {artist}: {song}') +trunclen = 35 +play_pause = fix_string(u'\u25B6,\u23F8') # first character is play, second is paused + +label_with_font = '%{{T{font}}}{label}%{{T-}}' +font = args.font +play_pause_font = args.play_pause_font + +quiet = args.quiet + +# parameters can be overwritten by args +if args.trunclen is not None: + trunclen = args.trunclen +if args.custom_format is not None: + output = args.custom_format +if args.play_pause is not None: + play_pause = args.play_pause + +try: + session_bus = dbus.SessionBus() + spotify_bus = session_bus.get_object( + 'org.mpris.MediaPlayer2.spotify', + '/org/mpris/MediaPlayer2' + ) + + spotify_properties = dbus.Interface( + spotify_bus, + 'org.freedesktop.DBus.Properties' + ) + + metadata = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'Metadata') + status = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus') + + # Handle play/pause label + + play_pause = play_pause.split(',') + + if status == 'Playing': + play_pause = play_pause[0] + elif status == 'Paused': + play_pause = play_pause[1] + else: + play_pause = str() + + if play_pause_font: + play_pause = label_with_font.format(font=play_pause_font, label=play_pause) + + # Handle main label + + artist = fix_string(metadata['xesam:artist'][0]) if metadata['xesam:artist'] else '' + song = fix_string(metadata['xesam:title']) if metadata['xesam:title'] else '' + album = fix_string(metadata['xesam:album']) if metadata['xesam:album'] else '' + + if (quiet and status == 'Paused') or (not artist and not song and not album): + print('') + else: + if font: + artist = label_with_font.format(font=font, label=artist) + song = label_with_font.format(font=font, label=song) + album = label_with_font.format(font=font, label=album) + + # Add 4 to trunclen to account for status symbol, spaces, and other padding characters + print(truncate(output.format(artist=artist, + song=song, + play_pause=play_pause, + album=album), trunclen + 4)) + +except Exception as e: + if isinstance(e, dbus.exceptions.DBusException): + print('') + else: + print(e) diff --git a/squashfs-extract b/squashfs-extract new file mode 100755 index 0000000..c0ec96d --- /dev/null +++ b/squashfs-extract @@ -0,0 +1 @@ +./${1} --appimage-extract diff --git a/ufetch b/ufetch new file mode 100755 index 0000000..b31bc09 --- /dev/null +++ b/ufetch @@ -0,0 +1,83 @@ +#!/bin/zsh +# +# ufetch-arch - tiny system info for arch + +## INFO + +# user is already defined +host="$(cat /etc/hostname)" +os='Arch Linux' +kernel="$(uname -sr)" +uptime="$(uptime -p | sed 's/up //')" +packages="$(pacman -Q | wc -l)" +shell="$(basename "${SHELL}")" + +## UI DETECTION + +parse_rcs() { + for f in "${@}"; do + wm="$(tail -n 1 "${f}" 2> /dev/null | cut -d ' ' -f 2)" + [ -n "${wm}" ] && echo "${wm}" && return + done +} + +rcwm="$(parse_rcs "${HOME}/.xinitrc" "${HOME}/.xsession")" + +ui='unknown' +uitype='UI' +if [ -n "${DE}" ]; then + ui="${DE}" + uitype='DE' +elif [ -n "${WM}" ]; then + ui="${WM}" + uitype='WM' +elif [ -n "${XDG_CURRENT_DESKTOP}" ]; then + ui="${XDG_CURRENT_DESKTOP}" + uitype='DE' +elif [ -n "${DESKTOP_SESSION}" ]; then + ui="${DESKTOP_SESSION}" + uitype='DE' +elif [ -n "${rcwm}" ]; then + ui="${rcwm}" + uitype='WM' +elif [ -n "${XDG_SESSION_TYPE}" ]; then + ui="${XDG_SESSION_TYPE}" +fi + +ui="$(basename "${ui}")" + +## DEFINE COLORS + +# probably don't change these +if [ -x "$(command -v tput)" ]; then + bold="$(tput bold 2> /dev/null)" + black="$(tput setaf 0 2> /dev/null)" + red="$(tput setaf 1 2> /dev/null)" + green="$(tput setaf 2 2> /dev/null)" + yellow="$(tput setaf 3 2> /dev/null)" + blue="$(tput setaf 4 2> /dev/null)" + magenta="$(tput setaf 5 2> /dev/null)" + cyan="$(tput setaf 6 2> /dev/null)" + white="$(tput setaf 7 2> /dev/null)" + reset="$(tput sgr0 2> /dev/null)" +fi + +# you can change these +lc="${reset}${bold}${blue}" # labels +nc="${reset}${bold}${blue}" # user and hostname +ic="${reset}" # info +c0="${reset}${blue}" # first color + +## OUTPUT + +cat <" diff --git a/vim b/vim new file mode 100755 index 0000000..b6e8392 --- /dev/null +++ b/vim @@ -0,0 +1,64 @@ +#!/bin/bash +#=============================================================================== +# +# FILE: edit.sh +# +# USAGE: ./edit.sh +# +# DESCRIPTION: Simple script that runs editor as sudo if necessary. +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Chevalier de Balibari (chevalierdebalibari@keemail.me), +# ORGANIZATION: --- +# CREATED: 04/11/2019 09:22:29 AM +# REVISION: --- +#=============================================================================== + +#set default editor +if [ -z $VIM_PATH ]; then + VIM_PATH=/usr/bin/lvim +fi + +#check if an argument is provided +if [ -z $1 ] +then + #open editor only, no argument is provided + $VIM_PATH +else + #test if file exists + if [ ! -f $1 ] + then + #file don't exist, destination folder permissions apply + FILE_PATH=$1 + DESTINATION_FOLDER_PATH=${FILE_PATH%/*} + #test if path or filename is provided + if [ $FILE_PATH == $DESTINATION_FOLDER_PATH ] + then + #destination folder path is current working directory + DESTINATION_FOLDER_PATH=$PWD + fi + #check if destination folder is writable by user + if [ -w $DESTINATION_FOLDER_PATH ] + then + #open editor as ordinary user + $VIM_PATH $FILE_PATH + else + #open editor as sudo user + sudo $VIM_PATH $FILE_PATH + fi + #file exists, file permissions apply + else + if [ -w $1 ] + then + #open editor as ordinary user + $VIM_PATH $1 + else + #open editor as sudo user + sudo $VIM_PATH $1 + fi + fi +fi + diff --git a/vimake b/vimake new file mode 100755 index 0000000..124ab7e --- /dev/null +++ b/vimake @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +vim Makefile -- cgit v1.2.3