Add files via upload

This commit is contained in:
Quinta
2023-03-18 22:21:53 +01:00
committed by GitHub
commit fd733cd338
100 changed files with 8809 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
# this requires a service for clash at /usr/lib/systemd/system
service=$(systemctl is-active --user clash)
case $1 in
"toggle")
if [ $service == 'active' ]
then
systemctl stop --user clash
printf '%s' '%{F#4c566a}%{F-}'
else
systemctl start --user clash
printf '%s' '%{F#a3be8c}%{F-}'
fi
;;
"")
if [ $service == "active" ]
then
printf '%s' '%{F#a3be8c}%{F-}'
else
printf '%s' '%{F#4c566a}%{F-}'
fi
esac
+36
View File
@@ -0,0 +1,36 @@
#!/bin/sh
# this requires a service for clipmenu at /usr/lib/systemd/system
service=$(systemctl is-active --user clipmenud)
dmenu_launcher=rofi
case $1 in
"toggle")
if [ $service == 'active' ]
then
systemctl stop --user clipmenud
printf '%s' '%{F#4c566a}%{F-}'
else
systemctl start --user clipmenud
printf '%s' '%{F#a3be8c}%{F-}'
fi
;;
"menu")
if [ $service == 'active' ]
then
CM_LAUNCHER=$dmenu_launcher clipmenu
printf '%s' '%{F#a3be8c}%{F-}'
else
printf '%s' '%{F#4c566a}%{F-}'
fi
;;
"")
if [ $service == "active" ]
then
printf '%s' '%{F#a3be8c}%{F-}'
else
printf '%s' '%{F#4c566a}%{F-}'
fi
esac
Binary file not shown.
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
# this requires a service for onedrive at /usr/lib/systemd/system
service=$(systemctl is-active --user onedrive)
case $1 in
"toggle")
if [ $service == 'active' ]
then
systemctl stop --user onedrive
printf '%s' '%{F#bf616a}%{F-}'
else
systemctl start --user onedrive
printf '%s' '%{F#bf616a}%{F-}'
fi
;;
"")
if [ $service == "active" ]
then
printf '%s' '%{F#bf616a}%{F-}'
else
printf '%s' '%{F#bf616a}%{F-}'
fi
esac
@@ -0,0 +1,96 @@
#!/bin/sh
get_icon() {
case $1 in
01d) icon="";;
01n) icon="";;
02d) icon="";;
02n) icon="";;
03*) icon="";;
04*) icon="";;
09d) icon="";;
09n) icon="";;
10d) icon="";;
10n) icon="";;
11d) icon="";;
11n) icon="";;
13d) icon="";;
13n) icon="";;
50d) icon="";;
50n) icon="";;
*) icon="";
esac
echo $icon
}
get_duration() {
osname=$(uname -s)
case $osname in
*BSD) date -r "$1" -u +%H:%M;;
*) date --date="@$1" -u +%H:%M;;
esac
}
KEY="62628c16e6247d2c1caf0cb398a3dffa"
CITY="Agartala"
UNITS="metric"
SYMBOL="°"
API="https://api.openweathermap.org/data/2.5"
if [ -n "$CITY" ]; then
if [ "$CITY" -eq "$CITY" ] 2>/dev/null; then
CITY_PARAM="id=$CITY"
else
CITY_PARAM="q=$CITY"
fi
current=$(curl -sf "$API/weather?appid=$KEY&$CITY_PARAM&units=$UNITS")
forecast=$(curl -sf "$API/forecast?appid=$KEY&$CITY_PARAM&units=$UNITS&cnt=1")
else
location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
if [ -n "$location" ]; then
location_lat="$(echo "$location" | jq '.location.lat')"
location_lon="$(echo "$location" | jq '.location.lng')"
current=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS")
forecast=$(curl -sf "$API/forecast?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS&cnt=1")
fi
fi
if [ -n "$current" ] && [ -n "$forecast" ]; then
current_temp=$(echo "$current" | jq ".main.temp" | cut -d "." -f 1)
current_icon=$(echo "$current" | jq -r ".weather[0].icon")
forecast_temp=$(echo "$forecast" | jq ".list[].main.temp" | cut -d "." -f 1)
forecast_icon=$(echo "$forecast" | jq -r ".list[].weather[0].icon")
if [ "$current_temp" -gt "$forecast_temp" ]; then
trend=""
elif [ "$forecast_temp" -gt "$current_temp" ]; then
trend=""
else
trend=""
fi
sun_rise=$(echo "$current" | jq ".sys.sunrise")
sun_set=$(echo "$current" | jq ".sys.sunset")
now=$(date +%s)
if [ "$sun_rise" -gt "$now" ]; then
daytime="$(get_duration "$((sun_rise-now))")"
elif [ "$sun_set" -gt "$now" ]; then
daytime="$(get_duration "$((sun_set-now))")"
else
daytime="$(get_duration "$((sun_rise-now))")"
fi
echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL $daytime"
fi
+4
View File
@@ -0,0 +1,4 @@
潮打三更瓜步月,雨荒十里红桥火。
清代-郑燮 满江红·思家
凌晨,晚上
0
+122
View File
@@ -0,0 +1,122 @@
#!/usr/bin/env bash
# CONFIGURATION
LOCATION=0
YOFFSET=0
XOFFSET=0
WIDTH=12
WIDTH_WIDE=24
THEME=$HOME/.local/share/rofi/themes/squared-everforest.rasi
# Color Settings of Icon shown in Polybar
COLOR_DISCONNECTED='#000' # Device Disconnected
COLOR_NEWDEVICE='#ff0' # New Device
COLOR_BATTERY_90='#fabd2f' # Battery >= 90
COLOR_BATTERY_80='#fabd2f' # Battery >= 80
COLOR_BATTERY_70='#fabd2f' # Battery >= 70
COLOR_BATTERY_60='#fabd2f' # Battery >= 60
COLOR_BATTERY_50='#fb493f' # Battery >= 50
COLOR_BATTERY_LOW='#fb493f' # Battery < 50
# Icons shown in Polybar
ICON_SMARTPHONE=''
ICON_TABLET=''
SEPERATOR='|'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
show_devices (){
IFS=$','
devices=""
for device in $(qdbus --literal org.kde.kdeconnect /modules/kdeconnect org.kde.kdeconnect.daemon.devices); do
deviceid=$(echo "$device" | awk -F'["|"]' '{print $2}')
devicename=$(qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$deviceid" org.kde.kdeconnect.device.name)
devicetype=$(qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$deviceid" org.kde.kdeconnect.device.type)
isreach="$(qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$deviceid" org.kde.kdeconnect.device.isReachable)"
istrust="$(qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$deviceid" org.kde.kdeconnect.device.isTrusted)"
if [ "$isreach" = "true" ] && [ "$istrust" = "true" ]
then
battery="$(qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$deviceid/battery" org.kde.kdeconnect.device.battery.charge)"
icon=$(get_icon "$battery" "$devicetype")
devices+="%{A1:$DIR/polybar-kdeconnect.sh -n '$devicename' -i $deviceid -b $battery -m:}$icon%{A}$SEPERATOR"
elif [ "$isreach" = "false" ] && [ "$istrust" = "true" ]
then
devices+="$(get_icon -1 "$devicetype")$SEPERATOR"
else
haspairing="$(qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$deviceid" org.kde.kdeconnect.device.hasPairingRequests)"
if [ "$haspairing" = "true" ]
then
show_pmenu2 "$devicename" "$deviceid"
fi
icon=$(get_icon -2 "$devicetype")
devices+="%{A1:$DIR/polybar-kdeconnect.sh -n $devicename -i $deviceid -p:}$icon%{A}$SEPERATOR"
fi
done
echo "${devices::-1}"
}
show_menu () {
menu="$(rofi -sep "|" -dmenu -i -p "$DEV_NAME" -location $LOCATION -yoffset $YOFFSET -xoffset $XOFFSET -theme $THEME -width $WIDTH -hide-scrollbar -line-padding 4 -padding 20 -lines 5 <<< "Battery: $DEV_BATTERY%|Ping|Find Device|Send File|Browse Files|Unpair")"
case "$menu" in
*Ping) qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$DEV_ID/ping" org.kde.kdeconnect.device.ping.sendPing ;;
*'Find Device') qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$DEV_ID/findmyphone" org.kde.kdeconnect.device.findmyphone.ring ;;
*'Send File') qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$DEV_ID/share" org.kde.kdeconnect.device.share.shareUrl "file://$(zenity --file-selection)" ;;
*'Browse Files')
if "$(qdbus --literal org.kde.kdeconnect "/modules/kdeconnect/devices/$DEV_ID/sftp" org.kde.kdeconnect.device.sftp.isMounted)" == "false"; then
qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$DEV_ID/sftp" org.kde.kdeconnect.device.sftp.mount
fi
qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$DEV_ID/sftp" org.kde.kdeconnect.device.sftp.startBrowsing
;;
*'Unpair' ) qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$DEV_ID" org.kde.kdeconnect.device.unpair
esac
}
show_pmenu () {
menu="$(rofi -sep "|" -dmenu -i -p "$DEV_NAME" -location $LOCATION -yoffset $YOFFSET -xoffset $XOFFSET -theme $THEME -width $WIDTH -hide-scrollbar -line-padding 1 -padding 20 -lines 1<<<"Pair Device")"
case "$menu" in
*'Pair Device') qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$DEV_ID" org.kde.kdeconnect.device.requestPair
esac
}
show_pmenu2 () {
menu="$(rofi -sep "|" -dmenu -i -p "$1 has sent a pairing request" -location $LOCATION -yoffset $YOFFSET -xoffset $XOFFSET -theme $THEME -width $WIDTH_WIDE -hide-scrollbar -line-padding 4 -padding 20 -lines 2 <<< "Accept|Reject")"
case "$menu" in
*'Accept') qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$2" org.kde.kdeconnect.device.acceptPairing ;;
*) qdbus org.kde.kdeconnect "/modules/kdeconnect/devices/$2" org.kde.kdeconnect.device.rejectPairing
esac
}
get_icon () {
if [ "$2" = "tablet" ]
then
icon=$ICON_TABLET
else
icon=$ICON_SMARTPHONE
fi
case $1 in
"-1") ICON="%{F$COLOR_DISCONNECTED}$icon%{F-}" ;;
"-2") ICON="%{F$COLOR_NEWDEVICE}$icon%{F-}" ;;
5*) ICON="%{F$COLOR_BATTERY_50}$icon%{F-}" ;;
6*) ICON="%{F$COLOR_BATTERY_60}$icon%{F-}" ;;
7*) ICON="%{F$COLOR_BATTERY_70}$icon%{F-}" ;;
8*) ICON="%{F$COLOR_BATTERY_80}$icon%{F-}" ;;
9*|100) ICON="%{F$COLOR_BATTERY_90}$icon%{F-}" ;;
*) ICON="%{F$COLOR_BATTERY_LOW}$icon%{F-}" ;;
esac
echo $ICON
}
unset DEV_ID DEV_NAME DEV_BATTERY
while getopts 'di:n:b:mp' c
do
# shellcheck disable=SC2220
case $c in
d) show_devices ;;
i) DEV_ID=$OPTARG ;;
n) DEV_NAME=$OPTARG ;;
b) DEV_BATTERY=$OPTARG ;;
m) show_menu ;;
p) show_pmenu ;;
esac
done
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
rofi -show run -theme nord-oneline
+141
View File
@@ -0,0 +1,141 @@
#!/usr/bin/env python
import sys
import dbus
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'-t',
'--trunclen',
type=int,
metavar='trunclen'
)
parser.add_argument(
'-f',
'--format',
type=str,
metavar='custom format',
dest='custom_format'
)
parser.add_argument(
'-p',
'--playpause',
type=str,
metavar='play-pause indicator',
dest='play_pause'
)
parser.add_argument(
'--font',
type=str,
metavar='the index of the font to use for the main label',
dest='font'
)
parser.add_argument(
'--playpause-font',
type=str,
metavar='the index of the font to use to display the playpause indicator',
dest='play_pause_font'
)
parser.add_argument(
'-q',
'--quiet',
action='store_true',
help="if set, don't show any output when the current song is paused",
dest='quiet',
)
args = parser.parse_args()
def fix_string(string):
# corrects encoding for the python version used
if sys.version_info.major == 3:
return string
else:
return string.encode('utf-8')
def truncate(name, trunclen):
if len(name) > trunclen:
name = name[:trunclen]
name += '...'
if ('(' in name) and (')' not in name):
name += ')'
return name
# Default parameters
output = fix_string(u'{play_pause} {artist}: {song}')
trunclen = 35
play_pause = fix_string(u'\u25B6,\u23F8') # first character is play, second is paused
label_with_font = '%{{T{font}}}{label}%{{T-}}'
font = args.font
play_pause_font = args.play_pause_font
quiet = args.quiet
# parameters can be overwritten by args
if args.trunclen is not None:
trunclen = args.trunclen
if args.custom_format is not None:
output = args.custom_format
if args.play_pause is not None:
play_pause = args.play_pause
try:
session_bus = dbus.SessionBus()
spotify_bus = session_bus.get_object(
'org.mpris.MediaPlayer2.spotify',
'/org/mpris/MediaPlayer2'
)
spotify_properties = dbus.Interface(
spotify_bus,
'org.freedesktop.DBus.Properties'
)
metadata = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'Metadata')
status = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus')
# Handle play/pause label
play_pause = play_pause.split(',')
if status == 'Playing':
play_pause = play_pause[0]
elif status == 'Paused':
play_pause = play_pause[1]
else:
play_pause = str()
if play_pause_font:
play_pause = label_with_font.format(font=play_pause_font, label=play_pause)
# Handle main label
artist = fix_string(metadata['xesam:artist'][0]) if metadata['xesam:artist'] else ''
song = fix_string(metadata['xesam:title']) if metadata['xesam:title'] else ''
album = fix_string(metadata['xesam:album']) if metadata['xesam:album'] else ''
if (quiet and status == 'Paused') or (not artist and not song and not album):
print('')
else:
if font:
artist = label_with_font.format(font=font, label=artist)
song = label_with_font.format(font=font, label=song)
album = label_with_font.format(font=font, label=album)
# Add 4 to trunclen to account for status symbol, spaces, and other padding characters
print(truncate(output.format(artist=artist,
song=song,
play_pause=play_pause,
album=album), trunclen + 4))
except Exception as e:
if isinstance(e, dbus.exceptions.DBusException):
print('')
else:
print(e)
+9
View File
@@ -0,0 +1,9 @@
#! /bin/bash
if pgrep -x redshift > /dev/null
then
pgrep redshift | xargs -n1 kill -9 | notify-send 'Redshift stopped'
else
notify-send 'Redshift started'
redshift &
fi