From 652b9822e934242d238619a92ec9dd37a7dd51de Mon Sep 17 00:00:00 2001 From: Lucas Barbieri Date: Tue, 16 Jan 2024 10:08:31 -0300 Subject: [PATCH] add all scripts i really use --- desktop/configs/scripts/animations.sh | 14 ++ desktop/configs/scripts/elash.sh | 112 ++++++++++++ desktop/configs/scripts/fix.sh | 8 + desktop/configs/scripts/init.sh | 18 ++ desktop/configs/scripts/macro.sh | 27 +++ desktop/configs/scripts/screenlayout.sh | 2 +- desktop/configs/scripts/sfp.sh | 12 ++ desktop/configs/scripts/swww.sh | 9 + desktop/configs/scripts/volume_brightness.sh | 179 +++++++++++++++++++ desktop/configs/scripts/weechat.sh | 1 + 10 files changed, 381 insertions(+), 1 deletion(-) create mode 100755 desktop/configs/scripts/animations.sh create mode 100755 desktop/configs/scripts/elash.sh create mode 100755 desktop/configs/scripts/fix.sh create mode 100755 desktop/configs/scripts/init.sh create mode 100755 desktop/configs/scripts/macro.sh create mode 100755 desktop/configs/scripts/sfp.sh create mode 100755 desktop/configs/scripts/swww.sh create mode 100755 desktop/configs/scripts/volume_brightness.sh create mode 100755 desktop/configs/scripts/weechat.sh diff --git a/desktop/configs/scripts/animations.sh b/desktop/configs/scripts/animations.sh new file mode 100755 index 0000000..252a991 --- /dev/null +++ b/desktop/configs/scripts/animations.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh +HYPRGAMEMODE=$(hyprctl getoption animations:enabled | awk 'NR==2{print $2}') +if [ "$HYPRGAMEMODE" = 1 ] ; then + hyprctl --batch "\ + keyword animations:enabled 0;\ + keyword decoration:drop_shadow 0;\ + keyword decoration:blur:enabled 0;\ + keyword general:gaps_in 0;\ + keyword general:gaps_out 0;\ + keyword general:border_size 1;\ + keyword decoration:rounding 0" + exit +fi +hyprctl reload diff --git a/desktop/configs/scripts/elash.sh b/desktop/configs/scripts/elash.sh new file mode 100755 index 0000000..fe9a490 --- /dev/null +++ b/desktop/configs/scripts/elash.sh @@ -0,0 +1,112 @@ +#!/bin/sh + +## Change following to '0' for output to be like ls and '1' for exa features +# Don't list implied . and .. by default with -a +dot=0 +# Show human readable file sizes by default +hru=1 +# Show file sizes in decimal (1KB=1000 bytes) as opposed to binary units (1KiB=1024 bytes) +meb=0 +# Don't show group column +fgp=0 +# Don't show hardlinks column +lnk=0 +# Show file git status automatically (can cause a slight delay in large repo trees) +git=1 +# Show icons +ico=1 +# Show column headers +hed=0 +# Group directories first in long listing by default +gpd=1 +# Colour always even when piping (can be disabled with -N switch when not wanted) +col=1 + +help() { + cat << EOF + ${0##*/} options: + -a all + -A almost all + -1 one file per line + -x list by lines, not columns + -l long listing format + -G display entries as a grid * + -k bytes + -h human readable file sizes + -F classify + -R recurse + -r reverse + -d don't list directory contents + -D directories only * + -M group directories first * + -I ignore [GLOBS] + -i show inodes + -o show octal permissions * + -N no colour * + -S sort by file size + -t sort by modified time + -u sort by accessed time + -U sort by created time * + -X sort by extension + -T tree * + -L level [DEPTH] * + -s file system blocks + -g don't show/show file git status * + -n ignore .gitignore files * + -b file sizes in binary/decimal (--si in ls) + -@ extended attributes and sizes * + + * not used in ls +EOF + exit +} + +[[ "$*" =~ --help ]] && help + +exa_opts=() + +while getopts ':aAbtuUSI:rkhnsXL:MNg1lFGRdDioTx@' arg; do + case $arg in + a) (( dot == 1 )) && exa_opts+=(-a) || exa_opts+=(-a -a) ;; + A) exa_opts+=(-a) ;; + t) exa_opts+=(-s modified); ((++rev)) ;; + u) exa_opts+=(-us accessed); ((++rev)) ;; + U) exa_opts+=(-Us created); ((++rev)) ;; + S) exa_opts+=(-s size); ((++rev)) ;; + I) exa_opts+=(--ignore-glob="${OPTARG}") ;; + r) ((++rev)) ;; + k) ((--hru)) ;; + h) ((++hru)) ;; + n) exa_opts+=(--git-ignore) ;; + s) exa_opts+=(-S) ;; + X) exa_opts+=(-s extension) ;; + L) exa_opts+=(--level="${OPTARG}") ;; + o) exa_opts+=(--octal-permissions) ;; + M) ((++gpd)) ;; + N) ((++nco)) ;; + g) ((++git)) ;; + b) ((--meb)) ;; + 1|l|F|G|R|d|D|i|T|x|@) exa_opts+=(-"$arg") ;; + :) printf "%s: -%s switch requires a value\n" "${0##*/}" "${OPTARG}" >&2; exit 1 + ;; + *) printf "Error: %s\n --help for help\n" "${0##*/}" >&2; exit 1 + ;; + esac +done + +shift "$((OPTIND - 1))" + +(( rev == 1 )) && exa_opts+=(-r) +(( fgp == 0 )) && exa_opts+=(-g) +(( lnk == 0 )) && exa_opts+=(-H) +(( hru <= 0 )) && exa_opts+=(-B) +(( hed == 1 )) && exa_opts+=(-h) +(( meb == 0 && hru > 0 )) && exa_opts+=(-b) +(( col == 1 )) && exa_opts+=(--color=always) || exa_opts+=(--color=auto) +(( nco == 1 )) && exa_opts+=(--color=never) +(( gpd >= 1 )) && exa_opts+=(--group-directories-first) +(( ico == 1 )) && exa_opts+=(--icons) +(( git == 1 )) && \ + [[ $(git -C "${*:-.}" rev-parse --is-inside-work-tree) == true ]] 2>/dev/null && exa_opts+=(--git) + +eza --color-scale all "${exa_opts[@]}" "$@" diff --git a/desktop/configs/scripts/fix.sh b/desktop/configs/scripts/fix.sh new file mode 100755 index 0000000..e3e913c --- /dev/null +++ b/desktop/configs/scripts/fix.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +sleep 2 +pkill -f /usr/libexec/xdg-desktop-portal\* +sleep 1 +/usr/libexec/xdg-desktop-portal-hyprland & +sleep 1 +exec /usr/libexec/xdg-desktop-portal diff --git a/desktop/configs/scripts/init.sh b/desktop/configs/scripts/init.sh new file mode 100755 index 0000000..4eac54b --- /dev/null +++ b/desktop/configs/scripts/init.sh @@ -0,0 +1,18 @@ +#!/bin/bash +sh ~/screenlayout.sh +gentoo-pipewire-launcher & +spotifyd & +setxkbmap -option ctrl:nocaps br abnt2 +xinput --set-prop 'pointer:''Gaming Mouse' 'libinput Accel Profile Enabled' 0, 1 && xinput --set-prop 'pointer:''Gaming Mouse' 'libinput Accel Speed' 0.5 +dunst & +lxqt-policykit-agent & +touch ~/tmp/touchy && rm -rf ~/tmp/* +otd & +gsettings set org.gnome.desktop.interface icon-theme Win10Sur-black-dark & gsettings set org.gnome.desktop.interface gtk-theme Numix-BLACK-Pomegranate & gsettings set org.gnome.desktop.interface cursor-theme Simp1e +corectrl --minimize-systray & +gammastep -t 4500:3500 -l -23.5475:-46.63611 -b 1.0:0.5 & + +xset -dpms +setterm -blank 0 -powerdown 0 + +xset s off diff --git a/desktop/configs/scripts/macro.sh b/desktop/configs/scripts/macro.sh new file mode 100755 index 0000000..32c625e --- /dev/null +++ b/desktop/configs/scripts/macro.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +running="/tmp/running" +if [ -f "$running" ]; then + pid=$(cat "$running") + kill $pid + rm "$running" +else + while true; do + # spam e + # xdotool keydown ctrl ; xdotool keyup ctrl + # xdotool keydown e + # xdotool keyup e + + # glaive + # xdotool keydown e + # sleep 1.1 + # xdotool keyup e + # sleep 0.3 + # xdotool click 2 + # sleep 0.2 + xdotool click 1 + sleep 1 + +done & +echo "$!" >"$running" +fi diff --git a/desktop/configs/scripts/screenlayout.sh b/desktop/configs/scripts/screenlayout.sh index 253ecb3..f3d486e 100755 --- a/desktop/configs/scripts/screenlayout.sh +++ b/desktop/configs/scripts/screenlayout.sh @@ -1,2 +1,2 @@ #!/bin/sh -xrandr --output DVI-D-0 --off --output HDMI-0 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DP-0 --off --output DP-1 --mode 1920x1080 --pos 1920x148 --rotate normal +xrandr --output DisplayPort-0 --off --output DisplayPort-1 --off --output DisplayPort-2 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-A-0 --mode 1920x1080 --pos 1920x0 --rotate normal diff --git a/desktop/configs/scripts/sfp.sh b/desktop/configs/scripts/sfp.sh new file mode 100755 index 0000000..a43172c --- /dev/null +++ b/desktop/configs/scripts/sfp.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +sfp="/tmp/sfp" +if [ -f "$sfp" ]; then + rm $sfp +else + /yang/docs/SFP_UI-linux-x64-SelfContained/SFP_UI & + echo "$!" > "$sfp" + sleep 1 +fi +steam --noverifyfiles -cef-enable-debugging & + diff --git a/desktop/configs/scripts/swww.sh b/desktop/configs/scripts/swww.sh new file mode 100755 index 0000000..eb4226c --- /dev/null +++ b/desktop/configs/scripts/swww.sh @@ -0,0 +1,9 @@ +#!/bin/sh +SWWW_TRANSITION_STEP=1 +SWWW_TRANSITION_FPS=60 +SWWW_TRANSITION="grow" + +swww-daemon & + +sleep 0.5 && swww img -o DP-3 ~/pics/wallpapers/a\ carnival.jpg +swww img -o HDMI-A-1 ~/pics/wallpapers/the\ true\ old\ god.jpg diff --git a/desktop/configs/scripts/volume_brightness.sh b/desktop/configs/scripts/volume_brightness.sh new file mode 100755 index 0000000..49574f1 --- /dev/null +++ b/desktop/configs/scripts/volume_brightness.sh @@ -0,0 +1,179 @@ +#!/bin/bash + +# See README.md for usage instructions +volume_step=1 +brightness_step=5 +max_volume=100 +notification_timeout=1000 +download_album_art=true +show_album_art=true +show_music_in_volume_indicator=true + +# Uses regex to get volume from pactl +function get_volume { + pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '[0-9]{1,3}(?=%)' | head -1 +} + +# Uses regex to get mute status from pactl +function get_mute { + pactl get-sink-mute @DEFAULT_SINK@ | grep -Po '(?<=Mute: )(yes|no)' +} + +# Uses regex to get brightness from xbacklight +function get_brightness { + sudo light | grep -Po '[0-9]{1,3}' | head -n 1 +} + +# Returns a mute icon, a volume-low icon, or a volume-high icon, depending on the volume +function get_volume_icon { + volume=$(get_volume) + mute=$(get_mute) + if [ "$volume" -eq 0 ] || [ "$mute" == "yes" ] ; then + volume_icon=" " + elif [ "$volume" -lt 50 ]; then + volume_icon=" " + else + volume_icon=" " + fi +} + +# Always returns the same icon - I couldn't get the brightness-low icon to work with fontawesome +function get_brightness_icon { + brightness_icon="" +} + +function get_album_art { + url=$(playerctl -f "{{mpris:artUrl}}" metadata) + if [[ $url == "file://"* ]]; then + album_art="${url/file:\/\//}" + elif [[ $url == "http://"* ]] && [[ $download_album_art == "true" ]]; then + # Identify filename from URL + filename="$(echo $url | sed "s/.*\///")" + + # Download file to /tmp if it doesn't exist + if [ ! -f "/tmp/$filename" ]; then + wget -O "/tmp/$filename" "$url" + fi + + album_art="/tmp/$filename" + elif [[ $url == "https://"* ]] && [[ $download_album_art == "true" ]]; then + # Identify filename from URL + filename="$(echo $url | sed "s/.*\///")" + + # Download file to /tmp if it doesn't exist + if [ ! -f "/tmp/$filename" ]; then + wget -O "/tmp/$filename" "$url" + fi + + album_art="/tmp/$filename" + else + album_art="" + fi +} + +# Displays a volume notification +function show_volume_notif { + volume=$(get_mute) + get_volume_icon + + if [[ $show_music_in_volume_indicator == "true" ]]; then + current_song=$(playerctl -f "{{title}} - {{artist}}" metadata) + + if [[ $show_album_art == "true" ]]; then + get_album_art + fi + + notify-send -t $notification_timeout -h string:x-dunst-stack-tag:volume_notif -h int:value:$volume -i "$album_art" "$volume_icon $volume%" "$current_song" + else + notify-send -t $notification_timeout -h string:x-dunst-stack-tag:volume_notif -h int:value:$volume "$volume_icon $volume%" + fi +} + +# Displays a music notification +function show_music_notif { + local status_log="$1" + song_title=$(playerctl -f "{{title}}" metadata) + song_artist=$(playerctl -f "{{artist}}" metadata) + song_album=$(playerctl -f "{{album}}" metadata) + status=$(playerctl status) + if [[ $status == "Paused" ]]; then + status_icon="" + else + status_icon="" + fi + + if [[ $show_album_art == "true" ]]; then + get_album_art + fi + + if [[ $status_log == "true" ]]; then + notify-send -t $notification_timeout -h string:x-dunst-stack-tag:music_notif -i "$album_art" "$status_icon - $song_title" "$song_artist - $song_album" + else + notify-send -t $notification_timeout -h string:x-dunst-stack-tag:music_notif -i "$album_art" "$song_title" "$song_artist - $song_album" + fi +} + +# Displays a brightness notification using dunstify +function show_brightness_notif { + brightness=$(get_brightness) + echo $brightness + get_brightness_icon + notify-send -t $notification_timeout -h string:x-dunst-stack-tag:brightness_notif -h int:value:$brightness "$brightness_icon $brightness%" +} + +# Main function - Takes user input, "volume_up", "volume_down", "brightness_up", or "brightness_down" +case $1 in + volume_up) + # Unmutes and increases volume, then displays the notification + pactl set-sink-mute @DEFAULT_SINK@ 0 + volume=$(get_volume) + if [ $(( "$volume" + "$volume_step" )) -gt $max_volume ]; then + pactl set-sink-volume @DEFAULT_SINK@ $max_volume% + else + pactl set-sink-volume @DEFAULT_SINK@ +$volume_step% + fi + show_volume_notif + ;; + + volume_down) + # Raises volume and displays the notification + pactl set-sink-volume @DEFAULT_SINK@ -$volume_step% + show_volume_notif + ;; + + volume_mute) + # Toggles mute and displays the notification + pactl set-sink-mute @DEFAULT_SINK@ toggle + show_volume_notif + ;; + + brightness_up) + # Increases brightness and displays the notification + sudo light -A $brightness_step + show_brightness_notif + ;; + + brightness_down) + # Decreases brightness and displays the notification + sudo light -U $brightness_step + show_brightness_notif + ;; + + next_track) + # Skips to the next song and displays the notification + playerctl next + sleep 0.5 && show_music_notif + ;; + + prev_track) + # Skips to the previous song and displays the notification + playerctl previous + sleep 0.5 && show_music_notif + ;; + + play_pause) + playerctl play-pause + show_music_notif "true" + # Pauses/resumes playback and displays the notification + ;; +esac diff --git a/desktop/configs/scripts/weechat.sh b/desktop/configs/scripts/weechat.sh new file mode 100755 index 0000000..f563eb6 --- /dev/null +++ b/desktop/configs/scripts/weechat.sh @@ -0,0 +1 @@ +/usr/bin/tmux new -d -s weechat weechat \; set-option status off