init: copy from Hacmini

This commit is contained in:
2024-09-14 10:42:47 -04:00
commit 1df22c6512
384 changed files with 18925 additions and 0 deletions

13
dotfiles/scripts/autolock.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
# _ _ _ _
# / \ _ _| |_ ___ | | ___ ___| | __
# / _ \| | | | __/ _ \| |/ _ \ / __| |/ /
# / ___ \ |_| | || (_) | | (_) | (__| <
# /_/ \_\__,_|\__\___/|_|\___/ \___|_|\_\
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
pkill xautolock
xautolock -time 10 -locker "swaylock -i ~/.cache/current_wallpaper.jpg" -notify 30 -notifier "notify-send 'Screen will be locked soon.' 'Locking screen in 30 seconds'"

View File

@@ -0,0 +1,15 @@
#!/bin/bash
# ____ _ _
# | __ ) ___ ___ | | ___ __ ___ __ _ _ __| | _____
# | _ \ / _ \ / _ \| |/ / '_ ` _ \ / _` | '__| |/ / __|
# | |_) | (_) | (_) | <| | | | | | (_| | | | <\__ \
# |____/ \___/ \___/|_|\_\_| |_| |_|\__,_|_| |_|\_\___/
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
selected=$(cat ~/.config/BraveSoftware/Brave-Browser/Default/Bookmarks | grep '"url":' | awk '{print $2}' | sed 's/"//g' | rofi -dmenu -p "Select a Brave Bookmark")
if [ "$selected" ]; then
brave $selected
fi

12
dotfiles/scripts/calculator.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
# ____ _ _ _
# / ___|__ _| | ___ _ _| | __ _| |_ ___ _ __
# | | / _` | |/ __| | | | |/ _` | __/ _ \| '__|
# | |__| (_| | | (__| |_| | | (_| | || (_) | |
# \____\__,_|_|\___|\__,_|_|\__,_|\__\___/|_|
#
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
rofi -show calc

View File

@@ -0,0 +1,14 @@
#!/bin/bash
# ____ _ _ __
# | _ \| | __ _| |_ / _| ___ _ __ _ __ ___
# | |_) | |/ _` | __| |_ / _ \| '__| '_ ` _ \
# | __/| | (_| | |_| _| (_) | | | | | | | |
# |_| |_|\__,_|\__|_| \___/|_| |_| |_| |_|
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
# 3 = Desktop
# 10 = Laptop
# -----------------------------------------------------
cat /sys/class/dmi/id/chassis_type

