add laptop scripts

This commit is contained in:
Lucas Barbieri 2024-02-10 10:13:44 -03:00
parent e078ac1394
commit 87d21a8898
8 changed files with 406 additions and 0 deletions

View File

@ -0,0 +1,55 @@
#!/bin/bash
CURRENT_THEME=$(readlink ~/.config/tmux/theme.conf)
WHITE_WIDE_WPP=~/pics/wallpapers/sl3.jpg
WHITE_NORMAL_WPP=~/pics/wallpapers/sl2.png
RED_WIDE_WPP=~/pics/wallpapers/bm5.jpg
RED_NORMAL_WPP=~/pics/wallpapers/bm3.png
if [[ $CURRENT_THEME == *tmux-white.conf ]]; then
# change wallpaper
swww img -o HDMI-A-1 $RED_WIDE_WPP
swww img -o DP-3 $RED_NORMAL_WPP
# change tmux theme and reload
ln -sf ~/.config/tmux/tmux-red.conf ~/.config/tmux/theme.conf
tmux source-file ~/.config/tmux/tmux.conf
# change wezterm theme
sed -i 's/Solarized Light (Gogh)/Fahrenheit/g' ~/.config/wezterm/wezterm.lua
# change nvim theme
sed -i 's/zed = true/zed = false/g' ~/.config/nvim/lua/custom/plugins/colorscheme.lua
sed -i 's/-- h/h/g' ~/.config/nvim/lua/custom/plugins/bufferline.lua
# change neofetch pic (yes lmao)
sed -i 's/rh.jpg/red.jpg/g' ~/.config/neofetch/config.conf
sed -i '0,/cl11/{s/cl11/cl3/}' ~/.config/neofetch/config.conf
# waybar black css
killall waybar; waybar > /dev/null &
else
# change wpp
swww img -o HDMI-A-1 $WHITE_WIDE_WPP
swww img -o DP-3 $WHITE_NORMAL_WPP
# change tmux theme and reload
ln -sf ~/.config/tmux/tmux-white.conf ~/.config/tmux/theme.conf
tmux source-file ~/.config/tmux/tmux.conf
# change wezterm theme
sed -i 's/Fahrenheit/Solarized Light (Gogh)/g' ~/.config/wezterm/wezterm.lua
# change nvim theme
sed -i 's/zed = false/zed = true/g' ~/.config/nvim/lua/custom/plugins/colorscheme.lua
sed -i 's/highlights/-- highlights/g' ~/.config/nvim/lua/custom/plugins/bufferline.lua
# neofetch
sed -i 's/red.jpg/rh.jpg/g' ~/.config/neofetch/config.conf
sed -i '0,/cl3/{s/cl3/cl11/}' ~/.config/neofetch/config.conf
# waybar white css
killall waybar; waybar -s ~/.config/waybar/style-solarized.css > /dev/null &
fi

112
laptop/scripts/elash.sh Executable file
View File

@ -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[@]}" "$@"

3
laptop/scripts/readme.md Normal file
View File

@ -0,0 +1,3 @@
## Dependencies
depends on grimblast

7
laptop/scripts/upt.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
upt="$(uptime --pretty | sed -e 's/up //g' -e 's/ days/d/g' -e 's/ day/d/g' -e 's/ hours/h/g' -e 's/ hour/h/g' -e 's/ minutes/m/g' -e 's/, / /g')"
echo -e "$upt "

5
laptop/scripts/volume.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
vol="$(amixer get Master | tail -n1 | sed -r 's/.*\[(.*)%\].*/\1/')"
echo "${vol}%"

View File

@ -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

44
laptop/scripts/way-print.sh Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env sh
swpy_dir="${XDG_CONFIG_HOME:-$HOME/.config}/swappy"
save_dir="$HOME/pics/screenshots"
save_file="screenshot-$(date -Iseconds | cut -d '+' -f1).png"
temp_screenshot="/tmp/screenshot.png"
mkdir -p $save_dir
mkdir -p $swpy_dir
echo -e "[Default]\nsave_dir=$save_dir\nsave_filename_format=$save_file" > $swpy_dir/config
upload ()
{
curl -F'file=@'"${save_dir}/${save_file}" -Fsecret= -Fexpires=24 https://0x0.st | wl-copy
}
function print_error
{
cat << "EOF"
./screenshot.sh <action>
...valid actions are...
p : print all screens
s : snip current screen
sf : snip current screen (frozen)
m : print focused monitor
EOF
}
case $1 in
p) # print all outputs
grimblast copysave screen $temp_screenshot && swappy -f $temp_screenshot ;;
s) # drag to manually snip an area / click on a window to print it
grimblast copysave area $temp_screenshot && swappy -f $temp_screenshot ;;
sf) # frozen screen, drag to manually snip an area / click on a window to print it
grimblast --freeze copysave area $temp_screenshot && swappy -f $temp_screenshot ;;
m) # print focused monitor
grimblast copysave output $temp_screenshot && swappy -f $temp_screenshot ;;
t) #upload to 0x0.st temporarily
grimblast copysave area $temp_screenshot && swappy -f $temp_screenshot && upload ;;
*) # invalid option
print_error ;;
esac
rm "$temp_screenshot"

1
laptop/scripts/weechat.sh Executable file
View File

@ -0,0 +1 @@
/usr/bin/tmux new -d -s weechat weechat \; set-option status off