This commit is contained in:
天クマ 2025-12-18 12:09:34 -03:00
commit c8734e660a
392 changed files with 21043 additions and 0 deletions

View file

@ -0,0 +1,45 @@
#!/bin/sh
PATH_AC="/sys/class/power_supply/AC"
PATH_BATTERY_0="/sys/class/power_supply/BAT0"
PATH_BATTERY_1="/sys/class/power_supply/BAT1"
ac=0
battery_level_0=0
battery_level_1=0
battery_max_0=0
battery_max_1=0
if [ -f "$PATH_AC/online" ]; then
ac=$(cat "$PATH_AC/online")
fi
if [ -f "$PATH_BATTERY_0/energy_now" ]; then
battery_level_0=$(cat "$PATH_BATTERY_0/energy_now")
fi
if [ -f "$PATH_BATTERY_0/energy_full" ]; then
battery_max_0=$(cat "$PATH_BATTERY_0/energy_full")
fi
if [ -f "$PATH_BATTERY_1/energy_now" ]; then
battery_level_1=$(cat "$PATH_BATTERY_1/energy_now")
fi
if [ -f "$PATH_BATTERY_1/energy_full" ]; then
battery_max_1=$(cat "$PATH_BATTERY_1/energy_full")
fi
battery_level=$(("$battery_level_0 + $battery_level_1"))
battery_max=$(("$battery_max_0 + $battery_max_1"))
battery_level=$(("$battery_level_0"))
battery_max=$(("$battery_max_0"))
battery_percent=$(("$battery_level * 100"))
battery_percent=$(("$battery_percent / $battery_max"))
if ([ $battery_percent -eq 10 ] || [ $battery_percent -eq 6 ]) && [ "$ac" -eq 0 ]
then
notify-send -u normal -i battery-level-10-symbolic "Arch Linux" "$battery_percent battery left."
fi

View file

@ -0,0 +1,24 @@
#!/bin/bash
updates_yay=$(yay -Qu --aur 2> /dev/null | wc -l)
updates_pacman=$(checkupdates 2> /dev/null | wc -l)
updates=$((updates_pacman + updates_yay))
if [ "$updates" -gt 0 ]; then
if [ "$updates_yay" -eq 1 ]; then
echo "<big></big> $updates"
notify-send -u normal -i software-update-available-symbolic "$updates_yay update available from AUR" "$(yay -Qu --aur)"
fi
if [ "$updates_pacman" -eq 1 ]; then
echo "<big></big> $updates"
notify-send -u normal -i software-update-available-symbolic "$updates_pacman update available from pacman" "$(checkupdates)"
fi
if [ "$updates_yay" -gt 1 ]; then
echo "<big></big> $updates"
notify-send -u normal -i software-update-available-symbolic "$updates_yay updates available from AUR" "$(yay -Qu --aur)"
fi
if [ "$updates_pacman" -gt 1 ]; then
echo "<big></big> $updates"
notify-send -u normal -i software-update-available-symbolic "$updates_pacman updates available from pacman" "$(checkupdates)"
fi
fi

View file

