init
This commit is contained in:
27
misc/bin/brightness
Normal file
27
misc/bin/brightness
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# Originally created by - https://github.com/rxyhn
|
||||
|
||||
DIR="$HOME/.local/share/assets"
|
||||
BRIGHTNESS_STEPS=5
|
||||
|
||||
function get_brightness {
|
||||
brightnessctl i | grep -oP '\(\K[^%\)]+'
|
||||
}
|
||||
|
||||
function send_notification {
|
||||
icon="$DIR/brightness.svg"
|
||||
brightness=$(get_brightness)
|
||||
bar=$(seq -s "─" 0 $((brightness / 5)) | sed 's/[0-9]//g')
|
||||
dunstify "Brightness $brightness%" -i $icon -r 5555 -u normal -h int:value:$(($brightness))
|
||||
}
|
||||
|
||||
case $1 in
|
||||
up)
|
||||
brightnessctl set "${BRIGHTNESS_STEPS:-5}%+" -q
|
||||
send_notification
|
||||
;;
|
||||
down)
|
||||
brightnessctl set "${BRIGHTNESS_STEPS:-5}%-" -q
|
||||
send_notification
|
||||
;;
|
||||
esac
|
9
misc/bin/bsphidenode
Normal file
9
misc/bin/bsphidenode
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
NHidden=$(bspc query -N -n .hidden -d focused)
|
||||
|
||||
if [ -z "$NHidden" ]; then
|
||||
bspc node focused -g hidden=on
|
||||
else
|
||||
bspc node "$NHidden" -g hidden=off
|
||||
fi
|
160
misc/bin/colorscript
Normal file
160
misc/bin/colorscript
Normal file
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash
|
||||
# Simple CLI for shell-color-scripts
|
||||
|
||||
if [[ "$DEV" -gt 0 ]]; then
|
||||
DIR_COLORSCRIPTS="./colorscripts"
|
||||
else
|
||||
DIR_COLORSCRIPTS="$HOME/.local/share/asciiart"
|
||||
fi
|
||||
|
||||
if command -v find &>/dev/null; then
|
||||
LS_CMD="$(command -v find) ${DIR_COLORSCRIPTS} -maxdepth 1 -type f"
|
||||
LS_CMD_B="$(command -v find) ${DIR_COLORSCRIPTS}/blacklisted -maxdepth 1 -type f"
|
||||
else
|
||||
LS_CMD="$(command -v ls) ${DIR_COLORSCRIPTS}"
|
||||
LS_CMD_B="$(command -v ls) ${DIR_COLORSCRIPTS}/blacklisted"
|
||||
fi
|
||||
|
||||
list_colorscripts="$($LS_CMD | xargs -I $ basename $ | cut -d ' ' -f 1 | nl)"
|
||||
length_colorscripts="$($LS_CMD | wc -l)"
|
||||
list_blacklist="$($LS_CMD_B 2>/dev/null | xargs -I $ basename $ | cut -d ' ' -f 1 | nl || "")"
|
||||
length_blacklist="$($LS_CMD_B 2>/dev/null | wc -l || 0)"
|
||||
|
||||
fmt_help=" %-20s\t%-54s\n"
|
||||
function _help() {
|
||||
echo "Description: A collection of terminal color scripts."
|
||||
echo ""
|
||||
echo "Usage: colorscript [OPTION] [SCRIPT NAME/INDEX]"
|
||||
printf "${fmt_help}" \
|
||||
"-h, --help, help" "Print this help." \
|
||||
"-l, --list, list" "List all installed color scripts." \
|
||||
"-r, --random, random" "Run a random color script." \
|
||||
"-e, --exec, exec" "Run a specified color script by SCRIPT NAME or INDEX."\
|
||||
"-b, --blacklist, blacklist" "Blacklist a color script by SCRIPT NAME or INDEX." \
|
||||
"-u, --unblacklist, unblacklist" "Unblacklist a color script by SCRIPT NAME or INDEX." \
|
||||
"-a, --all, all" "List the outputs of all colorscripts with their SCRIPT NAME"
|
||||
}
|
||||
|
||||
function _list() {
|
||||
echo "There are "$($LS_CMD | wc -l)" installed color scripts:"
|
||||
echo "${list_colorscripts}"
|
||||
}
|
||||
|
||||
function _list_blacklist() {
|
||||
echo "There are $length_blacklist blacklisted color scripts:"
|
||||
echo "${list_blacklist}"
|
||||
}
|
||||
|
||||
function _random() {
|
||||
declare -i random_index=$RANDOM%$length_colorscripts
|
||||
[[ $random_index -eq 0 ]] && random_index=1
|
||||
|
||||
random_colorscript="$(echo "${list_colorscripts}" | sed -n ${random_index}p \
|
||||
| tr -d ' ' | tr '\t' ' ' | cut -d ' ' -f 2)"
|
||||
# echo "${random_colorscript}"
|
||||
exec "${DIR_COLORSCRIPTS}/${random_colorscript}"
|
||||
}
|
||||
|
||||
function ifhascolorscipt() {
|
||||
[[ -e "${DIR_COLORSCRIPTS}/$1" ]] && echo "Has this color script."
|
||||
}
|
||||
|
||||
function _run_by_name() {
|
||||
if [[ "$1" == "random" ]]; then
|
||||
_random
|
||||
elif [[ -n "$(ifhascolorscipt "$1")" ]]; then
|
||||
exec "${DIR_COLORSCRIPTS}/$1"
|
||||
else
|
||||
echo "Input error, Don't have color script named $1."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function _run_by_index() {
|
||||
if [[ "$1" -gt 0 && "$1" -le "${length_colorscripts}" ]]; then
|
||||
|
||||
colorscript="$(echo "${list_colorscripts}" | sed -n ${1}p \
|
||||
| tr -d ' ' | tr '\t' ' ' | cut -d ' ' -f 2)"
|
||||
exec "${DIR_COLORSCRIPTS}/${colorscript}"
|
||||
else
|
||||
echo "Input error, Don't have color script indexed $1."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function _run_colorscript() {
|
||||
if [[ "$1" =~ ^[0-9]+$ ]]; then
|
||||
_run_by_index "$1"
|
||||
else
|
||||
_run_by_name "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function _run_all() {
|
||||
for s in $DIR_COLORSCRIPTS/*
|
||||
do
|
||||
echo "$(echo $s | awk -F '/' '{print $NF}'):"
|
||||
echo "$($s)"
|
||||
echo
|
||||
done
|
||||
}
|
||||
|
||||
function _blacklist_colorscript() { # by name only
|
||||
if [ ! -d "${DIR_COLORSCRIPTS}/blacklisted" ]; then
|
||||
sudo mkdir "${DIR_COLORSCRIPTS}/blacklisted"
|
||||
fi
|
||||
sudo mv "${DIR_COLORSCRIPTS}/$1" "${DIR_COLORSCRIPTS}/blacklisted"
|
||||
}
|
||||
|
||||
function _unblacklist_colorscript() { # by name only
|
||||
if [ -f "${DIR_COLORSCRIPTS}/blacklisted/$1" ]; then
|
||||
sudo mv "${DIR_COLORSCRIPTS}/blacklisted/$1" "${DIR_COLORSCRIPTS}"
|
||||
else
|
||||
echo "Input error. Script $1 is not blacklisted!"
|
||||
fi
|
||||
}
|
||||
|
||||
case "$#" in
|
||||
0)
|
||||
_help
|
||||
;;
|
||||
1)
|
||||
case "$1" in
|
||||
-h | --help | help)
|
||||
_help
|
||||
;;
|
||||
-l | --list | list)
|
||||
_list
|
||||
;;
|
||||
-b | --blacklist | blacklist)
|
||||
_list_blacklist
|
||||
;;
|
||||
-r | --random | random)
|
||||
_random
|
||||
;;
|
||||
-a | --all | all)
|
||||
_run_all
|
||||
;;
|
||||
*)
|
||||
echo "Input error."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
2)
|
||||
if [[ "$1" == "-e" || "$1" == "--exec" || "$1" == "exec" ]]; then
|
||||
_run_colorscript "$2"
|
||||
elif [[ "$1" == "-b" || "$1" == "--blacklist" || "$1" == "blacklist" ]]; then
|
||||
_blacklist_colorscript "$2"
|
||||
elif [[ "$1" == "-u" || "$1" == "--unblacklist" || "$1" == "unblacklist" ]]; then
|
||||
_unblacklist_colorscript "$2"
|
||||
else
|
||||
echo "Input error."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Input error, too many arguments."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
32
misc/bin/externalrules
Normal file
32
misc/bin/externalrules
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
wid=$1
|
||||
class=$2
|
||||
instance=$3
|
||||
consequences=$4
|
||||
|
||||
case "$class" in
|
||||
floaterm)
|
||||
eval "$consequences"
|
||||
[ "$state" ] || echo "state=floating center=on"
|
||||
;;
|
||||
updating)
|
||||
eval "$consequences"
|
||||
[ "$state" ] || echo "state=floating sticky=on center=on"
|
||||
;;
|
||||
mpv)
|
||||
eval "$consequences"
|
||||
[ "$state" ] || echo "state=pseudo_tiled focus=on rectangle=849x477+0+0 center=on"
|
||||
;;
|
||||
virt-manager)
|
||||
eval "$consequences"
|
||||
[ "$state" ] || echo "state=floating desktop=^5 follow=on center=on"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$instance" in
|
||||
Toolkit)
|
||||
eval "$consequences"
|
||||
[ "$state" ] || echo "state=floating sticky=on rectangle=500x290+1054+593"
|
||||
;;
|
||||
esac
|
21
misc/bin/hidebar
Normal file
21
misc/bin/hidebar
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function hide() {
|
||||
polybar-msg cmd hide | bspc config top_padding 2 | bspc config bottom_padding 2
|
||||
}
|
||||
|
||||
function unhide() {
|
||||
polybar-msg cmd show | bspc config top_padding 48 | bspc config bottom_padding 48
|
||||
}
|
||||
|
||||
case $1 in
|
||||
-h | --hide | hide)
|
||||
hide
|
||||
exit;;
|
||||
-u | --unhide | unhide)
|
||||
unhide
|
||||
exit;;
|
||||
*)
|
||||
echo "Error: Invalid option"
|
||||
exit;;
|
||||
esac
|
4
misc/bin/keybindingshelp
Normal file
4
misc/bin/keybindingshelp
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
awk '/^[a-z]/ && last {print $0,"\t",last} {last=""} /^#/{last=$0}' ~/.config/sxhkd/sxhkdrc | \
|
||||
column -t -s $'\t' | rofi -dmenu -i -markup-rows -no-show-icons -width 1000 -lines 15 -yoffset 40
|
132
misc/bin/mediacontrol
Normal file
132
misc/bin/mediacontrol
Normal file
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Set the player
|
||||
[ -n "$(pgrep spotify)" ] && Control="spotify" || Control="MPD"
|
||||
|
||||
Cover=/tmp/cover.png
|
||||
bkpCover=~/.local/share/assets/fallback.webp
|
||||
mpddir=~/music
|
||||
|
||||
case $Control in
|
||||
MPD)
|
||||
case $1 in
|
||||
--next)
|
||||
mpc -q next
|
||||
;;
|
||||
--previous)
|
||||
mpc -q prev
|
||||
;;
|
||||
--toggle)
|
||||
mpc -q toggle
|
||||
;;
|
||||
--stop)
|
||||
mpc -q stop
|
||||
;;
|
||||
--title)
|
||||
title=$(mpc -f %title% current)
|
||||
echo "${title:-Play Something}"
|
||||
;;
|
||||
--artist)
|
||||
artist=$(mpc -f %artist% current)
|
||||
echo "${artist:-No Artist}"
|
||||
;;
|
||||
--status)
|
||||
status=$(mpc status | head -2 | tail -1 | cut -c2-8 | sed 's/]//g' | sed 's/./\U&/')
|
||||
echo "${status:-Stopped}"
|
||||
;;
|
||||
--player)
|
||||
echo "$Control"
|
||||
;;
|
||||
--cover)
|
||||
ffmpeg -i "$mpddir"/"$(mpc current -f %file%)" "${Cover}" -y &> /dev/null || cp $bkpCover $Cover
|
||||
echo "$Cover"
|
||||
;;
|
||||
nccover)
|
||||
ffmpeg -i "$mpddir"/"$(mpc current -f %file%)" "${Cover}" -y &> /dev/null || cp $bkpCover $Cover
|
||||
;;
|
||||
--position)
|
||||
position=$(mpc status %currenttime%)
|
||||
echo "${position:-0:00}"
|
||||
;;
|
||||
--positions)
|
||||
positions=$(mpc status %currenttime% | awk -F: '{print ($1 * 60) + $2}')
|
||||
echo "${positions:-0}"
|
||||
;;
|
||||
--length)
|
||||
length=$(mpc status %totaltime%)
|
||||
echo "${length:-0:00}"
|
||||
;;
|
||||
--lengths)
|
||||
lengths=$(mpc status %totaltime% | awk -F: '{print ($1 * 60) + $2}')
|
||||
echo "${lengths:-0}"
|
||||
;;
|
||||
--shuffle)
|
||||
shuffle=$(mpc status | sed -n '3s/.*random: \([^ ]*\).*/\1/p' | sed 's/.*/\u&/')
|
||||
echo "${shuffle:-Off}"
|
||||
;;
|
||||
--loop)
|
||||
loop=$(mpc status | sed -n '3s/.*repeat: \([^ ]*\).*/\1/p' | sed 's/.*/\u&/')
|
||||
echo "${loop:-Off}"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
case $1 in
|
||||
--next)
|
||||
playerctl --player=$Control next
|
||||
;;
|
||||
--previous)
|
||||
playerctl --player=$Control previous
|
||||
;;
|
||||
--toggle)
|
||||
playerctl --player=$Control play-pause
|
||||
;;
|
||||
--stop)
|
||||
playerctl --player=$Control stop
|
||||
;;
|
||||
--title)
|
||||
title=$(playerctl --player=$Control metadata --format {{title}})
|
||||
echo "${title:-Play Something}"
|
||||
;;
|
||||
--artist)
|
||||
artist=$(playerctl --player=$Control metadata --format {{artist}})
|
||||
echo "${artist:-No Artist}"
|
||||
;;
|
||||
--status)
|
||||
status=$(playerctl --player=$Control status)
|
||||
echo "${status:-Stopped}"
|
||||
;;
|
||||
--player)
|
||||
echo "$Control"
|
||||
;;
|
||||
--cover)
|
||||
albumart="$(playerctl --player=$Control metadata mpris:artUrl | sed -e 's/open.spotify.com/i.scdn.co/g')"
|
||||
[ $(playerctl --player=$Control metadata mpris:artUrl) ] && curl -s "$albumart" --output $Cover || cp $bkpCover $Cover
|
||||
echo "$Cover"
|
||||
;;
|
||||
--position)
|
||||
position=$(playerctl --player=$Control position --format "{{ duration(position) }}")
|
||||
echo "${position:-0:00}"
|
||||
;;
|
||||
--positions)
|
||||
positions=$(playerctl --player=$Control position | sed 's/..\{6\}$//')
|
||||
echo "${positions:-0}"
|
||||
;;
|
||||
--length)
|
||||
length=$(playerctl --player=$Control metadata --format "{{ duration(mpris:length) }}")
|
||||
echo "${length:-0:00}"
|
||||
;;
|
||||
--lengths)
|
||||
lengths=$(playerctl --player=$Control metadata mpris:length | sed 's/.\{6\}$//')
|
||||
echo "${lengths:-0}"
|
||||
;;
|
||||
--shuffle)
|
||||
shuffle=$(playerctl --player=$Control shuffle)
|
||||
echo "${shuffle:-Off}"
|
||||
;;
|
||||
--loop)
|
||||
loop=$(playerctl --player=$Control loop)
|
||||
echo "${loop:-None}"
|
||||
;;
|
||||
esac
|
||||
esac 2>/dev/null
|
37
misc/bin/openapp
Normal file
37
misc/bin/openapp
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
case "$1" in
|
||||
--menu)
|
||||
rofi -show drun -theme $HOME/.config/rofi/launcher.rasi
|
||||
;;
|
||||
--terminal)
|
||||
alacritty
|
||||
;;
|
||||
--floating)
|
||||
alacritty --class floaterm,alacritty -o window.dimensions.lines=22 window.dimensions.columns=90
|
||||
;;
|
||||
--update)
|
||||
alacritty --hold --class floaterm,alacritty -o window.dimensions.lines=22 window.dimensions.columns=90 -e updates --update-system
|
||||
;;
|
||||
--checkupdates)
|
||||
alacritty --hold --class updating,alacritty -o window.dimensions.lines=22 window.dimensions.columns=47 -e updates --print-updates
|
||||
;;
|
||||
--ranger)
|
||||
alacritty --class alacritty -e ranger
|
||||
;;
|
||||
--nvim)
|
||||
alacritty -e nvim
|
||||
;;
|
||||
--music)
|
||||
alacritty --class floaterm,alacritty -o window.dimensions.lines=18 window.dimensions.columns=67 -e ncmpcpp
|
||||
;;
|
||||
--fetch)
|
||||
alacritty --hold --class floaterm,alacritty -o window.dimensions.lines=21 window.dimensions.columns=90 -e neofetch
|
||||
;;
|
||||
--browser)
|
||||
brave
|
||||
;;
|
||||
*)
|
||||
echo "Not a Valid Option"
|
||||
;;
|
||||
esac
|
42
misc/bin/screenshoter
Normal file
42
misc/bin/screenshoter
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
timestamp=$(date +%d_%m_%Y-%I-%M-%S)
|
||||
dir="$(xdg-user-dir PICTURES)/screenshots"
|
||||
filename="$dir/screenshot-${timestamp}.png"
|
||||
|
||||
[ -d "$dir" ] || mkdir -p "$dir"
|
||||
|
||||
show_notification() {
|
||||
dunstify --replace=699 -i "$1" "Screenshot" "$2"
|
||||
}
|
||||
|
||||
countdown() {
|
||||
for sec in $(seq "$1" -1 1); do
|
||||
dunstify -t 1000 --replace=699 -i ~/.local/misc/share/assets/screenshot.svg "Taking shot in : $sec"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
take_screenshot() {
|
||||
maim -u "$filename"
|
||||
xclip -selection clipboard -t image/png -i "$filename"
|
||||
show_notification "$filename" "$1"
|
||||
}
|
||||
|
||||
case $1 in
|
||||
--now)
|
||||
take_screenshot "Screensot saved and copied to clipboard";;
|
||||
--in10)
|
||||
countdown 10
|
||||
take_screenshot "Scheduled capture taken after 10 seconds and copied to clipboard";;
|
||||
--sel)
|
||||
maim -u -s "$filename"
|
||||
xclip -selection clipboard -t image/png -i "$filename"
|
||||
show_notification "$filename" "Screenshot of selected area saved and copied to clipboard";;
|
||||
--active)
|
||||
maim -u -i "$(xdotool getactivewindow)" "$filename"
|
||||
xclip -selection clipboard -t image/png -i "$filename"
|
||||
show_notification "$filename" "Screenshot of active window saved and copied to clipboard";;
|
||||
*)
|
||||
take_screenshot "Screensot saved and copied to clipboard";;
|
||||
esac
|
48
misc/bin/setsysvars
Normal file
48
misc/bin/setsysvars
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SFILE="$HOME/.local/bin/.sys"
|
||||
|
||||
function get_values() {
|
||||
|
||||
DEFNETWORK=$(ip route | grep '^default' | awk '{print $5}' | head -n1)
|
||||
CARD=$(ls -1 /sys/class/backlight/)
|
||||
power_supply_files=$(ls /sys/class/power_supply/)
|
||||
|
||||
for file in $power_supply_files
|
||||
do
|
||||
if [ -e "/sys/class/power_supply/$file/capacity" ]; then
|
||||
battery_file=$file
|
||||
fi
|
||||
|
||||
if [ -e "/sys/class/power_supply/$file/online" ]; then
|
||||
adapter_file=$file
|
||||
fi
|
||||
done
|
||||
|
||||
BATTERY="$battery_file"
|
||||
ADAPTER="$adapter_file"
|
||||
|
||||
}
|
||||
|
||||
function set_values() {
|
||||
|
||||
if [[ "$DEFNETWORK" ]]; then
|
||||
sed -i -e "s/sys_network_interface = .*/sys_network_interface = $DEFNETWORK/g" $HOME/.config/polybar/system.ini
|
||||
fi
|
||||
if [[ "$ADAPTER" ]]; then
|
||||
sed -i -e "s/sys_adapter = .*/sys_adapter = $ADAPTER/g" $HOME/.config/polybar/system.ini
|
||||
fi
|
||||
if [[ "$BATTERY" ]]; then
|
||||
sed -i -e "s/sys_battery = .*/sys_battery = $BATTERY/g" $HOME/.config/polybar/system.ini
|
||||
fi
|
||||
if [[ "$CARD" ]]; then
|
||||
sed -i -e "s/sys_graphics_card = .*/sys_graphics_card = $CARD/g" $HOME/.config/polybar/system.ini
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
if [[ ! -f "$SFILE" ]]; then
|
||||
get_values
|
||||
set_values
|
||||
touch "$SFILE"
|
||||
fi
|
45
misc/bin/updates
Normal file
45
misc/bin/updates
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
get_total_updates() {
|
||||
local total_updates=$(($(checkupdates 2> /dev/null | wc -l || echo 0) + $(yay -Qua 2> /dev/null | wc -l || echo 0)))
|
||||
echo "${total_updates:-0}"
|
||||
}
|
||||
|
||||
get_list_updates() {
|
||||
echo -e "\033[1m\033[34mRegular updates:\033[0m"
|
||||
checkupdates | sed 's/->/\x1b[32;1m\x1b[0m/g'
|
||||
}
|
||||
|
||||
get_list_aur_updates() {
|
||||
echo -e "\n\033[1m\033[34mAur updates available:\033[0m"
|
||||
yay -Qua | sed 's/->/\x1b[32;1m\x1b[0m/g'
|
||||
}
|
||||
|
||||
print_updates() {
|
||||
local print_updates=$(get_total_updates)
|
||||
|
||||
if [[ "$print_updates" -gt 0 ]]; then
|
||||
echo -e "\033[1m\033[33mThere are $print_updates updates available:\033[0m\n"
|
||||
get_list_updates
|
||||
get_list_aur_updates
|
||||
else
|
||||
echo -e "\033[1m\033[32mYour system is already updated!\033[0m"
|
||||
fi
|
||||
}
|
||||
|
||||
update_system() {
|
||||
yay -Syu --nocombinedupgrade --noconfirm
|
||||
echo -e "\033[1m\033[32mFinished!\033[0m"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
--get-updates)get_total_updates;;
|
||||
--print-updates)print_updates;;
|
||||
--update-system)update_system;;
|
||||
--help|*)echo -e "Updates [options]
|
||||
|
||||
Options:
|
||||
--get-updates Get the numer of updates available.
|
||||
--print-updates Print the available package to updates.
|
||||
--update-system Update your system including AUR.\n"
|
||||
esac
|
58
misc/bin/volume
Normal file
58
misc/bin/volume
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Icons
|
||||
vol_dir="$HOME/.local/share/assets"
|
||||
notify_cmd='dunstify -u low -h string:x-dunst-stack-tag:cvolum'
|
||||
|
||||
# Get Volume
|
||||
get_volume() {
|
||||
pamixer --get-volume-human | sed 's/%//'
|
||||
}
|
||||
|
||||
# Get icons
|
||||
get_icon() {
|
||||
current="$(get_volume)"
|
||||
if [[ "$current" -eq "0" || "$current" == "muted" ]]; then
|
||||
icon="$vol_dir/mute.png"
|
||||
else
|
||||
icon="$vol_dir/vol.png"
|
||||
fi
|
||||
}
|
||||
|
||||
# Notify
|
||||
notify_user() {
|
||||
${notify_cmd} -i "$icon" "Volume : $(get_volume)%"
|
||||
}
|
||||
|
||||
# Adjust Volume
|
||||
adjust_volume() {
|
||||
[[ $(pamixer --get-mute) == true ]] && pamixer -u
|
||||
pamixer --allow-boost --set-limit 150 "$1" "$2" && get_icon && notify_user
|
||||
}
|
||||
|
||||
# Toggle Mute
|
||||
toggle_mute() {
|
||||
if [[ $(pamixer --get-mute) == false ]]; then
|
||||
pamixer --toggle-mute
|
||||
get_icon
|
||||
message="Mute"
|
||||
else
|
||||
pamixer --toggle-mute
|
||||
get_icon
|
||||
message="Unmute"
|
||||
fi
|
||||
${notify_cmd} -i "$icon" "$message"
|
||||
}
|
||||
|
||||
# Execute accordingly
|
||||
if command -v pamixer &>/dev/null; then
|
||||
case "$1" in
|
||||
--get) get_volume ;;
|
||||
--inc) adjust_volume -i 5 ;;
|
||||
--dec) adjust_volume -d 5 ;;
|
||||
--toggle) toggle_mute ;;
|
||||
*) echo "$(get_volume)%" ;;
|
||||
esac
|
||||
else
|
||||
${notify_cmd} "'pamixer' is not installed."
|
||||
fi
|
132
misc/bin/weather
Normal file
132
misc/bin/weather
Normal file
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
encode_to_url_format() {
|
||||
echo "$1" | sed 's/ /%20/g'
|
||||
}
|
||||
|
||||
check_if_empty() {
|
||||
[[ -z "$1" ]] && echo "0" || echo "$1"
|
||||
}
|
||||
|
||||
KEY="699a48531cdd445784916ed7a7ca80e6"
|
||||
CITY="Virginia Beach"
|
||||
CITYN=$(encode_to_url_format "$CITY")
|
||||
UNITS="imperial" # Available "metric" "imperial"
|
||||
WEATHER=$(curl -sf "api.openweathermap.org/data/2.5/weather?q=$CITYN&appid=$KEY&units=$UNITS")
|
||||
|
||||
WEATHER_DESC=$(echo "$WEATHER" | jq -r ".weather[0].main")
|
||||
WEATHER_TEMP=$(echo "$WEATHER" | jq ".main.temp" | cut -d "." -f 1)
|
||||
WEATHER_ICON_CODE=$(echo "$WEATHER" | jq -r ".weather[].icon" | head -1)
|
||||
WEATHER_FEELS_LIKE=$(echo "$WEATHER" | jq ".main.feels_like" | cut -d "." -f 1)
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX=""
|
||||
|
||||
case $WEATHER_ICON_CODE in
|
||||
"01d")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#ffd86b"
|
||||
;;
|
||||
"01n")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#fcdcf6"
|
||||
;;
|
||||
"02d")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#adadff"
|
||||
;;
|
||||
"02n")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#adadff"
|
||||
;;
|
||||
"03d")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#adadff"
|
||||
;;
|
||||
"03n")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#adadff"
|
||||
;;
|
||||
"04d")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#adadff"
|
||||
;;
|
||||
"04n")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#acb0d0"
|
||||
;;
|
||||
"09d")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#6b95ff"
|
||||
;;
|
||||
"09n")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#6b95ff"
|
||||
;;
|
||||
"10d")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#6b95ff"
|
||||
;;
|
||||
"10n")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#6b95ff"
|
||||
;;
|
||||
"11d")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#ffeb57"
|
||||
;;
|
||||
"11n")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#ffeb57"
|
||||
;;
|
||||
"13d")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#e3e6fc"
|
||||
;;
|
||||
"13n")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#e3e6fc"
|
||||
;;
|
||||
"40d")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#84afdb"
|
||||
;;
|
||||
"40n")
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#84afdb"
|
||||
;;
|
||||
*)
|
||||
WEATHER_ICON=""
|
||||
WEATHER_HEX="#adadff"
|
||||
;;
|
||||
esac
|
||||
|
||||
case $1 in
|
||||
"current_temp")
|
||||
check_if_empty "$WEATHER_TEMP"
|
||||
;;
|
||||
"current_temp_fahrenheit")
|
||||
WEATHER_TEMP=$("$WEATHER_TEMP" 9 / 5 + 32)
|
||||
check_if_empty "$WEATHER_TEMP"
|
||||
;;
|
||||
"feels_like")
|
||||
check_if_empty "$WEATHER_FEELS_LIKE"
|
||||
;;
|
||||
"weather_desc")
|
||||
[[ -z $WEATHER_DESC ]] && echo "Not Available." || echo "$WEATHER_DESC"
|
||||
;;
|
||||
"icon")
|
||||
echo $WEATHER_ICON
|
||||
;;
|
||||
"hex")
|
||||
echo $WEATHER_HEX
|
||||
;;
|
||||
"full")
|
||||
echo "$WEATHER"
|
||||
;;
|
||||
"city")
|
||||
echo "$CITY"
|
||||
;;
|
||||
"wmodule")
|
||||
echo $WEATHER_ICON "$WEATHER_TEMP"°
|
||||
;;
|
||||
esac
|
Reference in New Issue
Block a user