Some config files added

This commit is contained in:
ManOfGoldForever 2025-11-10 12:37:40 -05:00
commit 7e2ddc1054
33 changed files with 1470 additions and 0 deletions

12
.config/waybar/colors.css Normal file
View file

@ -0,0 +1,12 @@
@define-color background-darker rgba(30, 31, 41, 230);
@define-color background #282a36;
@define-color selection #44475a;
@define-color foreground #f8f8f2;
@define-color comment #6272a4;
@define-color cyan #8be9fd;
@define-color green #50fa7b;
@define-color orange #ffb86c;
@define-color pink #ff79c6;
@define-color purple #bd93f9;
@define-color red #ff5555;
@define-color yellow #f1fa8c;

79
.config/waybar/config Normal file
View file

@ -0,0 +1,79 @@
{
"layer": "top",
"position": "top",
"height": 24,
"spacing": 4,
"modules-left": [
"hyprland/workspaces",
],
"modules-center": [
"hyprland/window"
],
"modules-right": [
"custom/media",
"custom/updates",
"custom/storage",
"tray",
"clock"
],
"wlr/taskbar": {
"on-click": "activate",
"on-click-middle": "close",
"ignore-list": [
"foot"
]
},
"hyprland/workspaces": {
"on-click": "activate",
"on-scroll-up": "hyprctl dispatch workspace e-1",
"on-scroll-down": "hyprctl dispatch workspace e+1"
},
"hyprland/window": {
"max-length": 128
},
"clock": {
"format": "{:%m/%d/%Y %I:%M %p}",
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>"
},
"tray": {
"spacing": 4
},
"custom/weather": {
"exec": "~/.config/waybar/wittr.sh",
"return-type": "json",
"format": "{}",
"tooltip": true,
"interval": 900
},
"custom/spotify": {
"exec": "~/.config/waybar/modules/spotify.sh",
"return-type": "json",
"format": "{}",
"tooltip": false,
"interval": 5
},
"custom/media": {
"exec": "~/.config/waybar/mediaplayer.py --player spotify_player",
"return-type": "json",
"interval": 0,
"on-click": "playerctl play-pause",
"tooltip": false
},
"custom/storage": {
"exec": "~/.config/waybar/modules/storage.sh",
"return-type": "json",
"interval": 900,
"format": "{}",
"tooltip": false
},
"custom/updates": {
"exec": "~/.config/waybar/modules/update-check.sh",
"interval": 900,
"return-type": "json",
"format": "{text}",
"on-click": "kitty -e fish -ic 'update'",
"on-output": "class: no-updates",
"on-error": "class: updates-available",
"tooltip": false
},
}

127
.config/waybar/mediaplayer.py Executable file
View file

@ -0,0 +1,127 @@
#!/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 occurance 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)
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()

42
.config/waybar/modules/mail.py Executable file
View file

@ -0,0 +1,42 @@
#!/usr/bin/python
import os
import imaplib
import mailsecrets
def getmails(username, password, server):
imap = imaplib.IMAP4_SSL(server, 993)
imap.login(username, password)
imap.select('INBOX')
ustatus, uresponse = imap.uid('search', None, 'UNSEEN')
if ustatus == 'OK':
unread_msg_nums = uresponse[0].split()
else:
unread_msg_nums = []
fstatus, fresponse = imap.uid('search', None, 'FLAGGED')
if fstatus == 'OK':
flagged_msg_nums = fresponse[0].split()
else:
flagged_msg_nums = []
return [len(unread_msg_nums), len(flagged_msg_nums)]
ping = os.system("ping " + mailsecrets.server + " -c1 > /dev/null 2>&1")
if ping == 0:
mails = getmails(mailsecrets.username, mailsecrets.password, mailsecrets.server)
text = ''
alt = ''
if mails[0] > 0:
text = alt = str(mails[0])
if mails[1] > 0:
alt = str(mails[1]) + "" + alt
else:
exit(1)
print('{"text":"' + text + '", "alt": "' + alt + '"}')
else:
exit(1)

View file