@ -0,0 +1,15 @@
#!/bin/bash
# Server and mail adress are defined with credentials in ~/.netrc
SERVER="$(head -1 ~/.netrc | awk '{print $2}')"
INBOX=$(curl --netrc -X "STATUS INBOX (UNSEEN)" imaps://$SERVER/INBOX | tr -d -c "[:digit:]")
if [ $INBOX ] && [ $INBOX -gt 0 ] ; then
if [ $INBOX -eq 1 ] ; then
echo "<big></big> $INBOX"
notify-send -i mail-unread-symbolic "Thunderbird" "You have an unread e-mail."
else
echo "<big></big> $INBOX"
notify-send -i mail-unread-symbolic "Thunderbird" "You have $INBOX unread e-mail."
fi
fi

View file

@ -0,0 +1,20 @@
#!/bin/bash
arg="$1"
## Install Cargo
curl https://sh.rustup.rs -sSf | sh
## Install playerctl
sudo pacman -Sy playerctl --needed --noconfirm
if [ "$arg" == "yes" ]; then
sudo pacman -Sy otf-font-awesome --needed --noconfirm
fi
source "$HOME/.cargo/env"
## Install Module
cargo install waybar_media_display
echo -e "Waybar Media Display Module Installed.
Run waybar_media_display --help for options"

View file

@ -0,0 +1,128 @@
#!/usr/bin/env python3
import argparse
import logging
import sys
import signal
import gi
import json
gi.require_version('Playerctl', '2.0')
from gi.repository import Playerctl, GLib
logger = logging.getLogger(__name__)
def write_output(text, player):
logger.info('Writing output')
output = {'text': text,
'class': 'custom-' + player.props.player_name,
'alt': player.props.player_name}
sys.stdout.write(json.dumps(output) + '\n')
sys.stdout.flush()
def on_play(player, status, manager):
logger.info('Received new playback status')
on_metadata(player, player.props.metadata, manager)
def on_metadata(player, metadata, manager):
logger.info('Received new metadata')
track_info = ''
if player.props.player_name == 'spotify' and \
'mpris:trackid' in metadata.keys() and \
':ad:' in player.props.metadata['mpris:trackid']:
track_info = 'AD PLAYING'
elif player.get_artist() != '' and player.get_title() != '':
track_info = '{artist} - {title}'.format(artist=player.get_artist(),
title=player.get_title())
else:
track_info = player.get_title()
if player.props.status != 'Playing' and track_info:
track_info = '' + track_info
write_output(track_info, player)
def on_player_appeared(manager, player, selected_player=None):
if player is not None and (selected_player is None or player.name == selected_player):
init_player(manager, player)
else:
logger.debug("New player appeared, but it's not the selected player, skipping")
def on_player_vanished(manager, player):
logger.info('Player has vanished')
sys.stdout.write('\n')
sys.stdout.flush()
def init_player(manager, name):
logger.debug('Initialize player: {player}'.format(player=name.name))
player = Playerctl.Player.new_from_name(name)
player.connect('playback-status', on_play, manager)
player.connect('metadata', on_metadata, manager)
manager.manage_player(player)
on_metadata(player, player.props.metadata, manager)
def signal_handler(sig, frame):
logger.debug('Received signal to stop, exiting')
sys.stdout.write('\n')
sys.stdout.flush()
# loop.quit()
sys.exit(0)
def parse_arguments():
parser = argparse.ArgumentParser()
# Increase verbosity with every occurrence of -v
parser.add_argument('-v', '--verbose', action='count', default=0)
# Define for which player we're listening
parser.add_argument('--player')
return parser.parse_args()
def main():
arguments = parse_arguments()
# Initialize logging
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
format='%(name)s %(levelname)s %(message)s')
# Logging is set by default to WARN and higher.
# With every occurrence of -v it's lowered by one
logger.setLevel(max((3 - arguments.verbose) * 10, 0))
# Log the sent command line arguments
logger.debug('Arguments received {}'.format(vars(arguments)))
manager = Playerctl.PlayerManager()
loop = GLib.MainLoop()
manager.connect('name-appeared', lambda *args: on_player_appeared(*args, arguments.player))
manager.connect('player-vanished', on_player_vanished)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
for player in manager.props.player_names:
if arguments.player is not None and arguments.player != player.name:
logger.debug('{player} is not the filtered player, skipping it'
.format(player=player.name)
)
continue
init_player(manager, player)
loop.run()
if __name__ == '__main__':
main()

View file

@ -0,0 +1,27 @@
#!/bin/bash
player_status=$(playerctl status)
player_name=$(playerctl metadata --format "{{ playerName }}")
artist=$(playerctl metadata --format "{{ artist }}")
title=$(playerctl metadata --format "{{ title }}")
duration=$(playerctl metadata --format "{{ duration(position) }} / {{ duration(mpris:length) }}")
firefox_status=$(playerctl --player=firefox status)
spotify_status=$(playerctl --player=spotify status)
if [ "$player_name" == "spotify" ]; then
echo "<big></big> $artist - $title - [$duration]"
elif [ "$player_name" == "firefox" ]; then
if [ "$artist" == "" ]; then
echo "<big></big> $title"
else
echo "<big></big> $artist - $title"
fi
else
if [ "$player_status" == "Playing" ]; then
echo "<big></big> $artist - $title"
else
echo ""
fi
fi

View file

@ -0,0 +1,23 @@
#!/bin/bash
option0=" Lock"
option1="󰗽 Logout"
option2=" Suspend"
option3=" Reboot"
option4=" Shutdown"
options="$option0\n$option1\n$option2\n$option3\n$option4\n$option5\n$option6\n$option7"
chosen="$(echo -e "$options" | fuzzel --lines 5 --dmenu)"
case $chosen in
$option0)
swaylock;;
$option1)
swaymsg exit;;
$option2)
systemctl suspend;;
$option3)
systemctl reboot;;
$option4)
systemctl poweroff;;
esac

