diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..e9d80e7 --- /dev/null +++ b/.hgignore @@ -0,0 +1,2 @@ +.log +.old diff --git a/convertAtlasXmlToJson.php b/convertAtlasXmlToJson.php new file mode 100755 index 0000000..c5fe305 --- /dev/null +++ b/convertAtlasXmlToJson.php @@ -0,0 +1,95 @@ +#!/bin/php +meta->sprites} textures processed successfully with {$json->meta->app} version {$json->meta->version}"); + file_put_contents($new_filename, json_encode($json)); + logMsg("Saved to {$new_filename}"); + } else { + logMsg("No file exists named: {$filename}"); + die(); + } +} +else { + logMsg("No input file name provided"); + die(); +} +die(); + +function convertXMLToJSONHash($xml){ + $json = new stdClass(); + //build out the frames obj (contains all the images) + $json->frames = new stdClass(); + //build out the meta object (just info about this program) + $json->meta = writeJSONMeta(); + //loop through all subtextures + $i = 0; + foreach ($xml->SubTexture as $frame){ + //get the attributes for each XML node + $attrs = $frame->attributes(); + //make the right object, JSON arr would differ here + $json->frames->{$attrs["name"]} = new stdClass(); + //make the frame object + $frame_obj = new stdClass(); + $frame_obj->x = intval($attrs["x"]); + $frame_obj->y = intval($attrs["y"]); + $frame_obj->w = intval($attrs["width"]); + $frame_obj->h = intval($attrs["height"]); + //set the frame object + $json->frames->{$attrs["name"]}->frame = $frame_obj; + + //make the sprite source object + $sprite_obj = new stdClass(); + $sprite_obj->x = 0; + $sprite_obj->y = 0; + $sprite_obj->w = $frame_obj->w; + $sprite_obj->h = $frame_obj->h; + //set the sprite source object + $json->frames->{$attrs["name"]}->spriteSourceSize = $sprite_obj; + + //make the source size object + $source_obj = new stdClass(); + $source_obj->w = $frame_obj->w; + $source_obj->h = $frame_obj->h; + //set the sprite source object + $json->frames->{$attrs["name"]}->sourceSize = $source_obj; + + //add some more stuff that may or may not matter + $json->frames->{$attrs["name"]}->rotated = false; + $json->frames->{$attrs["name"]}->trimmed = false; + + //make the pivot object + $pivot_obj = new stdClass(); + $pivot_obj->x = 0.5; + $pivot_obj->y = 0.5; + $json->frames->{$attrs["name"]}->rotated = false; + $i++; + } + $json->meta->sprites = $i; + //get root attributes + $attrs = $xml->attributes(); + $json->meta->image = (string)$attrs["imagePath"]; + return $json; +} + +function writeJSONMeta(){ + global $VERSION; + $meta = new stdClass(); + $meta->app = "TextureAtlasConverter"; + $meta->version = $VERSION; + return $meta; +} + +function logMsg ($message){ + echo "{$message}\n"; +} +?> diff --git a/dropbox.py b/dropbox.py index 415dd21..d786247 100755 --- a/dropbox.py +++ b/dropbox.py @@ -4,7 +4,7 @@ # # dropbox # Dropbox frontend script -# This file is part of nautilus-dropbox 1.6.1. +# This file is part of nautilus-dropbox 2015.10.28. # # nautilus-dropbox is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -212,7 +212,7 @@ def verify_signature(key_file, sig_file, plain_file): def download_file_chunk(url, buf): opener = urllib2.build_opener() - opener.addheaders = [('User-Agent', "DropboxLinuxDownloader/1.6.1")] + opener.addheaders = [('User-Agent', "DropboxLinuxDownloader/2015.10.28")] sock = opener.open(url) size = int(sock.info()['content-length']) @@ -430,6 +430,7 @@ if GUI_AVAILABLE: self.hovering = False self.clicked_link = False self.user_cancelled = False + self.task = None self.ok = ok = gtk.Button(stock=gtk.STOCK_OK) ok.connect('clicked', self.handle_ok) @@ -994,10 +995,10 @@ This is an alias for filestatus -l @command @requires_dropbox_running def puburl(args): - u"""get public url of a file in your dropbox + u"""get public url of a file in your dropbox's public folder dropbox puburl FILE -Prints out a public url for FILE. +Prints out a public url for FILE (which must be in your public folder). """ if len(args) != 1: console_print(puburl.__doc__,linebreak=False) @@ -1016,6 +1017,153 @@ Prints out a public url for FILE. except DropboxCommand.CouldntConnectError, e: console_print(u"Dropbox isn't running!") +@command +@requires_dropbox_running +def sharelink(args): + u"""get a shared link for a file in your dropbox +dropbox sharelink FILE + +Prints out a shared link for FILE. +""" + if len(args) != 1: + console_print(sharelink.__doc__, linebreak=False) + return + + try: + with closing(DropboxCommand()) as dc: + try: + path = unicode_abspath(args[0].decode(sys.getfilesystemencoding())) + link = dc.get_shared_link(path=path).get('link', [u'No link'])[0] + console_print(link) + except DropboxCommand.CommandError, e: + console_print(u"Couldn't get shared link: " + str(e)) + except DropboxCommand.BadConnectionError, e: + console_print(u"Dropbox isn't responding!") + except DropboxCommand.EOFError: + console_print(u"Dropbox daemon stopped.") + except DropboxCommand.CouldntConnectError, e: + console_print(u"Dropbox isn't running!") + +@command +@requires_dropbox_running +def proxy(args): + u"""set proxy settings for Dropbox +dropbox proxy MODE [TYPE] [HOST] [PORT] [USERNAME] [PASSWORD] + +Set proxy settings for Dropbox. + +MODE - one of "none", "auto", "manual" +TYPE - one of "http", "socks4", "socks5" (only valid with "manual" mode) +HOST - proxy hostname (only valid with "manual" mode) +PORT - proxy port (only valid with "manual" mode) +USERNAME - (optional) proxy username (only valid with "manual" mode) +PASSWORD - (optional) proxy password (only valid with "manual" mode) +""" + mode = None + type_ = None + if len(args) >= 1: + mode = args[0].decode(sys.getfilesystemencoding()).lower() + if len(args) >= 2: + type_ = args[1].decode(sys.getfilesystemencoding()).lower() + + if (len(args) == 0 or + mode not in [u'none', u'auto', u'manual'] or + (mode == 'manual' and len(args) not in (4, 6)) or + (mode != 'manual' and len(args) != 1) or + (mode == 'manual' and type_ not in [u'http', u'socks4', u'socks5'])): + # Print help + console_print(proxy.__doc__, linebreak=False) + return + + ARGS = ['mode', 'type', 'host', 'port', 'username', 'password'] + + # Load the args into a dictionary + kwargs = dict(zip(ARGS, [a.decode(sys.getfilesystemencoding()) for a in args])) + + # Re-set these two because they were coerced to lower case + kwargs['mode'] = mode + if type_: + kwargs['type'] = type_ + + try: + with closing(DropboxCommand()) as dc: + try: + dc.set_proxy_settings(**kwargs) + console_print(u'set') + except DropboxCommand.CommandError, e: + console_print(u"Couldn't set proxy: " + str(e)) + except DropboxCommand.BadConnectionError, e: + console_print(u"Dropbox isn't responding!") + except DropboxCommand.EOFError: + console_print(u"Dropbox daemon stopped.") + except DropboxCommand.CouldntConnectError, e: + console_print(u"Dropbox isn't running!") + +@command +@requires_dropbox_running +def throttle(args): + u"""set bandwidth limits for Dropbox +dropbox throttle DOWNLOAD UPLOAD + +Set bandwidth limits for file sync. + +DOWNLOAD - either "unlimited" or a manual limit in KB/s +UPLOAD - one of "unlimited", "auto", or a manual limit in KB/s +""" + if len(args) != 2: + console_print(throttle.__doc__, linebreak=False) + return + + downlimit = args[0].decode(sys.getfilesystemencoding()).lower() + uplimit = args[1].decode(sys.getfilesystemencoding()).lower() + + download_limit = None + download_mode = None + if downlimit == u'unlimited': + download_mode = downlimit + else: + try: + download_limit = int(downlimit) + download_mode = u'manual' + except ValueError: + console_print(throttle.__doc__, linebreak=False) + return + + upload_limit = None + upload_mode = None + if uplimit in [u'unlimited', u'auto']: + upload_mode = uplimit + else: + try: + upload_limit = int(uplimit) + upload_mode = u'manual' + except ValueError: + console_print(throttle.__doc__, linebreak=False) + return + + kwargs = { + u'download_mode': download_mode, + u'upload_mode': upload_mode, + } + if download_limit: + kwargs[u'download_limit'] = unicode(download_limit) + if upload_limit: + kwargs[u'upload_limit'] = unicode(upload_limit) + + try: + with closing(DropboxCommand()) as dc: + try: + dc.set_bandwidth_limits(**kwargs) + console_print(u'set') + except DropboxCommand.CommandError, e: + console_print(u"Couldn't set bandwidth limits: " + str(e)) + except DropboxCommand.BadConnectionError, e: + console_print(u"Dropbox isn't responding!") + except DropboxCommand.EOFError: + console_print(u"Dropbox daemon stopped.") + except DropboxCommand.CouldntConnectError, e: + console_print(u"Dropbox isn't running!") + @command @requires_dropbox_running def status(args): diff --git a/getGPUTemp.py b/getGPUTemp.py index ca3aafd..2a6b8b8 100755 --- a/getGPUTemp.py +++ b/getGPUTemp.py @@ -1,8 +1,12 @@ #!/usr/bin/python import os import re +import logging from subprocess import check_output +FORMAT = "%(asctime)s %(levelname)s %(message)s" +logging.basicConfig(format=FORMAT, filename=__file__+'.log', level=logging.DEBUG) + def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) @@ -21,8 +25,11 @@ return_value = check_output(command, shell=True) if sensors_available: m = re.search(r'\+(.*)°C ',return_value.decode("utf-8")) print(m.group(1)) + logging.info(m.group(1)) elif aticonfig_available: m = re.search(r'- (.*) C',return_value.decode("utf-8")) print(m.group(1)) + logging.info(m.group(1)) else: print("?") + logging.info('?') diff --git a/old/autoclick.sh b/old/autoclick.sh new file mode 100644 index 0000000..860d47a --- /dev/null +++ b/old/autoclick.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +while [ 1 ]; do + xdotool mousemove 215 469 click 1 & + sleep 0.1 +done diff --git a/old/enable_kvm.sh b/old/enable_kvm.sh new file mode 100755 index 0000000..49d8145 --- /dev/null +++ b/old/enable_kvm.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync +xrandr --addmode VGA1 1920x1080_60.00 +xrandr --output VGA1 --mode 1920x1080_60.00 --right-of LVDS1 diff --git a/old/encode_webm.sh b/old/encode_webm.sh new file mode 100755 index 0000000..d7a6cfc --- /dev/null +++ b/old/encode_webm.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +ffmpeg -i $1 -pix_fmt yuv420p -f yuv4mpegpipe - 2>/dev/null | vpxenc --i420 -p 1 -t 4 --good --cpu-used=3 --target-bitrate=2000 --end-usage=vbr --fps=30000/1001 -v --kf-min-dist=0 --kf-max-dist=360 --token-parts=2 --static-thresh=0 --min-q=0 --max-q=63 -o $(basename $1).webm - + + diff --git a/old/feh_browser.desktop b/old/feh_browser.desktop new file mode 100644 index 0000000..39dc2af --- /dev/null +++ b/old/feh_browser.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=Feh Browser +GenericName=Image viewer +GenericName[en_US]=Image viewer +Comment=Fast Imlib2-based Image Viewer +Exec=feh_browser.sh %f -Z --scale-down +Terminal=false +Type=Application +Icon=/usr/share/feh/images/feh.png +Categories=Graphics;2DGraphics;Viewer; +MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-pcx;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-tga;image/x-xbitmap; +Name[en_US]=feh diff --git a/old/feh_browser.sh b/old/feh_browser.sh new file mode 100755 index 0000000..5b092ce --- /dev/null +++ b/old/feh_browser.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +shopt -s nullglob + +if [[ ! -f $1 ]]; then + echo "$0: first argument is not a file" >&2 + exit 1 +fi + +file=$(basename -- "$1") +dir=$(dirname -- "$1") +arr=() +shift + +cd -- "$dir" + +echo $file + +for i in *; do + [[ -f $i ]] || continue + arr+=("$i") + [[ "$i" == "$file" ]] && c=$((${#arr[@]} - 1)) +done + +exec feh "$@" -- "${arr[@]:c}" "${arr[@]:0:c}" diff --git a/runWinePrefix.sh b/runWinePrefix.sh new file mode 100755 index 0000000..d8abfff --- /dev/null +++ b/runWinePrefix.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +if [ $# -eq 0 ] +then + echo "No arguments supplied" +fi + +WINEDIR=$HOME/Pelit/Wine/$1/ + +export WINEDEBUG=-all +export WINEARCH=win32 +export WINEPREFIX=$WINEDIR + +echo "Run in $WINEDIR" +wine $2 + diff --git a/setTheme.sh b/setTheme.sh new file mode 100755 index 0000000..f9b2d7c --- /dev/null +++ b/setTheme.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +echo "Set theme to $1" +# GTK2 +gconftool-2 --type=string --set /desktop/gnome/interface/gtk_theme $1 + +# GTK3 +gsettings set org.gnome.desktop.interface gtk-theme $1 diff --git a/sxiv_browser.sh b/sxiv_browser.sh new file mode 100755 index 0000000..97868dd --- /dev/null +++ b/sxiv_browser.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Compatible with ranger 1.6.0 through 1.7.* +# +# This script searches image files in a directory, opens them all with sxiv and +# sets the first argument to the first image displayed by sxiv. +# +# This is supposed to be used in rifle.conf as a workaround for the fact that +# sxiv takes no file name arguments for the first image, just the number. Copy +# this file somewhere into your $PATH and add this at the top of rifle.conf: +# +# mime ^image, has sxiv, X, flag f = path/to/this/script -- "$@" +# +# Implementation notes: this script is quite slow because of POSIX limitations +# and portability concerns. First calling the shell function 'abspath' is +# quicker than calling 'realpath' because it would fork a whole process, which +# is slow. Second, we need to append a file list to sxiv, which can only be done +# properly in two ways: arrays (which are not POSIX) or \0 sperated +# strings. Unfortunately, assigning \0 to a variable is not POSIX either (will +# not work in dash and others), so we cannot store the result of listfiles to a +# variable. +# +# Implementation notes (lanxu): I wanted to add Natural Ordering support to the +# script. Therefore, I decided to use ls with '-v' flag and pass it to awk +# which adds the required null terminator. Additionally, I added max-chars +# parameter for xargs because I was hitting the default limit with my +# abnormally large image directories (5000+ files). +# + +# vim: set tabstop=8 softtabstop=0 shiftwidth=4 expandtab smarttab +if [ $# -eq 0 ]; then + echo "Usage: ${0##*/} PICTURES" + exit +fi + +[ "$1" == '--' ] && shift + +abspath () { + case "$1" in + /*) printf "%s\n" "$1";; + *) printf "%s\n" "$PWD/$1";; + esac +} + +listfiles () { + #find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex '.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z + ls -dv "$(dirname "$target")"/* | egrep '.*(jpe?g|bmp|png|gif)$' | awk '{print}' ORS='\0' +} + +target="$(abspath "$1")" +count="$(listfiles | grep -m 1 -ZznF "$target" | cut -d: -f1)" +if [ -n "$count" ]; then + listfiles | xargs -s 1280000 -0 sxiv -an "$count" -- +else + sxiv -- "$@" # fallback +fi