diff --git a/hypr/.gitignore b/hypr/.gitignore deleted file mode 100644 index 2645bda..0000000 --- a/hypr/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -!* -!*/** \ No newline at end of file diff --git a/waybar/config b/waybar/config new file mode 100644 index 0000000..04f992e --- /dev/null +++ b/waybar/config @@ -0,0 +1,127 @@ +{ + "layer": "bottom", + "position": "top", + "height": 30, + "spacing": 2, + "exclusive": true, + "gtk-layer-shell": true, + "passthrough": false, + "fixed-center": true, + "modules-left": [ + "hyprland/workspaces", + "hyprland/window" + ], + "modules-center": [ + "custom/notification", + "clock", + "clock#simpleclock" + ], + "modules-right": [ + "mpris", + "cpu", + "memory", + "pulseaudio", + "tray", + "custom/power" + ], + "custom/spotify": { + "format": " {}", + "return-type": "json", + "on-click": "playerctl -p spotify play-pause", + "on-click-right": "spotifatius toggle-liked", + "on-click-middle": "playerctl -p spotify next", + "exec": "spotifatius monitor" + }, + "mpris": { + "player": "spotify", + "dynamic-order": [ + "artist", + "title" + ], + "format": "{player_icon} {dynamic}", + "format-paused": "{status_icon} {dynamic}", + "status-icons": { + "paused": "" + }, + "player-icons": { + "default": "" + } + }, + "hyprland/workspaces": { + "on-click": "activate", + "format": "{id}", + "all-outputs": true, + "disable-scroll": false, + "active-only": false + }, + "hyprland/window": { + "format": "{title}" + }, + "tray": { + "show-passive-items": true, + "spacing": 10 + }, + "clock#simpleclock": { + "tooltip": false, + "format": " {:%H:%M}" + }, + "clock": { + "format": " {:L%a %d %b}", + "calendar": { + "format": { + "days": "{}", + "months": "{}", + "today": "{}", + "weekdays": "{}", + "weeks": "W{}" + }, + "mode": "month", + "mode-mon-col": 1, + "on-scroll": 1 + }, + "tooltip-format": "{calendar}" + }, + "cpu": { + "format": " {usage}%", + "tooltip": true, + "interval": 1 + }, + "memory": { + "format": " {percentage}%" + }, + "pulseaudio": { + "format": "{icon} {volume}%", + "format-muted": " muted", + "format-icons": { + "headphone": "", + "default": [ + " ", + " ", + " " + ] + }, + "on-click": "pavucontrol" + }, + "custom/sep": { + "format": "|", + "tooltip": false + }, + "custom/power": { + "tooltip": false, + "on-click": "wlogout -p layer-shell &", + "format": "⏻" + }, + "custom/notification": { + "escape": true, + "exec": "swaync-client -swb", + "exec-if": "which swaync-client", + "format": "{icon}", + "format-icons": { + "none": "󰅺", + "notification": "󰡟" + }, + "on-click": "sleep 0.1 && swaync-client -t -sw", + "return-type": "json", + "tooltip": false + } +} diff --git a/waybar/mocha.css b/waybar/mocha.css new file mode 100644 index 0000000..0eb6a82 --- /dev/null +++ b/waybar/mocha.css @@ -0,0 +1,26 @@ +@define-color rosewater #f5e0dc; +@define-color flamingo #f2cdcd; +@define-color pink #f5c2e7; +@define-color mauve #cba6f7; +@define-color red #f38ba8; +@define-color maroon #eba0ac; +@define-color peach #fab387; +@define-color yellow #f9e2af; +@define-color green #a6e3a1; +@define-color teal #94e2d5; +@define-color sky #89dceb; +@define-color sapphire #74c7ec; +@define-color blue #89b4fa; +@define-color lavender #b4befe; +@define-color text #cdd6f4; +@define-color subtext1 #bac2de; +@define-color subtext0 #a6adc8; +@define-color overlay2 #9399b2; +@define-color overlay1 #7f849c; +@define-color overlay0 #6c7086; +@define-color surface2 #585b70; +@define-color surface1 #45475a; +@define-color surface0 #313244; +@define-color base #1e1e2e; +@define-color mantle #181825; +@define-color crust #11111b; diff --git a/waybar/modules/mail.py b/waybar/modules/mail.py new file mode 100755 index 0000000..abc36ec --- /dev/null +++ b/waybar/modules/mail.py @@ -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) diff --git a/waybar/modules/spotify.sh b/waybar/modules/spotify.sh new file mode 100755 index 0000000..c00622b --- /dev/null +++ b/waybar/modules/spotify.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +class=$(playerctl metadata --player=spotify --format '{{lc(status)}}') +icon="" + +if [[ $class == "playing" ]]; then + info=$(playerctl metadata --player=spotify --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"\"}" diff --git a/waybar/modules/storage.sh b/waybar/modules/storage.sh new file mode 100755 index 0000000..ae2a5ce --- /dev/null +++ b/waybar/modules/storage.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +mount="/" +warning=20 +critical=10 + +df -h -P -l "$mount" | awk -v warning=$warning -v critical=$critical ' +/\/.*/ { + text=$4 + 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"\"}" +} +' diff --git a/waybar/modules/weather.sh b/waybar/modules/weather.sh new file mode 100755 index 0000000..06157ef --- /dev/null +++ b/waybar/modules/weather.sh @@ -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]}"\"}" diff --git a/waybar/style-default.css b/waybar/style-default.css new file mode 100644 index 0000000..5f337dd --- /dev/null +++ b/waybar/style-default.css @@ -0,0 +1,116 @@ +* { + min-height: 0; + min-width: 0; + font-family: Lexend, "JetBrainsMono NFP"; + font-size: 16px; + font-weight: 600; +} + +window#waybar { + transition-property: background-color; + transition-duration: 0.5s; + /* background-color: #1e1e2e; */ + /* background-color: #181825; */ + background-color: #11111b; + /* background-color: rgba(24, 24, 37, 0.6); */ +} + +#workspaces button { + padding: 0.3rem 0.6rem; + margin: 0.4rem 0.25rem; + border-radius: 6px; + /* background-color: #181825; */ + background-color: #1e1e2e; + color: #cdd6f4; +} + +#workspaces button:hover { + color: #1e1e2e; + background-color: #cdd6f4; +} + +#workspaces button.active { + background-color: #1e1e2e; + color: #89b4fa; +} + +#workspaces button.urgent { + background-color: #1e1e2e; + color: #f38ba8; +} + +#clock, +#pulseaudio, +#custom-logo, +#custom-power, +#custom-spotify, +#custom-notification, +#cpu, +#tray, +#memory, +#window, +#mpris { + padding: 0.3rem 0.6rem; + margin: 0.4rem 0.25rem; + border-radius: 6px; + /* background-color: #181825; */ + background-color: #1e1e2e; +} + +#mpris.playing { + color: #a6e3a1; +} + +#mpris.paused { + color: #9399b2; +} + +#custom-sep { + padding: 0px; + color: #585b70; +} + +window#waybar.empty #window { + background-color: transparent; +} + +#cpu { + color: #94e2d5; +} + +#memory { + color: #cba6f7; +} + +#clock { + color: #74c7ec; +} + +#clock.simpleclock { + color: #89b4fa; +} + +#window { + color: #cdd6f4; +} + +#pulseaudio { + color: #b4befe; +} + +#pulseaudio.muted { + color: #a6adc8; +} + +#custom-logo { + color: #89b4fa; +} + +#custom-power { + color: #f38ba8; +} + +tooltip { + background-color: #181825; + border: 2px solid #89b4fa; +} diff --git a/waybar/style.css b/waybar/style.css new file mode 100644 index 0000000..08e85b3 --- /dev/null +++ b/waybar/style.css @@ -0,0 +1,122 @@ +* { + min-height: 0; + min-width: 0; + font-family: Lexend, "JetBrainsMono NFP"; + font-size: 16px; + font-weight: 600; +} + +window#waybar { + transition-property: background-color; + transition-duration: 0.5s; + /* background-color: #1e1e2e; */ + /* background-color: #181825; */ + background-color: transparent; + /* background-color: rgba(24, 24, 37, 0.6); */ +} + +#workspaces button { + padding: 0.3rem 0.6rem; + margin: 0.4rem 0.25rem; + border-radius: 6px; + /* background-color: #181825; */ + background-color: #1e1e2e; + color: #cdd6f4; +} + +#workspaces button:hover { + color: #1e1e2e; + background-color: #cdd6f4; +} + +#workspaces button.active { + background-color: #1e1e2e; + color: #89b4fa; +} + +#workspaces button.urgent { + background-color: #1e1e2e; + color: #f38ba8; +} + +#clock, +#pulseaudio, +#custom-logo, +#custom-power, +#custom-spotify, +#custom-notification, +#cpu, +#tray, +#custom-weather, +#idle_inhibitor, +#memory, +#window, +#mpris { + padding: 0.3rem 0.6rem; + margin: 0.4rem 0.25rem; + border-radius: 6px; + /* background-color: #181825; */ + background-color: #1e1e2e; +} + +#mpris.playing { + color: #a6e3a1; +} + +#mpris.paused { + color: #9399b2; +} + +#custom-sep { + padding: 0px; + color: #585b70; +} + +window#waybar.empty #window { + background-color: transparent; +} + +#cpu { + color: #b8f5f0; +} + +#memory { + color: #b8f5f0; +} + +#clock { + color: #89b4fa; +} + +#clock.simpleclock { + color: #89b4fa; +} + +#custom-weather{ + color: #b8f5f0; +} + +#window { + color: #cdd6f4; +} + +#pulseaudio { + color: #b8f5f0; +} + +#pulseaudio.muted { + color: #a6adc8; +} + +#custom-logo { + color: #89b4fa; +} + +#custom-power { + color: #f38ba8; +} + +tooltip { + background-color: #181825; + border: 2px solid #89b4fa; +}