View file

@ -0,0 +1,7 @@
#!/bin/bash
file=${RANDOM}
echo 'What is your city?:'
read city1
city2="$(echo ${city1} | sed 's#[[:space:]]#_#g')"
w3m https://wttr.in/"${city2}"

View file

@ -0,0 +1,311 @@
#!/usr/bin/env bash
# __ _ _ _ _ _ _
# _ __ ___ / _(_) | |__ | |_ _ ___| |_ ___ ___ | |_| |__
# | '__/ _ \| |_| |_____| '_ \| | | | |/ _ \ __/ _ \ / _ \| __| '_ \
# | | | (_) | _| |_____| |_) | | |_| | __/ || (_) | (_) | |_| | | |
# |_| \___/|_| |_| |_.__/|_|\__,_|\___|\__\___/ \___/ \__|_| |_|
#
# Author: Nick Clyde (clydedroid)
#
# A script that generates a rofi menu that uses bluetoothctl to
# connect to bluetooth devices and display status info.
#
# Inspired by networkmanager-dmenu (https://github.com/firecat53/networkmanager-dmenu)
# Thanks to x70b1 (https://github.com/polybar/polybar-scripts/tree/master/polybar-scripts/system-bluetooth-bluetoothctl)
#
# Depends on:
# Arch repositories: rofi, bluez-utils (contains bluetoothctl)
# Constants
divider="---------"
goback="Back"
# Checks if bluetooth controller is powered on
power_on() {
if bluetoothctl show | grep -q "Powered: yes"; then
return 0
else
return 1
fi
}
# Toggles power state
toggle_power() {
if power_on; then
bluetoothctl power off
show_menu
else
if rfkill list bluetooth | grep -q 'blocked: yes'; then
rfkill unblock bluetooth && sleep 3
fi
bluetoothctl power on
show_menu
fi
}
# Checks if controller is scanning for new devices
scan_on() {
if bluetoothctl show | grep -q "Discovering: yes"; then
echo "Scan: on"
return 0
else
echo "Scan: off"
return 1
fi
}
# Toggles scanning state
toggle_scan() {
if scan_on; then
kill $(pgrep -f "bluetoothctl scan on")
bluetoothctl scan off
show_menu
else
bluetoothctl scan on &
echo "Scanning..."
sleep 5
show_menu
fi
}
# Checks if controller is able to pair to devices
pairable_on() {
if bluetoothctl show | grep -q "Pairable: yes"; then
echo "Pairable: on"
return 0
else
echo "Pairable: off"
return 1
fi
}
# Toggles pairable state
toggle_pairable() {
if pairable_on; then
bluetoothctl pairable off
show_menu
else
bluetoothctl pairable on
show_menu
fi
}
# Checks if controller is discoverable by other devices
discoverable_on() {
if bluetoothctl show | grep -q "Discoverable: yes"; then
echo "Discoverable: on"
return 0
else
echo "Discoverable: off"
return 1
fi
}
# Toggles discoverable state
toggle_discoverable() {
if discoverable_on; then
bluetoothctl discoverable off
show_menu
else
bluetoothctl discoverable on
show_menu
fi
}
# Checks if a device is connected
device_connected() {
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Connected: yes"; then
return 0
else
return 1
fi
}
# Toggles device connection
toggle_connection() {
if device_connected $1; then
bluetoothctl disconnect $1
device_menu "$device"
else
bluetoothctl connect $1
device_menu "$device"
fi
}
# Checks if a device is paired
device_paired() {
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Paired: yes"; then
echo "Paired: yes"
return 0
else
echo "Paired: no"
return 1
fi
}
# Toggles device paired state
toggle_paired() {
if device_paired $1; then
bluetoothctl remove $1
device_menu "$device"
else
bluetoothctl pair $1
device_menu "$device"
fi
}
# Checks if a device is trusted
device_trusted() {
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Trusted: yes"; then
echo "Trusted: yes"
return 0
else
echo "Trusted: no"
return 1
fi
}
# Toggles device connection
toggle_trust() {
if device_trusted $1; then
bluetoothctl untrust $1
device_menu "$device"
else
bluetoothctl trust $1
device_menu "$device"
fi
}
# Prints a short string with the current bluetooth status
# Useful for status bars like polybar, etc.
print_status() {
if power_on; then
printf ''
mapfile -t paired_devices < <(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
counter=0
for device in "${paired_devices[@]}"; do
if device_connected $device; then
device_alias=$(bluetoothctl info $device | grep "Alias" | cut -d ' ' -f 2-)
if [ $counter -gt 0 ]; then
printf ", %s" "$device_alias"
else
printf " %s" "$device_alias"
fi
((counter++))
fi
done
printf "\n"
else
echo ""
fi
}
# A submenu for a specific device that allows connecting, pairing, and trusting
device_menu() {
device=$1
# Get device name and mac address
device_name=$(echo $device | cut -d ' ' -f 3-)
mac=$(echo $device | cut -d ' ' -f 2)
# Build options
if device_connected $mac; then
connected="Connected: yes"
else
connected="Connected: no"
fi
paired=$(device_paired $mac)
trusted=$(device_trusted $mac)
options="$connected\n$paired\n$trusted\n$divider\n$goback\nExit"
# Open rofi menu, read chosen option
chosen="$(echo -e "$options" | $rofi_command "$device_name")"
# Match chosen option to command
case $chosen in
"" | $divider)
echo "No option chosen."
;;
$connected)
toggle_connection $mac
;;
$paired)
toggle_paired $mac
;;
$trusted)
toggle_trust $mac
;;
$goback)
show_menu
;;
esac
}
# Opens a rofi menu with current bluetooth status and options to connect
show_menu() {
# Get menu options
if power_on; then
power="Power: on"
# Human-readable names of devices, one per line
# If scan is off, will only list paired devices
devices=$(bluetoothctl devices | grep Device | cut -d ' ' -f 3-)
# Get controller flags
scan=$(scan_on)
pairable=$(pairable_on)
discoverable=$(discoverable_on)
# Options passed to rofi
options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nExit"
else
power="Power: off"
options="$power\nExit"
fi
# Open rofi menu, read chosen option
chosen="$(echo -e "$options" | $rofi_command "Bluetooth")"
# Match chosen option to command
case $chosen in
"" | $divider)
echo "No option chosen."
;;
$power)
toggle_power
;;
$scan)
toggle_scan
;;
$discoverable)
toggle_discoverable
;;
$pairable)
toggle_pairable
;;
*)
device=$(bluetoothctl devices | grep "$chosen")
# Open a submenu if a device is selected
if [[ $device ]]; then device_menu "$device"; fi
;;
esac
}
# Rofi command to pipe into, can add any options here
rofi_command="rofi -dmenu -no-fixed-num-lines -yoffset -100 -i -p"
case "$1" in
--status)
print_status
;;
*)
show_menu
;;
esac