@ -0,0 +1,18 @@
#!/bin/sh
class=$(playerctl metadata --player=spotify_player --format '{{lc(status)}}')
icon=""
if [[ $class == "playing" ]]; then
info=$(playerctl metadata --player=spotify_player --format '{{artist}} - {{title}}')
if [[ ${#info} > 40 ]]; then
info=$(echo $info | cut -c1-40)"..."
fi
text=$info" "$icon
elif [[ $class == "paused" ]]; then
text=$icon
elif [[ $class == "stopped" ]]; then
text=""
fi
echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}"

View file

@ -0,0 +1,24 @@
#!/bin/sh
mount="/"
warning=20
critical=10
df -h -P -l "$mount" | awk -v warning=$warning -v critical=$critical '
/\/.*/ {
text=$5
tooltip="Filesystem: "$1"\rSize: "$2"\rUsed: "$3"\rAvail: "$4"\rUse%: "$5"\rMounted on: "$6
use=$5
exit 0
}
END {
class=""
gsub(/%$/,"",use)
if ((100 - use) < critical) {
class="critical"
} else if ((100 - use) < warning) {
class="warning"
}
print "{\"text\":\""text"\", \"percentage\":"use",\"tooltip\":\""tooltip"\", \"class\":\""class"\"}"
}
'

View file

@ -0,0 +1,8 @@
#!/bin/bash
updates=$(($(checkupdates 2>/dev/null | wc -l) + $(paru -Qum 2>/dev/null | wc -l)))
if [ "$updates" -gt 0 ]; then
echo '{"text":"⟳","class":"updates-available"}'
else
echo '{"text":"⟳","class":"no-updates"}'
fi

View file

@ -0,0 +1,79 @@
#!/bin/bash
cachedir=~/.cache/rbn
cachefile=${0##*/}-$1
if [ ! -d $cachedir ]; then
mkdir -p $cachedir
fi
if [ ! -f $cachedir/$cachefile ]; then
touch $cachedir/$cachefile
fi
# Save current IFS
SAVEIFS=$IFS
# Change IFS to new line.
IFS=$'\n'
cacheage=$(($(date +%s) - $(stat -c '%Y' "$cachedir/$cachefile")))
if [ $cacheage -gt 1740 ] || [ ! -s $cachedir/$cachefile ]; then
data=($(curl -s https://en.wttr.in/$1\?0qnT 2>&1))
echo ${data[0]} | cut -f1 -d, > $cachedir/$cachefile
echo ${data[1]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile
echo ${data[2]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile
fi
weather=($(cat $cachedir/$cachefile))
# Restore IFSClear
IFS=$SAVEIFS
temperature=$(echo ${weather[2]} | sed -E 's/([[:digit:]])+\.\./\1 to /g')
#echo ${weather[1]##*,}
# https://fontawesome.com/icons?s=solid&c=weather
case $(echo ${weather[1]##*,} | tr '[:upper:]' '[:lower:]') in
"clear" | "sunny")
condition=""
;;
"partly cloudy")
condition="杖"
;;
"cloudy")
condition=""
;;
"overcast")
condition=""
;;
"mist" | "fog" | "freezing fog")
condition=""
;;
"patchy rain possible" | "patchy light drizzle" | "light drizzle" | "patchy light rain" | "light rain" | "light rain shower" | "rain")
condition=""
;;
"moderate rain at times" | "moderate rain" | "heavy rain at times" | "heavy rain" | "moderate or heavy rain shower" | "torrential rain shower" | "rain shower")
condition=""
;;
"patchy snow possible" | "patchy sleet possible" | "patchy freezing drizzle possible" | "freezing drizzle" | "heavy freezing drizzle" | "light freezing rain" | "moderate or heavy freezing rain" | "light sleet" | "ice pellets" | "light sleet showers" | "moderate or heavy sleet showers")
condition="ﭽ"
;;
"blowing snow" | "moderate or heavy sleet" | "patchy light snow" | "light snow" | "light snow showers")
condition="流"
;;
"blizzard" | "patchy moderate snow" | "moderate snow" | "patchy heavy snow" | "heavy snow" | "moderate or heavy snow with thunder" | "moderate or heavy snow showers")
condition="ﰕ"
;;
"thundery outbreaks possible" | "patchy light rain with thunder" | "moderate or heavy rain with thunder" | "patchy light snow with thunder")
condition=""
;;
*)
condition=""
echo -e "{\"text\":\""$condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"
;;
esac
#echo $temp $condition
echo -e "{\"text\":\""$temperature $condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"

44
.config/waybar/style.css Normal file
View file

@ -0,0 +1,44 @@
@import url("./colors.css");
* {
border: none;
border-radius: 0;
font-family: Iosevka;
font-size: 11pt;
min-height: 0;
}
window#waybar {
opacity: 1;
background: @background-darker;
color: @foreground;
border-bottom: 2px solid @background;
}
#workspaces button {
padding: 0 10px;
background: @background;
color: @foreground;
}
#workspaces button:hover {
box-shadow: inherit;
text-shadow: inherit;
background-image: linear-gradient(0deg, @selection, @background-darker);
}
#workspaces button.focused,
#workspaces button.active {
background-image: linear-gradient(0deg, @purple, @selection);
}
#workspaces button.urgent {
background-image: linear-gradient(0deg, @red, @background-darker);
}
#taskbar button.active {
background-image: linear-gradient(0deg, @selection, @background-darker);
}
#clock {
padding: 0 4px;
background: @background;
}
#custom-updates.no-updates {
color: #f8f8f2;
}
#custom-updates.updates-available {
color: #bd93f9;
}

10
.config/waybar/waybar.sh Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env sh
# Terminate already running bar 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 &

5
.config/waybar/wittr.sh Executable file
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\"}"