From 70b65b88ac2119600b68e1a75e3053459d171764 Mon Sep 17 00:00:00 2001 From: jbjjbjjbj Date: Fri, 13 Jan 2017 20:02:01 +0100 Subject: Added new scripts --- Scripts/Scanner.py | 31 +++++++++++++++++++++++++++++ Scripts/makeGif.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ Scripts/mayHem.py | 30 ++++++++++++++++++++++++++++ Scripts/overleafUp.sh | 4 ++++ Scripts/pythonSocket.py | 23 +++++++++++++++++++++ Scripts/volume-change.py | 2 ++ Scripts/whileUdDown.sh | 12 +++++++++++ 7 files changed, 154 insertions(+) create mode 100755 Scripts/Scanner.py create mode 100755 Scripts/makeGif.py create mode 100644 Scripts/mayHem.py create mode 100644 Scripts/overleafUp.sh create mode 100644 Scripts/pythonSocket.py create mode 100644 Scripts/whileUdDown.sh (limited to 'Scripts') diff --git a/Scripts/Scanner.py b/Scripts/Scanner.py new file mode 100755 index 0000000..04538c4 --- /dev/null +++ b/Scripts/Scanner.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +import getch +import os + +page = 0 + +name = input("Enter name of pdf: ") + +while(1): + print("Press q for exit, Space for scanning, and d for done") + x = getch.getch() + if(x == 'q'): + exit() + elif(x == ' '): + print("Starting scan of page " + str(page+1)) + os.system("scanimage --device genesys:libusb:001:004 --format=tiff > scan" + str(page) + ".tiff") + page += 1 + print("Scan done") + elif(x == 'd'): + print("Collecting tiff pages") + os.system("tiffcp scan*.tiff magazine.tiff"); + print("Making pdf file") + os.system("convert magazine.tiff '" + name + ".pdf'") + print("Removing tiffs") + os.system("rm *.tiff") + print("Done resetting vars") + page = 0 + name = input("Enter name of pdf: ") + + diff --git a/Scripts/makeGif.py b/Scripts/makeGif.py new file mode 100755 index 0000000..5a5ac98 --- /dev/null +++ b/Scripts/makeGif.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +import sys +import argparse +import os + +parser = argparse.ArgumentParser() +parser.add_argument('-s', '--start', + required=False, + type=int, + default=0, + dest="start", + help="Time to start gif at. [0]" ) +parser.add_argument('-l', '--lenght', + required=True, + type=int, + dest="lenght", + help="Lenght of gif in seconds" ) +parser.add_argument('-i', '--infile', + required=True, + type=str, + dest="infile", + help="Movie to convert" ) +parser.add_argument('-o', '--outfile', + required=False, + type=str, + default="output.gif", + dest="outfile", + help="Output gif name. [output.gif]") +parser.add_argument('-f', '--fps', + required=False, + type=int, + default=10, + dest="fps", + help="Frames per second. [10]") +parser.add_argument('-r', '--resolution', + required=False, + type=int, + default=320, + dest="res", + help="Resolution. [320]") +args = parser.parse_args() + + +os.system("ffmpeg -y -ss " + str(args.start) + " -t " + str(args.lenght) + " -i '" + args.infile + "' -vf fps=" + str(args.fps) + ",scale=" + str(args.res) + ":-1:flags=lanczos,palettegen palette.png") + +string = 'fps=' + str(args.fps) + ',scale=' + str(args.res) + ':-1:flags=lanczos[x];[x][1:v]paletteuse' + +os.system('ffmpeg -ss ' + str(args.start) + ' -t ' + str(args.lenght) + ' -i "' + args.infile + '" -i palette.png -filter_complex "' + string + '" "' + args.outfile + '"') + +os.remove("palette.png") + +print("\n\nDONE - your file " + args.outfile + " is ready. Have a nice day :-D") diff --git a/Scripts/mayHem.py b/Scripts/mayHem.py new file mode 100644 index 0000000..6ac90d6 --- /dev/null +++ b/Scripts/mayHem.py @@ -0,0 +1,30 @@ +import os +import tkinter as tk +import time +root = tk.Tk() +root.withdraw() + +control_c_sequence = '''keydown Shift_L; +key Left; +keyup Shift_L; +keydown Control_L; +key x; +keyup Control_L +''' + +left = 'key Left' +right = 'key Right' + +def keypress(sequence): + #print(sequence.replace('\n', '')) + for item in sequence.replace('\n', '').split(';'): + print("xdotool " + item) + os.system("xdotool " + item) + + +keypress(right) +while(True): + keypress(control_c_sequence) + keypress("keydown Shift_L key " + root.clipboard_get() + " keyup Shift_L") + keypress(right) + keypress(right) diff --git a/Scripts/overleafUp.sh b/Scripts/overleafUp.sh new file mode 100644 index 0000000..59f4355 --- /dev/null +++ b/Scripts/overleafUp.sh @@ -0,0 +1,4 @@ +cd /home/julian/Dokumenter/overleaf/fysikCirkelBevægelse + +git pull +pdflatex main.tex diff --git a/Scripts/pythonSocket.py b/Scripts/pythonSocket.py new file mode 100644 index 0000000..06c434b --- /dev/null +++ b/Scripts/pythonSocket.py @@ -0,0 +1,23 @@ +import socket +sock = socket.socket() + +server_addr = ('192.168.43.86', 5001) +sock.bind(server_addr) + +sock.listen(1) +print("Waiting for connection on " + str(server_addr)) +while True: + connection, client_address = sock.accept() + try: + print ('connection from', client_address) + + # Receive the data in small chunks and retransmit it + while True: + data = connection.recv(16) + print('received ' ,data) + if not data: + print('no more data from', client_address) + break + finally: + # Clean up the connection + connection.close() \ No newline at end of file diff --git a/Scripts/volume-change.py b/Scripts/volume-change.py index 64d578a..d279ce6 100755 --- a/Scripts/volume-change.py +++ b/Scripts/volume-change.py @@ -8,6 +8,8 @@ # # Requires: python3 and python-dbus (on Arch) or python3-dbus # (on Debian) or equivalent +# +# Git link: https://github.com/garrett92895/gnome-volume-step-osd import dbus import sys from subprocess import getoutput diff --git a/Scripts/whileUdDown.sh b/Scripts/whileUdDown.sh new file mode 100644 index 0000000..2ca8f07 --- /dev/null +++ b/Scripts/whileUdDown.sh @@ -0,0 +1,12 @@ +C=1 +RED=$(curl -Ls -o /dev/null -w %{url_effective} http://uddataplus.dk) +echo "$C $RED" +COM="https://www.uddata.dk/uddataplus-nede/" +while [ "$RED" == "$COM" ] +do + C=$((C+1)) + RED=$(curl -Ls -o /dev/null -w %{url_effective} http://uddataplus.dk) + echo "$C $RED" + sleep 30 +done +notify-send 'Yo!' 'Uddata virker måske igen' --icon=dialog-information -- cgit v1.2.3