View file

@ -0,0 +1,69 @@
#!/bin/sh
function checkConfig(){
if [ ! -f "$HOME/.config/wlsunset/config" ];
then
mkdir -p $HOME/.config/wlsunset
echo 'temp_low="4000"
temp_high="6500"
sunrise="07:00"
sunset="23:00"
duration="900"
location="off"
' >> $HOME/.config/wlsunset/config
fi
}
#Startup function
function onSunSet(){
checkConfig
source $HOME/.config/wlsunset/config
if [ ${location} = "on" ];
then
CONTENT=$(curl -s https://freegeoip.app/json/)
longitude=$(echo $CONTENT | jq .longitude)
latitude=$(echo $CONTENT | jq .latitude)
if [ -e $longitude ];
then
echo location ERROR: freegeoip.app
longitude='65'
latitude='60'
else
echo location OK: $latitude $longitude
fi
wlsunset -l $latitude -L $longitude -t $temp_low -T $temp_high -d $duration &
else
wlsunset -t $temp_low -T $temp_high -d $duration -S $sunrise -s $sunset &
fi
}
#Accepts managing parameter
case $1'' in
'off')
pkill wlsunset
;;
'on')
onSunSet
;;
'toggle')
if pkill -0 wlsunset
then
pkill wlsunset
else
onSunSet
fi
;;
esac
#Returns a string for Waybar
if pkill -0 wlsunset
then
class="on"
else
class="off"
fi
printf '{"alt":"%s"}\n' "$class"

View file

@ -0,0 +1,6 @@
#!/bin/bash
system="$(uptime | awk '{print $3}' | tr -d \,)"
user=$(whoami)
echo "<big></big> ${user^}<big></big>$system"

View file

