diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7aee4a5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+*.log
+*.old
+*.swp
+__pycache__
+temp
diff --git a/.hgignore b/.hgignore
deleted file mode 100644
index 952e1fc..0000000
--- a/.hgignore
+++ /dev/null
@@ -1,7 +0,0 @@
-.log
-.old
-.swp
-__pycache__
-temp
-.scr
-fetchers
diff --git a/README.md b/README.md
index 52d1b84..2e2d33c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,10 @@
# Script collection by lanxu :muscle:
This is a general collection of useful scripts used by me. Most of the scripts are written or modified by me.
+## Disclaimer
+
+Totally out-of-date. Will be updated in the future!
+
## Scripts by others
Script | Description
@@ -40,4 +44,3 @@ There are a few scripts that are just thrown into the mix in case I need them at
convertAtlasXMLToJson.php (convert sprite atlases to json)
sortPackagesBySize.sh (pacman script to sort packages by used size)
-
diff --git a/applications/itchio.desktop b/applications/itchio.desktop
new file mode 100644
index 0000000..a4c4b1a
--- /dev/null
+++ b/applications/itchio.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Application
+Name=itch (XWayland)
+Exec=env GDK_BACKEND=x11 itch %U
+Icon=itch
+Terminal=false
+Categories=Game;
+MimeType=x-scheme-handler/itchio;x-scheme-handler/itch;
+X-GNOME-Autostart-enabled=true
+Comment=Install and play itch.io games easily (uses X11 for games)
diff --git a/applications/lf_terminal.desktop b/applications/lf_terminal.desktop
new file mode 100644
index 0000000..c642e46
--- /dev/null
+++ b/applications/lf_terminal.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+Name=lf-terminal
+Comment=Launches the lf file manager
+Icon=utilities-terminal
+Exec=kitty -e lf
+Categories=System;FileTools;FileManager
+MimeType=inode/directory;
diff --git a/applications/mullvad-vpn.desktop b/applications/mullvad-vpn.desktop
new file mode 100644
index 0000000..2d6e44e
--- /dev/null
+++ b/applications/mullvad-vpn.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=Mullvad VPN (XWayland)
+Exec=env GDK_BACKEND=x11 "/opt/Mullvad VPN/mullvad-vpn" %U
+Terminal=false
+Type=Application
+Icon=mullvad-vpn
+StartupWMClass=Mullvad VPN
+Comment=Mullvad VPN client
+Categories=Network;
diff --git a/attic/btpower.sh b/attic/btpower.sh
new file mode 100644
index 0000000..f8318dd
--- /dev/null
+++ b/attic/btpower.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+DEVICES=$(upower -e)
+
+for device in $DEVICES; do
+ info=$(upower -i $device)
+ echo "$info"
+ model=$(echo "$info" | grep -oP 'model: \K\w+[a-zA-Z0-9 ]*$')
+ battery=$(echo "$info" | grep -oP 'percentage: [0-9 ]*%')
+ echo "$model: $battery"
+done
diff --git a/attic/checkupdates.sh b/attic/checkupdates.sh
new file mode 100755
index 0000000..2a71c85
--- /dev/null
+++ b/attic/checkupdates.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+#UPDATES=$(checkupdates | sed ':a;N;$!ba;s/\n/ /g')
+CHECKUPDATES=$(checkupdates)
+UPDATES=$(echo "${CHECKUPDATES}" | sed 's/->/-\>/g' | sed ':a;N;$!ba;s/\n/
/g')
+NUM_UPDATES=$(echo "${CHECKUPDATES}" | wc -l)
+
+#echo "{\"text\": \"${NUM_UPDATES}\", \"tooltip\":\"$UPDATES\"}"
+printf "{\"text\": \"%s\", \"tooltip\": \"%s\"}" $(checkupdates | wc -l) "$(checkupdates | tr '\n' '\r')"
diff --git a/hubic.py b/attic/hubic.py
similarity index 100%
rename from hubic.py
rename to attic/hubic.py
diff --git a/keepass.sh b/attic/keepass.sh
similarity index 100%
rename from keepass.sh
rename to attic/keepass.sh
diff --git a/lastpass.sh b/attic/lastpass.sh
similarity index 100%
rename from lastpass.sh
rename to attic/lastpass.sh
diff --git a/md_create_eplist.py b/attic/md_create_eplist.py
similarity index 100%
rename from md_create_eplist.py
rename to attic/md_create_eplist.py
diff --git a/ranger.sh b/attic/ranger.sh
similarity index 100%
rename from ranger.sh
rename to attic/ranger.sh
diff --git a/run-wine-prefix.sh b/attic/run-wine-prefix.sh
similarity index 100%
rename from run-wine-prefix.sh
rename to attic/run-wine-prefix.sh
diff --git a/search.sh b/attic/search.sh
similarity index 100%
rename from search.sh
rename to attic/search.sh
diff --git a/dunst_message.sh b/dunst_message.sh
index c98148d..97ba3eb 100755
--- a/dunst_message.sh
+++ b/dunst_message.sh
@@ -3,8 +3,10 @@
appname=$1
sound="message"
-if [ "$appname" = "Telegram-desktop" ]; then
+if [ $appname = "Telegram Desktop" ]; then
sound="window-attention"
fi
+echo "$1" >> /tmp/test
+echo "$sound" >> /tmp/test
mpv --no-terminal /usr/share/sounds/freedesktop/stereo/$sound.oga&
diff --git a/fetchers/fetch_groupees.py b/fetchers/fetch_groupees.py
new file mode 100644
index 0000000..71c532e
--- /dev/null
+++ b/fetchers/fetch_groupees.py
@@ -0,0 +1,31 @@
+#!/bin/python
+
+import requests
+import sys
+import re
+
+def get_urls(text):
+ text = text.replace('\n', ' ').replace('\r', '')
+ #r = re.compile("\"(https:([^<>]*))\">", re.I|re.M)
+ urls = []
+
+ matches = re.findall("\"(https:([^<>]*))\">", text)
+ if matches:
+ for m in matches:
+ urls.append(m[0])
+ return urls
+
+if __name__ == "__main__":
+ url = sys.argv[1]
+ jar = requests.cookies.RequestsCookieJar()
+ jar.set('_groupees_session', 'OWFWT1ZVTVZtdkFJU2NUUW5ZM2kwblNtTkFYVW0xdUhSWlVpdmROZE9ITWE0UDJIQlV5bmRpcXZLOTF5S1B1Z2lQZ08zUkJpT05FeVRaL0xQcDJJL1hKaVMvOWJPQUVvTTNzVjlaVERXQ2s5RE9WeEc4aWk1ZU9zMGVJd0tscGhLazZvSjVCQWZPMEdFWmVEdXZSYWNld3lTWDlyY1ZYdGdXOG54OXkrOUYyRjB4UXBpVUJJTXloZkN2REhYNTlwZ0s0NlVtbVNBclBRSXZEYVRmZXo1dz09LS0rOEkxVmUvR0ZCUEY1d3Y1RDVXSHd3PT0%3D--fc3a4f506f7c4a283a5d105ae9cb400b604a7fc8', domain='.groupees.com', path="/")
+ r = requests.get(url, cookies=jar)
+ urls = get_urls(r.text)
+ file_urls = [u for u in urls if "https://storage.groupees.com" in u]
+
+ cookie = jar.get('_groupees_session')
+ print("header=\"Cookie:_groupees_session=%s;\"" % cookie)
+ for file_url in file_urls:
+ print("remote-header-name")
+ print("remote-name")
+ print("url=\"%s\"" % (file_url))
diff --git a/gputemp.py b/gputemp.py
index 4455f18..90e67b6 100755
--- a/gputemp.py
+++ b/gputemp.py
@@ -2,12 +2,19 @@
import re
import logging
+from logging.handlers import RotatingFileHandler
import subprocess
from subprocess import check_output
import lib.helpers as helpers
-FORMAT = "%(asctime)s %(levelname)s %(message)s"
-logging.basicConfig(format=FORMAT, filename=__file__+'.log', level=logging.DEBUG)
+log_formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
+
+log_handler = RotatingFileHandler(__file__+'.log', maxBytes=1024*1024*10, mode='a', backupCount=0, encoding=None, delay=0)
+log_handler.setFormatter(log_formatter)
+log_handler.setLevel(logging.DEBUG)
+logger = logging.getLogger('root')
+logger.setLevel(logging.DEBUG)
+logger.addHandler(log_handler)
ATICONFIG_AVAILABLE = helpers.is_exe("/usr/bin/aticonfig")
SENSORS_AVAILABLE = helpers.is_exe("/usr/bin/sensors")
@@ -16,7 +23,7 @@ def get_temperature():
command = None
if SENSORS_AVAILABLE:
- commands = ["sensors amdgpu-pci-0800 | grep edge",
+ commands = ["sensors amdgpu-pci-0a00 | grep edge",
"sensors radeon-pci-* | grep temp1",
"sensors thinkpad-isa-0000 | grep ATI"]
@@ -48,8 +55,8 @@ def get_temperature():
m = re.search(r'- (.*) C', return_value.decode("utf-8"))
temp = m.group(1)
else:
- logging.info('wat')
- logging.info(temp)
+ logger.info('wat')
+ logger.info(temp)
return temp
print(get_temperature())
diff --git a/creategif.py b/helpers/creategif.py
similarity index 100%
rename from creategif.py
rename to helpers/creategif.py
diff --git a/encode-vp9.py b/helpers/encode-vp9.py
similarity index 100%
rename from encode-vp9.py
rename to helpers/encode-vp9.py
diff --git a/gen-ctags.sh b/helpers/gen-ctags.sh
similarity index 100%
rename from gen-ctags.sh
rename to helpers/gen-ctags.sh
diff --git a/htpasswd.sh b/helpers/htpasswd.sh
similarity index 100%
rename from htpasswd.sh
rename to helpers/htpasswd.sh
diff --git a/lock.sh b/i3/lock.sh
similarity index 100%
rename from lock.sh
rename to i3/lock.sh
diff --git a/screenoff.sh b/i3/screenoff.sh
similarity index 100%
rename from screenoff.sh
rename to i3/screenoff.sh
diff --git a/screensaver.sh b/i3/screensaver.sh
similarity index 100%
rename from screensaver.sh
rename to i3/screensaver.sh
diff --git a/setup_tablet.sh b/i3/setup_tablet.sh
similarity index 100%
rename from setup_tablet.sh
rename to i3/setup_tablet.sh
diff --git a/sxiv_browser.sh b/i3/sxiv_browser.sh
similarity index 100%
rename from sxiv_browser.sh
rename to i3/sxiv_browser.sh
diff --git a/i3/xscreensaverstopper.sh b/i3/xscreensaverstopper.sh
new file mode 100755
index 0000000..2c2efff
--- /dev/null
+++ b/i3/xscreensaverstopper.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# xscreensaverstopper.sh
+
+# This script is licensed under GNU GPL version 2.0 or above
+
+# Uses elements from lightsOn.sh
+# Copyright (c) 2011 iye.cba at gmail com
+# url: https://github.com/iye/lightsOn
+# This script is licensed under GNU GPL version 2.0 or above
+
+# Description: Restarts xscreensaver's idle countdown while
+# full screen applications are running.
+# Checks every 30 seconds to see if a full screen application
+# has focus, if so then the xscreensaver is told to restart
+# its idle countdown.
+
+
+# enumerate all the attached screens
+displays=""
+while read id
+do
+ displays="$displays $id"
+done< <(xvinfo | sed -n 's/^screen #\([0-9]\+\)$/\1/p')
+
+checkFullscreen()
+{
+
+ # loop through every display looking for a fullscreen window
+ for display in $displays
+ do
+ #get id of active window and clean output
+ activ_win_id=`DISPLAY=$DISPLAY.${display} xprop -root _NET_ACTIVE_WINDOW`
+ activ_win_id=${activ_win_id:40:9}
+
+ # Check if Active Window (the foremost window) is in fullscreen state
+ isActivWinFullscreen=`DISPLAY=$DISPLAY.${display} xprop -id $activ_win_id | grep _NET_WM_STATE_FULLSCREEN`
+ if [[ "$isActivWinFullscreen" == *NET_WM_STATE_FULLSCREEN* ]];then
+ xscreensaver-command -deactivate
+ fi
+ done
+}
+
+while sleep $((30)); do
+ checkFullscreen
+done
+
+exit 0
diff --git a/import-gsettings b/import-gsettings
new file mode 100755
index 0000000..410f23c
--- /dev/null
+++ b/import-gsettings
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# By default wayland only reads settings from gsettings and not from settings.ini
+
+# usage: import-gsettings
+config="${XDG_CONFIG_HOME:-$HOME/.config}/gtk-3.0/settings.ini"
+if [ ! -f "$config" ]; then exit 1; fi
+
+gnome_schema="org.gnome.desktop.interface"
+gtk_theme="$(grep 'gtk-theme-name' "$config" | sed 's/.*\s*=\s*//')"
+icon_theme="$(grep 'gtk-icon-theme-name' "$config" | sed 's/.*\s*=\s*//')"
+cursor_theme="$(grep 'gtk-cursor-theme-name' "$config" | sed 's/.*\s*=\s*//')"
+font_name="$(grep 'gtk-font-name' "$config" | sed 's/.*\s*=\s*//')"
+gsettings set "$gnome_schema" gtk-theme "$gtk_theme"
+gsettings set "$gnome_schema" icon-theme "$icon_theme"
+gsettings set "$gnome_schema" cursor-theme "$cursor_theme"
+gsettings set "$gnome_schema" font-name "$font_name"
diff --git a/powermenu.sh b/powermenu.sh
index 4ba5128..ac8ece6 100755
--- a/powermenu.sh
+++ b/powermenu.sh
@@ -12,7 +12,7 @@ case $op in
;;
lock)
#loginctl lock-session
- swaylock -f -c 221122
+ swaylock -f -c 000000
;;
logout)
swaymsg exit
diff --git a/run-desktop.sh b/run-desktop-file
similarity index 100%
rename from run-desktop.sh
rename to run-desktop-file
diff --git a/run-xhost b/run-xhost
new file mode 100755
index 0000000..cbae073
--- /dev/null
+++ b/run-xhost
@@ -0,0 +1,5 @@
+#!/bin/sh
+echo "$@"
+xhost +si:lanxu:root
+pkexec "$@"
+xhost -si:lanxu:root
diff --git a/startwayland b/startwayland
index 18b0eb7..ecfe53e 100755
--- a/startwayland
+++ b/startwayland
@@ -10,16 +10,22 @@ export XKB_DEFAULT_MODEL=pc105
# configure wayland backend
export GDK_BACKEND=wayland
export QT_QPA_PLATFORM=wayland # wayland-egl?
+export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
+export QT_AUTO_SCREEN_SCALE_FACTOR=1
export CLUTTER_BACKEND=wayland
export SDL_VIDEODRIVER=wayland
export EWOL_BACKEND=wayland
+
# firefox
export MOZ_ENABLE_WAYLAND=1
export MOZ_DBUS_REMOTE=1
+
# auth
-eval $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh)
-export SSH_AUTH_SOCK
+#eval $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh)
+#export SSH_AUTH_SOCK
# start!
-sway
+XDG_CURRENT_DESKTOP=sway XDG_SESSION_TYPE=wayland sway
+#XDG_CURRENT_DESKTOP=kde XDG_SESSION_TYPE=wayland dbus-run-session startplasma-wayland
+#XDG_CURRENT_DESKTOP=gnome XDG_SESSION_TYPE=wayland dbus-run-session gnome-shell --wayland
diff --git a/steam b/steam
index 0698f29..94bd103 100755
--- a/steam
+++ b/steam
@@ -1,4 +1,5 @@
#!/bin/sh
-XDG_CURRENT_DESKTOP=XFCE xdg-dbus-proxy "$DBUS_SESSION_BUS_ADDRESS" "$XDG_RUNTIME_DIR/steam-bus-proxy" --filter --call="org.freedesktop.DBus.*=*" --call="org.freedesktop.IBus.*=*" --call="org.freedesktop.portal.*=*" --call="com.feralinteractive.GameMode.*=*" --call="com.canonical.*=*" --broadcast="*=*" --call="org.kde.*=*" --call="org.gtk.*=*" &
+#XDG_CURRENT_DESKTOP=XFCE xdg-dbus-proxy "$DBUS_SESSION_BUS_ADDRESS" "$XDG_RUNTIME_DIR/steam-bus-proxy" --filter --call="org.freedesktop.DBus.*=*" --call="org.freedesktop.IBus.*=*" --call="org.freedesktop.portal.*=*" --call="com.feralinteractive.GameMode.*=*" --call="com.canonical.*=*" --broadcast="*=*" --call="org.kde.*=*" --call="org.gtk.*=*" &
+xdg-dbus-proxy "$DBUS_SESSION_BUS_ADDRESS" "$XDG_RUNTIME_DIR/steam-bus-proxy" --filter --call="org.freedesktop.DBus.*=*" --call="org.freedesktop.IBus.*=*" --call="org.freedesktop.portal.*=*" --call="com.feralinteractive.GameMode.*=*" --call="com.canonical.*=*" --broadcast="*=*" --call="org.kde.*=*" --call="org.gtk.*=*" &
DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/steam-bus-proxy" /usr/bin/steam
kill %1
diff --git a/sway/fullscreen-inhibiter.service b/sway/fullscreen-inhibiter.service
new file mode 100644
index 0000000..ef2bb96
--- /dev/null
+++ b/sway/fullscreen-inhibiter.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=fullscreen inhibiter for sway
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh /home/lanxu/Scripts/sway/fullscreen-inhibiter.sh
diff --git a/sway/fullscreen-inhibiter.sh b/sway/fullscreen-inhibiter.sh
new file mode 100755
index 0000000..6a8a637
--- /dev/null
+++ b/sway/fullscreen-inhibiter.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Get all open windows from sway
+IN_FULLSCREEN=$(swaymsg -t get_tree | jq '[[recurse(.nodes[]) | del(.nodes)] | .[] | select((.window_properties.class) or (.app_id)) | {app_id: .app_id, class: .window_properties.class, fullscreen_mode: .fullscreen_mode}]' | jq 'any(.fullscreen_mode == 1)')
+
+if [ $IN_FULLSCREEN = "true" ]; then
+ dunstctl set-paused true
+else
+ dunstctl set-paused false
+fi
diff --git a/sway/fullscreen-inhibiter.timer b/sway/fullscreen-inhibiter.timer
new file mode 100644
index 0000000..c44680f
--- /dev/null
+++ b/sway/fullscreen-inhibiter.timer
@@ -0,0 +1,9 @@
+[Unit]
+Description=Fullscreen inhibiter for Sway timer
+
+[Timer]
+OnUnitActiveSec=10s
+OnBootSec=10s
+
+[Install]
+WantedBy=timers.target
diff --git a/setup_table_sway.sh b/sway/setup-tablet.sh
old mode 100644
new mode 100755
similarity index 74%
rename from setup_table_sway.sh
rename to sway/setup-tablet.sh
index 5247423..2d17ae5
--- a/setup_table_sway.sh
+++ b/sway/setup-tablet.sh
@@ -5,7 +5,8 @@
# Get ouputs
# swaymsg -t get_outputs
-PAD_ID="9580:110:HID_256c:006e_Pad"
+#PAD_ID="9580:110:HID_256c:006e_Pad"
+PAD_ID="9580:110:HID_256c:006e"
OUTPUT="DP-2"
echo "swaymsg 'input $PAD_ID map_to_output $OUTPUT'"
diff --git a/sway/take_screenshot.sh b/sway/take_screenshot.sh
new file mode 100755
index 0000000..61ac148
--- /dev/null
+++ b/sway/take_screenshot.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+MODE=$1
+FILENAME=$(xdg-user-dir PICTURES)/$(date +%F_%T_grim.png)
+
+case $MODE in "region-copy") grim -g "$(slurp)" - | wl-copy;;
+ "region") grim -g "$(slurp)" $FILENAME && notify-send -i "$FILENAME" "Screenshot saved";;
+ *) grim $FILENAME && notify-send -i "$FILENAME" "Screenshot saved";;
+esac
diff --git a/sway_screensaver.sh b/sway_screensaver.sh
new file mode 100755
index 0000000..0439c1e
--- /dev/null
+++ b/sway_screensaver.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+swayidle -w \
+ timeout 30 'swaylock -f -c 000000' \
+ timeout 60 'swaymsg "output * dpms off"' \
+ resume 'swaymsg "output * dpms on"' \
+ before-sleep 'swaylock -f -c 000000'
diff --git a/echo.sh b/testing/echo.sh
similarity index 100%
rename from echo.sh
rename to testing/echo.sh
diff --git a/testing/run_zandronum.sh b/testing/run_zandronum.sh
new file mode 100644
index 0000000..000a4c3
--- /dev/null
+++ b/testing/run_zandronum.sh
@@ -0,0 +1,9 @@
+docker run -it \
+ --rm \
+ -p 10666:10666 \
+ -v /usr/share/games/doom/:/wads:ro \
+ --name=zandronum-server \
+ frozenfoxx/zandronum-server:latest \
+ -cooperative \
+ -lan \
+ -private
diff --git a/testing/sheet_process.sh b/testing/sheet_process.sh
new file mode 100644
index 0000000..d3ae40b
--- /dev/null
+++ b/testing/sheet_process.sh
@@ -0,0 +1,3 @@
+mogrify -format png *.tga
+rm *.tga
+mogrify -crop 256x400+0+0 +repage *.png
diff --git a/udevmonitord.py b/testing/udevmonitord.py
similarity index 100%
rename from udevmonitord.py
rename to testing/udevmonitord.py
diff --git a/tools/24-bit-color.sh b/tools/24-bit-color.sh
new file mode 100644
index 0000000..f407258
--- /dev/null
+++ b/tools/24-bit-color.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+# This file was originally taken from iterm2 https://github.com/gnachman/iTerm2/blob/master/tests/24-bit-color.sh
+#
+# This file echoes a bunch of 24-bit color codes
+# to the terminal to demonstrate its functionality.
+# The foreground escape sequence is ^[38;2;;;m
+# The background escape sequence is ^[48;2;;;m
+# range from 0 to 255 inclusive.
+# The escape sequence ^[0m returns output to default
+
+setBackgroundColor()
+{
+ #printf '\x1bPtmux;\x1b\x1b[48;2;%s;%s;%sm' $1 $2 $3
+ printf '\x1b[48;2;%s;%s;%sm' $1 $2 $3
+}
+
+resetOutput()
+{
+ echo -en "\x1b[0m\n"
+}
+
+# Gives a color $1/255 % along HSV
+# Who knows what happens when $1 is outside 0-255
+# Echoes "$red $green $blue" where
+# $red $green and $blue are integers
+# ranging between 0 and 255 inclusive
+rainbowColor()
+{
+ let h=$1/43
+ let f=$1-43*$h
+ let t=$f*255/43
+ let q=255-t
+
+ if [ $h -eq 0 ]
+ then
+ echo "255 $t 0"
+ elif [ $h -eq 1 ]
+ then
+ echo "$q 255 0"
+ elif [ $h -eq 2 ]
+ then
+ echo "0 255 $t"
+ elif [ $h -eq 3 ]
+ then
+ echo "0 $q 255"
+ elif [ $h -eq 4 ]
+ then
+ echo "$t 0 255"
+ elif [ $h -eq 5 ]
+ then
+ echo "255 0 $q"
+ else
+ # execution should never reach here
+ echo "0 0 0"
+ fi
+}
+
+for i in `seq 0 127`; do
+ setBackgroundColor $i 0 0
+ echo -en " "
+done
+resetOutput
+for i in `seq 255 -1 128`; do
+ setBackgroundColor $i 0 0
+ echo -en " "
+done
+resetOutput
+
+for i in `seq 0 127`; do
+ setBackgroundColor 0 $i 0
+ echo -n " "
+done
+resetOutput
+for i in `seq 255 -1 128`; do
+ setBackgroundColor 0 $i 0
+ echo -n " "
+done
+resetOutput
+
+for i in `seq 0 127`; do
+ setBackgroundColor 0 0 $i
+ echo -n " "
+done
+resetOutput
+for i in `seq 255 -1 128`; do
+ setBackgroundColor 0 0 $i
+ echo -n " "
+done
+resetOutput
+
+for i in `seq 0 127`; do
+ setBackgroundColor `rainbowColor $i`
+ echo -n " "
+done
+resetOutput
+for i in `seq 255 -1 128`; do
+ setBackgroundColor `rainbowColor $i`
+ echo -n " "
+done
+resetOutput
diff --git a/tools/gif_anim_montage.sh b/tools/gif_anim_montage.sh
new file mode 100755
index 0000000..10c0463
--- /dev/null
+++ b/tools/gif_anim_montage.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+#
+# gif_anim_montage [options] animation.gif [output_image]
+#
+# Convert a GIF animation into a strip showing each sub-frame of the
+# animation with a black border, positioned in the larger canvas context
+# of the animation. Also include a label defining the size and position,
+# and disposal setting of each frame in the animation.
+#
+# OPTIONS:
+# -u Underlay a dimmed coaleased image (context for frame)
+# -c Add checkerboard background for transparent areas
+# -g Use granite for background
+# -w Use a white background
+# -b Use a black background
+# -t image Use this image (or color image) for background
+# -r Use a red border color rather than black
+# #x# tile the images (default one single row)
+# -n Don't label the animation frames (not important)
+#
+####
+#
+# WARNING: Input arguments are NOT tested for correctness.
+# This script represents a security risk if used ONLINE.
+# I accept no responsiblity for misuse. Use at own risk.
+#
+# Anthony Thyssen Feburary 2006
+#
+PROGNAME=`type $0 | awk '{print $3}'` # search for executable on path
+PROGDIR=`dirname $PROGNAME` # extract directory of program
+PROGNAME=`basename $PROGNAME` # base name of program
+Usage() { # output the script comments as docs
+ echo >&2 "$PROGNAME:" "$@"
+ sed >&2 -n '/^###/q; /^#/!q; s/^#//; s/^ //; 3s/^/Usage: /; 2,$ p' \
+ "$PROGDIR/$PROGNAME"
+ exit 10;
+}
+
+border=black
+thickness=1x1
+pointsize=10
+tile='-tile x1'
+montage_opts=""
+method=1
+background=none
+
+# Figure out the montage label to use
+# Does IM understand %T as the frame time delay?
+label='%s: %D\n%wx%h%O'
+case `identify -format %T rose:` in
+0) label="%D, %Tcs\n%wx%h%O"
+esac
+
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --help|--doc*) Usage ;;
+ -u) method=2 ;; # add disposal image context
+ -n) label='' ;; # don't label the montage
+ -c) tile_image="pattern:checkerboard" ;;
+ -g) tile_image="granite:" ;;
+ -w) background="white" ;;
+ -b) background="black" ;;
+ -r) border=red ;;
+ [0-9]*x*[0-9]|[0-9]*x|x*[0-9])
+ X=`expr "$1" : '\([0-9]*\)x'`
+ Y=`expr "$1" : '[0-9]*x\([0-9]*\)$'`
+ tile="-tile ${X}x${Y}"
+ ;;
+ -) break ;; # stdin filename
+ --) shift; break ;; # end of user options
+ -*) Usage "Unknown option \"$1\"" ;;
+ *) break ;; # end of user options
+ esac
+ shift # next option
+done
+
+input="$1"
+[ $# -eq 0 ] && Usage "Missing Animation to Montage"
+[ $# -eq 1 ] && output='show:'
+[ $# -eq 2 ] && output="$2"
+[ $# -gt 2 ] && Usage "Too Many Arguments"
+
+if [ "$tile_image" ]; then
+ montage_opts="$montage_opts -texture $tile_image"
+fi
+if [ "$background" ]; then
+ montage_opts="$montage_opts -background $background"
+fi
+
+case "$method" in
+ 1) # Montage only method
+ convert "$input" -set background none -alpha on -set label "$label" \
+ -compose Copy -bordercolor $border -border $thickness \
+ -set dispose Background -coalesce miff:- |\
+ montage - -frame 4 -geometry '+1+1' $tile \
+ -bordercolor none -pointsize $pointsize \
+ $montage_opts "$output"
+ ;;
+ 2) # Montage with a disposed image underlay
+ # Still need some way to make the underlay partically transparent
+ convert "$input" -set label "$label" -write mpr:a \
+ -coalesce -bordercolor none -border $thickness \
+ -channel A -evaluate divide 2 +channel null: \
+ \( mpr:a -bordercolor none -mattecolor $border -frame $thickness \
+ \) -layers Composite \
+ miff:- | \
+ montage - -frame 4 -geometry '+1+1' $tile \
+ -bordercolor none -pointsize $pointsize \
+ $montage_opts "$output"
+ ;;
+ 3) # convert only method -- no montage labels :-(
+ convert -dispose Background "$input" \
+ -compose Copy -bordercolor $border -border $thickness \
+ -compose Over -coalesce -bordercolor none -frame 4x4+1+1 \
+ -bordercolor none -border 2x2 +append -set delay 0 \
+ $montage_opts "$output"
+
+esac
diff --git a/tools/updateorigin.sh b/tools/updateorigin.sh
new file mode 100644
index 0000000..dedbea6
--- /dev/null
+++ b/tools/updateorigin.sh
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+PATH32="drive_c/Program Files/Origin"
+PATH64="drive_c/Program Files (x86)/Origin"
+UPDATEPATH=""
+
+update() {
+ local DIR="$1"
+ if which aria2c; then
+ command="aria2c -x8 -c"
+ else
+ command="wget"
+ fi
+ echo "Downloading latest Origin setup file:"
+
+ if $command "https://download.dm.origin.com/origin/live/OriginSetup.exe"; then
+ echo "Extracting the installation file:"
+ unzip OriginSetup.exe 'update/*.zip'
+ unzip -o ./update/*.zip -d "$DIR"
+ echo "Cleaning up..."
+ rm -r ./update
+ rm OriginSetup.exe
+ echo "Done!"
+ fi
+}
+
+if [[ ! -z "$WINEPREFIX" ]];
+then
+
+ # exit if no Origin folder can be found in the WINEPREFIX
+ if [[ ! -e "$WINEPREFIX/$PATH32" ]] && [[ ! -e "$WINEPREFIX/$PATH64" ]];
+ then
+ echo "Origin not found in WINEPREFIX!"
+ echo "Please run this script again with the correct WINEPREFIX"
+ echo "or cd to your Origin directory and run the script there."
+ exit 1
+ fi
+
+ # check which installation of Origin is present. If both are (dunno why), then 64bit is being used
+ if [[ -e "$WINEPREFIX/$PATH32" ]];
+ then
+ UPDATEPATH=$PATH32
+ echo "Found a 32bit installation of Origin, going to use this:"
+ fi
+ if [[ -e "$WINEPREFIX/$PATH64" ]];
+ then
+ UPDATEPATH=$PATH64
+ echo "Found a 64bit installation of Origin, going to use this:"
+ fi
+
+ # ouput the folder, so that the user has confirmation
+ echo "=> $WINEPREFIX/$UPDATEPATH"
+
+ # now we do our magic!
+ update "$WINEPREFIX/$UPDATEPATH"
+ exit 0
+
+fi
+if [[ -z $WINEPREFIX ]]
+then
+ echo "WINEPREFIX not passed, checking working directory..."
+ if [[ -w "$PWD/Origin.exe" ]];
+ then
+ update "$PWD"
+ exit 0
+ fi
+ if [[ ! -w "$PWD/Origin.exe" ]];
+ then
+ echo "Origin.exe not found in working directory!"
+ echo "Please enter your Origin installation path:"
+ read -e path
+ if [[ -w "$path/Origin.exe" ]];
+ then
+ update "$path"
+ fi
+ if [[ ! -w "$path/Origin.exe" ]];
+ then
+ echo "This path does not contain Origin.exe!"
+ fi
+ fi
+fi
diff --git a/tools/vimeo-audio-and-video.py b/tools/vimeo-audio-and-video.py
new file mode 100755
index 0000000..b635767
--- /dev/null
+++ b/tools/vimeo-audio-and-video.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python3
+import argparse
+import base64
+import os
+import re
+import requests
+import subprocess
+from tqdm import tqdm
+
+parser = argparse.ArgumentParser()
+parser.add_argument('-i', '--url-list', help='List of URL/filename pairs, delimited by tabs')
+args = parser.parse_args()
+
+for line in open(args.url_list):
+ output_file, master_json_url = line.rstrip().split('\t')
+ print('\n\n\nProcessing %s' % output_file)
+
+ # Extract some stuff
+ base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1]
+ resp = requests.get(master_json_url)
+ content = resp.json()
+
+ # Video download here
+ heights = [(i, d['height']) for (i, d) in enumerate(content['video'])]
+ idx = max(heights, key=lambda x: x[1])[0]
+ video = content['video'][idx]
+ video_base_url = base_url + content['base_url'] + video['base_url']
+ print('Base url:', video_base_url)
+
+ filenameVideo = 'video_%s.mp4' % video['id']
+ print('Saving VIDEO to %s' % filenameVideo)
+
+ video_file = open(filenameVideo, 'wb')
+
+ init_segment = base64.b64decode(video['init_segment'])
+ video_file.write(init_segment)
+
+ for segment in tqdm(video['segments']):
+ segment_url = video_base_url + segment['url']
+ print(segment_url + '\n')
+ print(video_base_url+ '\n')
+ print(segment['url']+ '\n')
+ resp = requests.get(segment_url, stream=True)
+ if resp.status_code != 200:
+ print('not 200!')
+ print(resp)
+ print(segment_url)
+ break
+ for chunk in resp:
+ video_file.write(chunk)
+
+ video_file.flush()
+ video_file.close()
+
+ # Audio download here
+ bitrate = [(i, d['bitrate']) for (i, d) in enumerate(content['audio'])]
+
+ print('Bitrate', bitrate)
+
+ idx = max(bitrate, key=lambda x: x[1])[0]
+ audio = content['audio'][idx]
+ audio_base_url = base_url + content['base_url'] + audio['base_url']
+ print('Base url:', audio_base_url)
+
+ filenameAudio = 'audio_%s.mp4' % audio['id']
+ print('Saving AUDIO to %s' % filenameAudio)
+
+ audio_file = open(filenameAudio, 'wb')
+
+ init_segment = base64.b64decode(audio['init_segment'])
+ audio_file.write(init_segment)
+
+ for segment in tqdm(audio['segments']):
+ segment_url = audio_base_url + segment['url']
+ segment_url = re.sub(r'/[a-zA-Z0-9_-]*/\.\./',r'/',segment_url.rstrip())
+ resp = requests.get(segment_url, stream=True)
+ if resp.status_code != 200:
+ print('not 200!')
+ print(resp)
+ print(segment_url)
+ break
+ for chunk in resp:
+ audio_file.write(chunk)
+
+ audio_file.flush()
+ audio_file.close()
+
+ # Combine audio and video here
+ print('Combining video and audio...')
+ cmd = 'ffmpeg -y -i '
+ cmd += filenameAudio
+ cmd += ' -i '
+ cmd += filenameVideo
+ cmd += ' ' + output_file
+ subprocess.call(cmd, shell=True)
+ print('Mixing Done!')
+
+ # Delete the remaining single audio and video files
+# os.remove(filenameAudio)
+# os.remove(filenameVideo)
+# print("Temporary files removed!")
+
+ # Log the conclusion of the operations
+ print("*** VIDEO DOWNLOADED SUCCESSFULLY ***")
+ print(video['base_url'])
diff --git a/wayland-setup/setup_wayland_apps.sh b/wayland-setup/setup_wayland_apps.sh
new file mode 100644
index 0000000..e2c19d5
--- /dev/null
+++ b/wayland-setup/setup_wayland_apps.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# First, set flatpak overrides
+flatpak override --user --socket=wayland io.freetubeapp.FreeTube