15
dotfiles/scripts/cleanup.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
clear
cat <<"EOF"
____ _
/ ___| | ___ __ _ _ __ _ _ _ __
| | | |/ _ \/ _` | '_ \ | | | | '_ \
| |___| | __/ (_| | | | | | |_| | |_) |
\____|_|\___|\__,_|_| |_| \__,_| .__/
|_|
EOF
sudo pacman -Rns $(pacman -Qtdq)
yay -Scc

23
dotfiles/scripts/cliphist.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# ____ _ _ _ _ _
# / ___| (_)_ __ | |__ (_)___| |_
# | | | | | '_ \| '_ \| / __| __|
# | |___| | | |_) | | | | \__ \ |_
# \____|_|_| .__/|_| |_|_|___/\__|
# |_|
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
case $1 in
d) cliphist list | rofi -dmenu -replace -config ~/dotfiles/rofi/config-cliphist.rasi | cliphist delete
;;
w) if [ `echo -e "Clear\nCancel" | rofi -dmenu -config ~/dotfiles/rofi/config-short.rasi` == "Clear" ] ; then
cliphist wipe
fi
;;
*) cliphist list | rofi -dmenu -replace -config ~/dotfiles/rofi/config-cliphist.rasi | cliphist decode | wl-copy
;;
esac

44
dotfiles/scripts/diagnosis.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
clear
sleep 0.5
figlet "Diagnosis"
echo
echo "This script will check that essential packages and "
echo "execution commands are available on your system."
echo
_commandExists() {
package="$1";
if ! type $package > /dev/null 2>&1; then
echo ":: ERROR: $package doesn't exists. Please install it with yay -S $2"
else
echo ":: OK: $package found."
fi
}
_folderExists() {
folder="$1";
if [ ! -d $folder ]; then
echo ":: ERROR: $folder doesn't exists."
else
echo ":: OK: $folder found."
fi
}
_commandExists "rofi" "rofi-wayland"
_commandExists "dunst" "dunst"
_commandExists "waybar" "waybar"
_commandExists "hyprpaper" "hyprpaper"
_commandExists "hyprlock" "hyprpaper"
_commandExists "hypridle" "hyprpaper"
_commandExists "wal" "python-pywal"
_commandExists "gum" "gum"
_commandExists "wlogout" "wlogout"
_commandExists "swww" "swww"
_commandExists "eww" "eww"
_commandExists "magick2" "imagemagick"
_commandExists "figlet2" "figlet"
echo
echo "Press return to exit"
read

32
dotfiles/scripts/figlet.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
cat <<"EOF"
_____ _ _ _
| ___(_) __ _| | ___| |_
| |_ | |/ _` | |/ _ \ __|
| _| | | (_| | | __/ |_
|_| |_|\__, |_|\___|\__|
|___/
EOF
# -----------------------------------------------------
# Script to create ascii font based header on user input
# and copy the result to the clipboard
# -----------------------------------------------------
read -p "Enter the text for ascii encoding: " mytext
if [ -f ~/figlet.txt ]; then
touch ~/figlet.txt
fi
echo "cat <<\"EOF\"" > ~/figlet.txt
figlet "$mytext" >> ~/figlet.txt
echo "" >> ~/figlet.txt
echo "EOF" >> ~/figlet.txt
lines=$( cat ~/figlet.txt )
wl-copy "$lines"
xclip -sel clip ~/figlet.txt
echo "Text copied to clipboard!"

View File

@@ -0,0 +1 @@
thunar

16
dotfiles/scripts/fontsearch.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
# _____ _ _
# | ___|__ _ __ | |_ ___ ___ __ _ _ __ ___| |__
# | |_ / _ \| '_ \| __/ __|/ _ \/ _` | '__/ __| '_ \
# | _| (_) | | | | |_\__ \ __/ (_| | | | (__| | | |
# |_| \___/|_| |_|\__|___/\___|\__,_|_| \___|_| |_|
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
#
fc-list \
| grep -ioE ": [^:]*$1[^:]+:" \
| sed -E 's/(^: |:)//g' \
| tr , \\n \
| sort \
| uniq

View File

@@ -0,0 +1,32 @@
# ____ _ _ ____ _
# / ___|_ __ _____ _| |_| |__ | _ \ __ _| |_ ___
# | | _| '__/ _ \ \ /\ / / __| '_ \ | |_) / _` | __/ _ \
# | |_| | | | (_) \ V V /| |_| | | | | _ < (_| | || __/
# \____|_| \___/ \_/\_/ \__|_| |_| |_| \_\__,_|\__\___|
#
# by Stephan Raabe (2023)
# ---------------------------------------------------------------
# DESC: Python script to calculate the growth rate of two numbers
# ---------------------------------------------------------------
import rich
import pyperclip
from rich.console import Console
from rich.prompt import FloatPrompt
# Show prompts
console = Console()
num1 = FloatPrompt.ask("Old value")
num2 = FloatPrompt.ask("New value")
# Calculate the growth rate
gr = ((num2-num1)/num1)
percentage = "{:.2%}".format(gr)
# Print result to the console
console.print(percentage, style="bold")
# Copy result into the system clipboard
pyperclip.copy(percentage)
print("Result has been copied to the clipboard!")

View File

@@ -0,0 +1,42 @@
#!/bin/bash
# _____ _ _ _ __ _
# |_ _(_)_ __ ___ ___ ___| |__ (_)/ _| |_
# | | | | '_ ` _ \ / _ \/ __| '_ \| | |_| __|
# | | | | | | | | | __/\__ \ | | | | _| |_
# |_| |_|_| |_| |_|\___||___/_| |_|_|_| \__|
#
sleep 1
clear
figlet "Timeshift"
_isInstalledYay() {
package="$1";
check="$(yay -Qs --color always "${package}" | grep "local" | grep "${package} ")";
if [ -n "${check}" ] ; then
echo 0; #'0' means 'true' in Bash
return; #true
fi;
echo 1; #'1' means 'false' in Bash
return; #false
}
timeshift_installed=$(_isInstalledYay "timeshift")
grubbtrfs_installed=$(_isInstalledYay "grub-btrfs")
if [[ $timeshift_installed == "0" ]] ;then
echo ":: Timeshift is already installed"
else
if gum confirm "DO YOU WANT TO INSTALL Timeshift now?" ;then
yay -S timeshift
fi
fi
if [[ -d /boot/grub ]] && [[ $grubbtrfs_installed == "0" ]] ;then
echo ":: grub-btrfs is already installed"
else
echo ":: grub-btrfs is required to select a snapshot on grub bootloader."
if gum confirm "DO YOU WANT TO INSTALL grub-btrfs now?" ;then
yay -S grub-btrfs
fi
fi
sleep 3

View File

@@ -0,0 +1,66 @@
#!/bin/bash
# ___ _ _ _ _ _ _ _
# |_ _|_ __ ___| |_ __ _| | | | | | |_ __ __| | __ _| |_ ___ ___
# | || '_ \/ __| __/ _` | | | | | | | '_ \ / _` |/ _` | __/ _ \/ __|
# | || | | \__ \ || (_| | | | | |_| | |_) | (_| | (_| | || __/\__ \
# |___|_| |_|___/\__\__,_|_|_| \___/| .__/ \__,_|\__,_|\__\___||___/
# |_|
# by Stephan Raabe (2024)
# -----------------------------------------------------
# Required: yay trizen timeshift btrfs-grub
# -----------------------------------------------------
sleep 1
clear
figlet "Updates"
echo
_isInstalledYay() {
package="$1";
check="$(yay -Qs --color always "${package}" | grep "local" | grep "${package} ")";
if [ -n "${check}" ] ; then
echo 0; #'0' means 'true' in Bash
return; #true
fi;
echo 1; #'1' means 'false' in Bash
return; #false
}
# ------------------------------------------------------
# Confirm Start
# ------------------------------------------------------
if gum confirm "DO YOU WANT TO START THE UPDATE NOW?" ;then
echo
echo ":: Update started."
elif [ $? -eq 130 ]; then
exit 130
else
echo
echo ":: Update canceled."
exit;
fi
if [[ $(_isInstalledYay "timeshift") == "0" ]] ;then
if gum confirm "DO YOU WANT TO CREATE A SNAPSHOT?" ;then
echo
c=$(gum input --placeholder "Enter a comment for the snapshot...")
sudo timeshift --create --comments "$c"
sudo timeshift --list
sudo grub-mkconfig -o /boot/grub/grub.cfg
echo ":: DONE. Snapshot $c created!"
echo
elif [ $? -eq 130 ]; then
echo ":: Snapshot canceled."
exit 130
else
echo ":: Snapshot canceled."
fi
echo
fi
yay
notify-send "Update complete"
echo
echo ":: Update complete"
sleep 2

60
dotfiles/scripts/launchvm.sh Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
# _ _ __ ____ __
# | | __ _ _ _ _ __ ___| |__ \ \ / / \/ |
# | | / _` | | | | '_ \ / __| '_ \ \ \ / /| |\/| |
# | |__| (_| | |_| | | | | (__| | | | \ V / | | | |
# |_____\__,_|\__,_|_| |_|\___|_| |_| \_/ |_| |_|
#
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
if [ -f ~/private/win11-credentials.sh ]; then
echo "Credential file exists. Using the file."
source ~/private/win11-credentials.sh
else
win11user="USER"
win11pass="PASS"
win11ip="192.168.122.44"
win11name="windows11"
echo "## Preparing to remotely access your Windows virtual machine ##"
echo -n "Please enter your virtual machine name [default: $win11name]: "
read vmname
vmname=${vmname:-$win11name}
echo -n "Please enter your virtual machine ip [default: $win11ip]: "
read vmip
vmip=${vmip:-$win11ip}
echo -n "Please enter your username [default: $win11user]: "
read user
user=${user:-$win11user}
echo -n "Please enter your password [default: $win11pass]: "
read password
password=${password:-$win11pass}
fi
# echo "Hello, $vmname, $vmip, $user, $password"
tmp=$(virsh --connect qemu:///system list | grep " $vmname " | awk '{ print $3}')
if ([ "x$tmp" == "x" ] || [ "x$tmp" != "xrunning" ]); then
echo "Virtual Machine $vmname is starting now... Waiting 30s before starting xfreerdp."
notify-send "Virtual Machine $vmname 11 is starting now..." "Waiting 30s before starting xfreerdp."
virsh --connect qemu:///system start $vmname
sleep 30
else
notify-send "Virtual Machine $vmname is already running." "Launching xfreerdp now!"
echo "Starting xfreerdp now..."
fi
if command -v xfreerdp >/dev/null 2>&1; then
xfreerdp -grab-keyboard /v:$vmip /size:100% /cert-ignore /u:$user /p:$password /d: /dynamic-resolution /gfx-h264:avc444 +gfx-progressive /f &
elif command -v xfreerdp3 >/dev/null 2>&1; then
xfreerdp3 -v:$vmip -u:$user -p:$password -d: -dynamic-resolution /cert:ignore /f /gfx:AVC444 &
else
echo "'xfreerdp' or 'xfreerdp3' command not found."
fi

View File

@@ -0,0 +1,12 @@
#!/bin/bash
while IFS= read -r line; do
# If the line starts with # and the next line is not the lines to be added
if [[ $line == \#HandleLidSwitchDocked=ignore ]]; then
# Add the new lines
echo "HandleLidSwitchDocked=ignore" | sudo tee -a /etc/systemd/logind.conf > /dev/null
fi
if [[ $line == \#HoldoffTimeoutSec=5s ]]; then
# Add the new lines
echo "HoldoffTimeoutSec=5s" | sudo tee -a /etc/systemd/logind.conf > /dev/null
fi
done < /etc/systemd/logind.conf

View File

@@ -0,0 +1,20 @@
#!/bin/bash
# _ _ _ ____ _
# | | ___ ___ | | _(_)_ __ __ _ / ___| | __ _ ___ ___
# | | / _ \ / _ \| |/ / | '_ \ / _` | | | _| |/ _` / __/ __|
# | |__| (_) | (_) | <| | | | | (_| | | |_| | | (_| \__ \__ \
# |_____\___/ \___/|_|\_\_|_| |_|\__, | \____|_|\__,_|___/___/
# |___/
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
tmp=$(virsh --connect qemu:///system list | grep " win11 " | awk '{ print $3}')
if ([ "x$tmp" == "x" ] || [ "x$tmp" != "xrunning" ])
then
virsh --connect qemu:///system start win11
echo "Virtual Machine win11 is starting..."
sleep 3
fi
looking-glass-client &
exit

View File

@@ -0,0 +1,2 @@
curl -o - https://gitlab.com/stephan-raabe/dotfiles/-/raw/main/.install/version.txt?ref_type=heads&inline=false
echo $live_version

6
dotfiles/scripts/nm-applet.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
if [[ "$1" == "stop" ]]; then
killall nm-applet
else
nm-applet --indicator &
fi

12
dotfiles/scripts/onedrive.sh Executable file
View File

@@ -0,0 +1,12 @@
# ___ ____ _
# / _ \ _ __ ___| _ \ _ __(_)_ _____
# | | | | '_ \ / _ \ | | | '__| \ \ / / _ \
# | |_| | | | | __/ |_| | | | |\ V / __/
# \___/|_| |_|\___|____/|_| |_| \_/ \___|
#
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
rclone --vfs-cache-mode writes mount OneDrive: ~/OneDrive &
notify-send "OneDrive connected" "Microsoft OneDrive successfully mounted."

58
dotfiles/scripts/pacman.sh Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/bash
# ____
# | _ \ __ _ ___ _ __ ___ __ _ _ __
# | |_) / _` |/ __| '_ ` _ \ / _` | '_ \
# | __/ (_| | (__| | | | | | (_| | | | |
# |_| \__,_|\___|_| |_| |_|\__,_|_| |_|
#
sleep 1
clear
figlet "pacman.conf"
echo
echo ":: This script will activate or deactivate additions for your pacman.conf."
echo
if grep -Fq "#ParallelDownloads" /etc/pacman.conf
then
if gum confirm "Do you want to activate parallel downloads?" ;then
sudo sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
else
echo ":: Activation of parallel downloads skipped."
fi
else
echo ":: Parallel downloads are already activated."
fi
if grep -Fxq "#Color" /etc/pacman.conf
then
if gum confirm "Do you want to activate colors?" ;then
sudo sed -i 's/^#Color/Color/' /etc/pacman.conf
else
echo ":: Activation of Color skipped."
fi
else
echo ":: Color is already activated."
fi
if grep -Fxq "#VerbosePkgLists" /etc/pacman.conf
then
if gum confirm "Do you want to activate VerbosePkgLists?" ;then
sudo sed -i 's/^#VerbosePkgLists/VerbosePkgLists/' /etc/pacman.conf
else
echo ":: Activation of VerbosePkgLists skipped."
fi
else
echo ":: VerbosePkgLists is already activated."
fi
if grep -Fxq "ILoveCandy" /etc/pacman.conf
then
echo ":: ILoveCandy is already activated."
else
if gum confirm "Do you want to activate ILoveCandy?" ;then
sudo sed -i '/^ParallelDownloads = .*/a ILoveCandy' /etc/pacman.conf
else
echo ":: Activation of ILoveCandy skipped."
fi
fi
sleep 2

61
dotfiles/scripts/snapshot.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
# ____ _ _
# / ___| _ __ __ _ _ __ ___| |__ ___ | |_
# \___ \| '_ \ / _` | '_ \/ __| '_ \ / _ \| __|
# ___) | | | | (_| | |_) \__ \ | | | (_) | |_
# |____/|_| |_|\__,_| .__/|___/_| |_|\___/ \__|
# |_|
#
# by Stephan Raabe (2024)
# -----------------------------------------------------
sleep 1
clear
figlet "Snapshot"
_isInstalledYay() {
package="$1";
check="$(yay -Qs --color always "${package}" | grep "local" | grep "${package} ")";
if [ -n "${check}" ] ; then
echo 0; #'0' means 'true' in Bash
return; #true
fi;
echo 1; #'1' means 'false' in Bash
return; #false
}
timeshift_installed=$(_isInstalledYay "timeshift")
grubbtrfs_installed=$(_isInstalledYay "grub-btrfs")
if [[ $timeshift_installed == "0" ]] ;then
c=$(gum input --placeholder "Enter a comment for the snapshot...")
sudo timeshift --create --comments "$c"
sudo timeshift --list
if [[ -d /boot/grub ]] ;then
if [[ -d /boot/grub ]] && [[ $grubbtrfs_installed == "1" ]] ;then
if gum confirm "DO YOU WANT TO INSTALL grub-btrfs now?" ;then
yay -S grub-btrfs
else
exit
fi
fi
sudo grub-mkconfig -o /boot/grub/grub.cfg
fi
echo "DONE. Snapshot $c created!"
else
echo "ERROR: Timeshift is not installed."
if gum confirm "DO YOU WANT TO INSTALL Timeshift now?" ;then
yay -S timeshift
echo
echo ":: Timeshift has been installed. Please restart this script."
if [[ -d /boot/grub ]] && [[ $grubbtrfs_installed == "1" ]] ;then
echo ":: grub-btrfs is required to select a snapshot on grub bootloader."
if gum confirm "DO YOU WANT TO INSTALL grub-btrfs now?" ;then
yay -S grub-btrfs
else
exit
fi
fi
fi
fi

18
dotfiles/scripts/templates.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# _____ _ _
# |_ _|__ _ __ ___ _ __ | | __ _| |_ ___ ___
# | |/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \/ __|
# | | __/ | | | | | |_) | | (_| | || __/\__ \
# |_|\___|_| |_| |_| .__/|_|\__,_|\__\___||___/
# |_|
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
# Select text file
selected=$(ls -1 ~/private/templates | rofi -dmenu -p "Select the template")
if [ "$selected" ]; then
# Add content to clipboard
xclip -sel clip ~/private/templates/$selected
fi

View File

@@ -0,0 +1,19 @@
#!/bin/bash
clear
if [ -f ~/dotfiles/.settings/terminal.sh ]; then
terminal="$(cat ~/dotfiles/.settings/terminal.sh)"
echo ":: Installing $terminal"
if [ -d ~/.config/xfce4 ]; then
if [ ! -f ~/.config/xfce4/helpers.rc ]; then
touch ~/.config/xfce4/helpers.rc
fi
echo "TerminalEmulator=$terminal" > ~/.config/xfce4/helpers.rc
echo ":: $terminal defined as Thunar Terminal Emulator."
else
echo "ERROR: ~/.config/xfce4 not found. Please open Thunar once to create it."
echo "Then start this script again."
fi
else
echo "ERROR: ~/dotfiles/.settings/terminal.sh not found"
fi
sleep 3

View File

@@ -0,0 +1,9 @@
#!/bin/bash
sleep 1
if [ -f /var/lib/pacman/db.lck ]; then
sudo rm /var/lib/pacman/db.lck
echo ":: Unlock complete"
else
echo ":: Pacman database is not locked"
fi
sleep 3

64
dotfiles/scripts/updates.sh Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/bash
# _ _ _ _
# | | | |_ __ __| | __ _| |_ ___ ___
# | | | | '_ \ / _` |/ _` | __/ _ \/ __|
# | |_| | |_) | (_| | (_| | || __/\__ \
# \___/| .__/ \__,_|\__,_|\__\___||___/
# |_|
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
# Requires pacman-contrib trizen
# -----------------------------------------------------
# Define threshholds for color indicators
# -----------------------------------------------------
threshhold_green=0
threshhold_yellow=25
threshhold_red=100
# -----------------------------------------------------
# Calculate available updates pacman and aur (with trizen)
# -----------------------------------------------------
if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then
updates_arch=0
fi
if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then
updates_aur=0
fi
updates=$(("$updates_arch" + "$updates_aur"))
# -----------------------------------------------------
# Testing
# -----------------------------------------------------
# Overwrite updates with numbers for testing
# updates=100
# test JSON output
# printf '{"text": "0", "alt": "0", "tooltip": "0 Updates", "class": "red"}'
# exit
# -----------------------------------------------------
# Output in JSON format for Waybar Module custom-updates
# -----------------------------------------------------
css_class="green"
if [ "$updates" -gt $threshhold_yellow ]; then
css_class="yellow"
fi
if [ "$updates" -gt $threshhold_red ]; then
css_class="red"
fi
if [ "$updates" -gt $threshhold_green ]; then
printf '{"text": "%s", "alt": "%s", "tooltip": "Click to update your system", "class": "%s"}' "$updates" "$updates" "$updates" "$css_class"
else
printf '{"text": "0", "alt": "0", "tooltip": "No updates available", "class": "green"}'
fi

View File

@@ -0,0 +1,34 @@
#!/usr/bin/env python
import subprocess
import datetime
import json
from html import escape
data = {}
today = datetime.date.today().strftime("%Y-%m-%d")
next_week = (datetime.date.today() +
datetime.timedelta(days=10)).strftime("%Y-%m-%d")
output = subprocess.check_output("khal list now "+next_week, shell=True)
output = output.decode("utf-8")
lines = output.split("\n")
new_lines = []
for line in lines:
clean_line = escape(line).split(" ::")[0]
if len(clean_line) and not clean_line[0] in ['0', '1', '2']:
clean_line = "\n<b>"+clean_line+"</b>"
new_lines.append(clean_line)
output = "\n".join(new_lines).strip()
if today in output:
data['text'] = "" + output.split('\n')[1]
else:
data['text'] = ""
data['tooltip'] = output
print(json.dumps(data))