@ -0,0 +1,114 @@
#!/usr/bin/env python
import json
import requests
from datetime import datetime
WEATHER_CODES = {
'113': '☀️',
'116': '⛅️',
'119': '☁️',
'122': '☁️',
'143': '🌫',
'176': '🌦',
'179': '🌧',
'182': '🌧',
'185': '🌧',
'200': '',
'227': '🌨',
'230': '❄️',
'248': '🌫',
'260': '🌫',
'263': '🌦',
'266': '🌦',
'281': '🌧',
'284': '🌧',
'293': '🌦',
'296': '🌦',
'299': '🌧',
'302': '🌧',
'305': '🌧',
'308': '🌧',
'311': '🌧',
'314': '🌧',
'317': '🌧',
'320': '🌨',
'323': '🌨',
'326': '🌨',
'329': '❄️',
'332': '❄️',
'335': '❄️',
'338': '❄️',
'350': '🌧',
'353': '🌦',
'356': '🌧',
'359': '🌧',
'362': '🌧',
'365': '🌧',
'368': '🌨',
'371': '❄️',
'374': '🌧',
'377': '🌧',
'386': '',
'389': '🌩',
'392': '',
'395': '❄️'
}
data = {}
weather = requests.get("https://wttr.in/?format=j1").json()
def format_time(time):
return time.replace("00", "").zfill(2)
def format_temp(temp):
return (hour['FeelsLikeC']+"°").ljust(3)
def format_chances(hour):
chances = {
"chanceoffog": "Fog",
"chanceoffrost": "Frost",
"chanceofovercast": "Overcast",
"chanceofrain": "Rain",
"chanceofsnow": "Snow",
"chanceofsunshine": "Sunshine",
"chanceofthunder": "Thunder",
"chanceofwindy": "Wind"
}
conditions = []
for event in chances.keys():
if int(hour[event]) > 0:
conditions.append(chances[event]+" "+hour[event]+"%")
return ", ".join(conditions)
data['text'] = WEATHER_CODES[weather['current_condition'][0]['weatherCode']] + \
" "+weather['current_condition'][0]['FeelsLikeC']+"°"
data['tooltip'] = f"<b>{weather['current_condition'][0]['weatherDesc'][0]['value']} {weather['current_condition'][0]['temp_C']}°</b>\n"
data['tooltip'] += f"Feels like: {weather['current_condition'][0]['FeelsLikeC']}°\n"
data['tooltip'] += f"Wind: {weather['current_condition'][0]['windspeedKmph']}Km/h\n"
data['tooltip'] += f"Humidity: {weather['current_condition'][0]['humidity']}%\n"
for i, day in enumerate(weather['weather']):
data['tooltip'] += f"\n<b>"
if i == 0:
data['tooltip'] += "Today, "
if i == 1:
data['tooltip'] += "Tomorrow, "
data['tooltip'] += f"{day['date']}</b>\n"
data['tooltip'] += f"⬆️ {day['maxtempC']}° ⬇️ {day['mintempC']}° "
data['tooltip'] += f"🌅 {day['astronomy'][0]['sunrise']} 🌇 {day['astronomy'][0]['sunset']}\n"
for hour in day['hourly']:
if i == 0:
if int(format_time(hour['time'])) < datetime.now().hour-2:
continue
data['tooltip'] += f"{format_time(hour['time'])} {WEATHER_CODES[hour['weatherCode']]} {format_temp(hour['FeelsLikeC'])} {hour['weatherDesc'][0]['value']}, {format_chances(hour)}\n"
print(json.dumps(data))

View file

@ -0,0 +1,10 @@
#!/usr/bin/env sh
# Terminate already running instances
killall -q waybar
# Wait until the processes have been shut down
while pgrep -x waybar >/dev/null; do sleep 1; done
# Launch main
waybar

View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
text=$(curl -s "https://wttr.in/$1?format=%c+%f+%m")
if [[ $? == 0 ]]
then
text=$(echo "$text" | sed -E "s/\s+/ /g")
tooltip=$(curl -s "https://wttr.in/$1?format=%l:+%C+%c+%t+%w+%m")
if [[ $? == 0 ]]
then
tooltip=$(echo "$tooltip" | sed -E "s/\s+/ /g")
echo "{\"text\":\"$text\", \"tooltip\":\"$tooltip\"}"
exit
fi
fi
echo "{\"text\":\"Service Unavailable\", \"tooltip\":\"Service Unavailable\"}"

View file

@ -0,0 +1,5 @@
#!/usr/bin/sh
req=$(curl -s wttr.in/CITY?format="%t|%l+(%c%f)+%h,+%C")
bar=$(echo $req | awk -F "|" '{print $1}')
tooltip=$(echo $req | awk -F "|" '{print $2}')
echo "{\"text\":\"$bar\", \"tooltip\":\"$tooltip\"}"