From c96617dbce01dd9d1e6ff696544d1b83ce907b16 Mon Sep 17 00:00:00 2001 From: Tobias Kessels Date: Sun, 13 Aug 2017 01:26:53 +0200 Subject: [PATCH 1/2] fixed bug in toggle_touchpad toggle_touchpad was using a static id instead of the dynamic one readme extended --- README.md | 10 +++++++++- toggle_touchpad | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2372096..cf944c6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ # gists -uploadtest + +##chechsqlite.py +test sqliteDBs for consistency and passwords + +##sort.py +move/sort files in current dir to subfolder named after mime-type + +##toggle_touchpad +toggle touchpad on notebook on and off via xinput diff --git a/toggle_touchpad b/toggle_touchpad index 5820958..d100262 100755 --- a/toggle_touchpad +++ b/toggle_touchpad @@ -1,6 +1,6 @@ #!/bin/bash touchpad_id=$(xinput list | grep -i touch | grep -Po '(?<=id=)\d+') -if (xinput list-props 14 | grep "Device Enabled" | grep -Po '\d$' | grep -q "1"); then +if (xinput list-props ${touchpad_id} | grep "Device Enabled" | grep -Po '\d$' | grep -q "1"); then xinput disable "${touchpad_id}" else xinput enable "${touchpad_id}" From 885ed613f1b7e4d17f5ab91fc470c928f16963c0 Mon Sep 17 00:00:00 2001 From: Tobias Kessels Date: Mon, 14 Aug 2017 22:40:07 +0200 Subject: [PATCH 2/2] added json_save.py --- json_save.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 json_save.py diff --git a/json_save.py b/json_save.py new file mode 100644 index 0000000..62fa0af --- /dev/null +++ b/json_save.py @@ -0,0 +1,50 @@ +import simplejson +import json + +def put(data, filename): + try: + jsondata = simplejson.dumps(data, indent=4, skipkeys=True, sort_keys=True) + fd = open(filename, 'w') + fd.write(jsondata) + fd.close() + except Exception as e: + print('ERROR writing', filename) + print( e) + pass + +def get(filename): + returndata = {} + try: + fd = open(filename, 'r') + text = fd.read() + fd.close() + returndata = json.read(text) + # Hm. this returns unicode keys... + #returndata = simplejson.loads(text) + except: + print('COULD NOT LOAD:', filename) + return returndata + + + # print(mail.filename) + # print(mail.status) + +# import gzip +# import json +# +# # writing +# with gzip.GzipFile(jsonfilename, 'w') as outfile: +# for obj in objects: +# outfile.write(json.dumps(obj) + '\n') +# +# # reading +# with gzip.GzipFile(jsonfilename, 'r') as isfile: +# for line in infile: +# obj = json.loads(line) +# # process obj +# picklefile=open("mails.dump",'wb') +# for mail in list_of_mail: +# pickle.dump(mail, picklefile ) +# +# picklefile.close() +