diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/.gitignore | 1 | ||||
| -rwxr-xr-x | scripts/icstocal | 99 | ||||
| -rwxr-xr-x | scripts/randwp | 20 |
3 files changed, 120 insertions, 0 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 0000000..76d851f --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1 @@ +rider.sh
\ No newline at end of file diff --git a/scripts/icstocal b/scripts/icstocal new file mode 100755 index 0000000..94e8700 --- /dev/null +++ b/scripts/icstocal @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +# A really poorly written script to convert .ics file to calendar file for quand or when +# doesn't work when an event take longer than a day + +from sys import argv +from pathlib import Path + +if len(argv) < 3: + print("To use this script you need to supply 2 arguments.") + print("e.g.: icsparser calendar.ics $XDG_DATA_HOME/quand/calendar") + exit() + +TIMEZONE = 2 # as UTC+2 +IN="en" # 'en' means 'in' in french +INPUT = argv[1] +OUTPUT = argv[2] + +if not Path(INPUT).is_file(): + print("{0} doesn't exist".format(INPUT)) + exit() + +file = open(INPUT, "r") + +if file.readline() != "BEGIN:VCALENDAR\n": + print("{0} is not valid".format(INPUT)) + file.close() + exit() + +line = file.readline() +locations = [] +summaries = [] +starts = [] +ends = [] + +while line != "END:VCALENDAR\n": + if line == "BEGIN:VEVENT\n": + while line != "END:VEVENT\n": + if line.startswith("LOCATION"): + locations.append(line[9:].strip()) + elif line.startswith("SUMMARY"): + summaries.append(line[8:].strip()) + elif line.startswith("DTSTART"): + start = line.lstrip("DTSTART") + year = "" + month = "" + day = "" + hour = "" + min = "" + for i in range(len(start)): + if i >= 1 and i <= 4: + year += start[i] + elif i == 5 or i == 6: + month += start[i] + elif i == 7 or i == 8: + day += start[i] + elif i == 10: + hour += start[i] + elif i == 11: + if int(start[i]) + TIMEZONE > 9: + hour = str(int(hour[0]) + 1) + "0" # I cba do the case where H will become 25 + else: + hour += str(int(start[i]) + TIMEZONE) + elif i == 12 or i == 13: + min += start[i] + starts.append([year, month, day, hour, min]) + elif line.startswith("DTEND"): + end = line.lstrip("DTEND") + hour = "" + min = "" + for i in range(len(end)): + if i == 10: + hour += end[i] + elif i == 11: + if int(end[i]) + TIMEZONE > 9: + hour = str(int(hour[0]) + 1) + "0" # I cba do the case where H will become 25 + else: + hour += str(int(end[i]) + TIMEZONE) + elif i == 12 or i == 13: + min += end[i] + ends.append("{0}:{1}".format(hour, min)) + line = file.readline() + line = file.readline() +file.close() + +file = open(OUTPUT, "w") +for i in range(len(locations)): + # yyyy mm dd, hh:hh -> hh:hh summary location + file.write("{0} {1} {2}, {3}:{4} -> {5} {6} {7} {8}\n".format(starts[i][0], + starts[i][1], + starts[i][2], + starts[i][3], + starts[i][4], + ends[i], + summaries[i], + IN, + locations[i])) + +file.close() +print("All done!") diff --git a/scripts/randwp b/scripts/randwp new file mode 100755 index 0000000..a63271d --- /dev/null +++ b/scripts/randwp @@ -0,0 +1,20 @@ +#!/bin/sh +# set a random wallpaper +# to ignore a folder or a file put it in IGNORE like "file1|folder|file2" + +WPDIR="${1:-/home/marcellus/.config/wallpapers}" +ALL="$(find "$WPDIR" -type f ! -path '*/.git*' ! -name 'README.md')" + +searchwp() { + wp="$(printf '%s' "$ALL" | shuf -n 1)" +} + +# 1 screen with hsetroot +#searchwp +#hsetroot -cover "$wp" 1>/dev/null + +# multiple screens with xwallpaper +for output in $(xrandr | awk '$2=="connected" {print $1 "\n"}'); do + searchwp + xwallpaper --output "$output" --zoom "$wp" +done |
