Compare commits

..

11 Commits

Author SHA1 Message Date
0aa4626753 Added docker rootless script and phone mounting script 2022-04-24 18:58:48 +03:00
d4273a1609 Added screencasting scripts 2022-04-24 18:54:27 +03:00
407c93c90d Fixed fullscreen inhibitor 2022-04-05 21:08:20 +03:00
0bb20e93b0 Removed debugging from dunst message 2022-04-04 00:09:19 +03:00
ea19f3a47c Fixed naming 2022-04-04 00:01:26 +03:00
d3bdb21f94 Moved helpers to tools 2022-04-03 23:53:51 +03:00
4bff0c15f5 Removed attic 2022-04-03 23:53:51 +03:00
a101b152eb Added all changes since last year 2022-04-03 23:53:51 +03:00
lanxu
dccfecec74 Added new scripts for various use-cases 2022-04-03 23:53:51 +03:00
lanxu
1ce822854d Fixed typo 2021-07-25 17:08:17 +03:00
lanxu
3d45c4509f Automatic authentication and improved support for firefox and tablets 2021-07-25 17:02:55 +03:00
60 changed files with 1182 additions and 260 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
*.log
*.old
*.swp
__pycache__
temp

View File

@ -1,6 +0,0 @@
.log
.old
.swp
__pycache__
temp
.scr

View File

@ -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)

View File

@ -0,0 +1,14 @@
[Desktop Entry]
Name=imv-folder
Name[en_US]=imv
GenericName=Image viewer
GenericName[en_US]=Image viewer
Comment=Fast freeimage-based Image Viewer | Open all images on a folder
Exec=imv-dir %f
NoDisplay=true
Terminal=false
Type=Application
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;
Icon=multimedia-photo-viewer
Keywords=photo;picture;

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -1,95 +0,0 @@
#!/bin/php
<?php
$VERSION = 1;
if (isset($argv)) {
//get the file name
$filename = $argv[1];
//see if that file exists
if (file_exists($filename)) {
$xml = simplexml_load_file($filename);
//the xml is now imported
$json = convertXMLToJSONHash($xml);
$new_filename = explode(".", $filename)[0] . ".json";
logMsg("{$json->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";
}
?>

View File

@ -1,5 +0,0 @@
#!/bin/bash
s=`~/Scripts/dropbox.py puburl "$1"`
zenity --info --text="$s" && echo "$s" | xclip -selection c

View File

@ -1,17 +0,0 @@
#!/bin/sh
# This script restores local aur repository after fuckup with cleaning which
# happens way too often for me
echo "Creating custom repository..."
sudo install -d /var/cache/pacman/custom -o lanxu
repo-add /var/cache/pacman/custom/custom.db.tar
aur sync -u
echo "Retrieving aur packages which are installed..."
pacman -Qm | cut -f 1 -d " " > aur-packages.txt
echo "Installing..."
xargs -a aur-packages.txt aur sync
echo "Done."

10
docker-clean Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
# Stop everything
docker stop $(docker ps -a -q)
# Remove all containers
docker rm $(docker ps -a -q)
# Remove all imagesa
docker rmi $(docker images -q)

252
docker/rootless.sh Normal file
View File

@ -0,0 +1,252 @@
#!/bin/sh
set -e
# Docker CE for Linux installation script (Rootless mode)
#
# See https://docs.docker.com/go/rootless/ for the
# installation steps.
#
# This script is meant for quick & easy install via:
# $ curl -fsSL https://get.docker.com/rootless -o get-docker.sh
# $ sh get-docker.sh
#
# NOTE: Make sure to verify the contents of the script
# you downloaded matches the contents of install.sh
# located at https://github.com/docker/docker-install
# before executing.
#
# Git commit from https://github.com/docker/docker-install when
# the script was uploaded (Should only be modified by upload job):
SCRIPT_COMMIT_SHA=0225270
# This script should be run with an unprivileged user and install/setup Docker under $HOME/bin/.
# The channel to install from:
# * nightly
# * test
# * stable
DEFAULT_CHANNEL_VALUE="stable"
if [ -z "$CHANNEL" ]; then
CHANNEL=$DEFAULT_CHANNEL_VALUE
fi
# The latest release is currently hard-coded.
STABLE_LATEST="20.10.14"
TEST_LATEST="20.10.14"
STATIC_RELEASE_URL=
STATIC_RELEASE_ROOTLESS_URL=
case "$CHANNEL" in
"stable")
echo "# Installing stable version ${STABLE_LATEST}"
STATIC_RELEASE_URL="https://download.docker.com/linux/static/$CHANNEL/$(uname -m)/docker-${STABLE_LATEST}.tgz"
STATIC_RELEASE_ROOTLESS_URL="https://download.docker.com/linux/static/$CHANNEL/$(uname -m)/docker-rootless-extras-${STABLE_LATEST}.tgz"
;;
"test")
echo "# Installing test version ${TEST_LATEST}"
STATIC_RELEASE_URL="https://download.docker.com/linux/static/$CHANNEL/$(uname -m)/docker-${TEST_LATEST}.tgz"
STATIC_RELEASE_ROOTLESS_URL="https://download.docker.com/linux/static/$CHANNEL/$(uname -m)/docker-rootless-extras-${TEST_LATEST}.tgz"
;;
"nightly")
echo "# Installing nightly"
STATIC_RELEASE_URL="https://master.dockerproject.org/linux/$(uname -m)/docker.tgz"
STATIC_RELEASE_ROOTLESS_URL="https://master.dockerproject.org/linux/$(uname -m)/docker-rootless-extras.tgz"
;;
*)
>&2 echo "Aborting because of unknown CHANNEL \"$CHANNEL\". Set \$CHANNEL to either \"stable\", \"test\", or \"nightly\"."; exit 1
;;
esac
init_vars() {
BIN="${DOCKER_BIN:-$HOME/bin}"
DAEMON=dockerd
SYSTEMD=
if systemctl --user daemon-reload >/dev/null 2>&1; then
SYSTEMD=1
fi
}
checks() {
# OS verification: Linux only, point osx/win to helpful locations
case "$(uname)" in
Linux)
;;
*)
>&2 echo "Rootless Docker cannot be installed on $(uname)"; exit 1
;;
esac
# User verification: deny running as root (unless forced?)
if [ "$(id -u)" = "0" ] && [ -z "$FORCE_ROOTLESS_INSTALL" ]; then
>&2 echo "Refusing to install rootless Docker as the root user"; exit 1
fi
# HOME verification
if [ ! -d "$HOME" ]; then
>&2 echo "Aborting because HOME directory $HOME does not exist"; exit 1
fi
if [ -d "$BIN" ]; then
if [ ! -w "$BIN" ]; then
>&2 echo "Aborting because $BIN is not writable"; exit 1
fi
else
if [ ! -w "$HOME" ]; then
>&2 echo "Aborting because HOME (\"$HOME\") is not writable"; exit 1
fi
fi
# Existing rootful docker verification
if [ -w /var/run/docker.sock ] && [ -z "$FORCE_ROOTLESS_INSTALL" ]; then
>&2 echo "Aborting because rootful Docker is running and accessible. Set FORCE_ROOTLESS_INSTALL=1 to ignore."; exit 1
fi
# Validate XDG_RUNTIME_DIR
if [ ! -w "$XDG_RUNTIME_DIR" ]; then
if [ -n "$SYSTEMD" ]; then
>&2 echo "Aborting because systemd was detected but XDG_RUNTIME_DIR (\"$XDG_RUNTIME_DIR\") does not exist or is not writable"
>&2 echo "Hint: this could happen if you changed users with 'su' or 'sudo'. To work around this:"
>&2 echo "- try again by first running with root privileges 'loginctl enable-linger <user>' where <user> is the unprivileged user and export XDG_RUNTIME_DIR to the value of RuntimePath as shown by 'loginctl show-user <user>'"
>&2 echo "- or simply log back in as the desired unprivileged user (ssh works for remote machines)"
exit 1
fi
fi
# Already installed verification (unless force?). Only having docker cli binary previously shouldn't fail the build.
if [ -x "$BIN/$DAEMON" ]; then
# If rootless installation is detected print out the modified PATH and DOCKER_HOST that needs to be set.
echo "# Existing rootless Docker detected at $BIN/$DAEMON"
echo
echo "# To reinstall or upgrade rootless Docker, run the following commands and then rerun the installation script:"
echo "systemctl --user stop docker"
echo "rm -f $BIN/$DAEMON"
echo
echo "# Alternatively, install the docker-ce-rootless-extras RPM/deb package for ease of package management (requires root)."
echo "# See https://docs.docker.com/go/rootless/ for details."
exit 0
fi
INSTRUCTIONS=
# uidmap dependency check
if ! command -v newuidmap >/dev/null 2>&1; then
if command -v apt-get >/dev/null 2>&1; then
INSTRUCTIONS="apt-get install -y uidmap"
elif command -v dnf >/dev/null 2>&1; then
INSTRUCTIONS="dnf install -y shadow-utils"
elif command -v yum >/dev/null 2>&1; then
INSTRUCTIONS="curl -o /etc/yum.repos.d/vbatts-shadow-utils-newxidmap-epel-7.repo https://copr.fedorainfracloud.org/coprs/vbatts/shadow-utils-newxidmap/repo/epel-7/vbatts-shadow-utils-newxidmap-epel-7.repo
yum install -y shadow-utils46-newxidmap"
else
echo "newuidmap binary not found. Please install with a package manager."
exit 1
fi
fi
# iptables dependency check
if [ -z "$SKIP_IPTABLES" ] && ! command -v iptables >/dev/null 2>&1 && [ ! -f /sbin/iptables ] && [ ! -f /usr/sbin/iptables ]; then
if command -v apt-get >/dev/null 2>&1; then
INSTRUCTIONS="${INSTRUCTIONS}
apt-get install -y iptables"
elif command -v dnf >/dev/null 2>&1; then
INSTRUCTIONS="${INSTRUCTIONS}
dnf install -y iptables"
else
echo "iptables binary not found. Please install with a package manager."
exit 1
fi
fi
# ip_tables module dependency check
if [ -z "$SKIP_IPTABLES" ] && ! lsmod | grep ip_tables >/dev/null 2>&1 && ! grep -q ip_tables "/lib/modules/$(uname -r)/modules.builtin"; then
INSTRUCTIONS="${INSTRUCTIONS}
modprobe ip_tables"
fi
# debian requires setting unprivileged_userns_clone
if [ -f /proc/sys/kernel/unprivileged_userns_clone ]; then
if [ "1" != "$(cat /proc/sys/kernel/unprivileged_userns_clone)" ]; then
INSTRUCTIONS="${INSTRUCTIONS}
cat <<EOT > /etc/sysctl.d/50-rootless.conf
kernel.unprivileged_userns_clone = 1
EOT
sysctl --system"
fi
fi
# centos requires setting max_user_namespaces
if [ -f /proc/sys/user/max_user_namespaces ]; then
if [ "0" = "$(cat /proc/sys/user/max_user_namespaces)" ]; then
INSTRUCTIONS="${INSTRUCTIONS}
cat <<EOT > /etc/sysctl.d/51-rootless.conf
user.max_user_namespaces = 28633
EOT
sysctl --system"
fi
fi
if [ -n "$INSTRUCTIONS" ]; then
echo "# Missing system requirements. Please run following commands to
# install the requirements and run this installer again.
# Alternatively iptables checks can be disabled with SKIP_IPTABLES=1"
echo
echo "cat <<EOF | sudo sh -x"
echo "$INSTRUCTIONS"
echo "EOF"
echo
exit 1
fi
# validate subuid/subgid files for current user
if ! grep "^$(id -un):\|^$(id -u):" /etc/subuid >/dev/null 2>&1; then
>&2 echo "Could not find records for the current user $(id -un) from /etc/subuid . Please make sure valid subuid range is set there.
For example:
echo \"$(id -un):100000:65536\" >> /etc/subuid"
exit 1
fi
if ! grep "^$(id -un):\|^$(id -u):" /etc/subgid >/dev/null 2>&1; then
>&2 echo "Could not find records for the current user $(id -un) from /etc/subgid . Please make sure valid subuid range is set there.
For example:
echo \"$(id -un):100000:65536\" >> /etc/subgid"
exit 1
fi
}
exec_setuptool() {
if [ -n "$FORCE_ROOTLESS_INSTALL" ]; then
set -- "$@" --force
fi
if [ -n "$SKIP_IPTABLES" ]; then
set -- "$@" --skip-iptables
fi
(
set -x
PATH="$BIN:$PATH" "$BIN/dockerd-rootless-setuptool.sh" install "$@"
)
}
do_install() {
echo "# Executing docker rootless install script, commit: $SCRIPT_COMMIT_SHA"
init_vars
checks
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT INT TERM
# Download tarballs docker-* and docker-rootless-extras=*
(
cd "$tmp"
curl -L -o docker.tgz "$STATIC_RELEASE_URL"
curl -L -o rootless.tgz "$STATIC_RELEASE_ROOTLESS_URL"
)
# Extract under $HOME/bin/
(
mkdir -p "$BIN"
cd "$BIN"
tar zxf "$tmp/docker.tgz" --strip-components=1
tar zxf "$tmp/rootless.tgz" --strip-components=1
)
exec_setuptool "$@"
}
do_install "$@"

View File

@ -3,7 +3,9 @@
appname=$1
sound="message"
if [ "$appname" = "Telegram-desktop" ]; then
if [ "$appname" = "Element" ]; then
sound="window-attention"
elif [ "$appname" = "Telegram Desktop" ]; then
sound="window-attention"
fi

View File

@ -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))

View File

@ -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())

View File

@ -1,16 +0,0 @@
#!/usr/bin/python
import os
import re
import lib.helpers as helpers
from subprocess import check_output
hubic_available = helpers.is_exe('/usr/bin/hubic')
if not hubic_available:
print('Not running')
os.exit(1)
return_value = check_output(['hubic', 'status'])
m = re.search(r'State: (.*)', return_value.decode("utf-8"))
print(m.group(1))

View File

@ -0,0 +1,46 @@
#!/usr/bin/env python3
from argparse import ArgumentParser
from subprocess import call
import i3ipc
i3 = i3ipc.Connection()
parser = ArgumentParser(prog='disable-standby-fs',
description='''
Disable standby (dpms) and screensaver when a window becomes fullscreen
or exits fullscreen-mode. Requires `xorg-xset`.
''')
args = parser.parse_args()
def find_fullscreen(con):
# XXX remove me when this method is available on the con in a release
return [c for c in con.descendents() if c.type == 'con' and c.fullscreen_mode]
def set_dpms(state):
if state:
print('setting dpms on')
call(['xset', 's', 'on'])
call(['xset', '+dpms'])
else:
print('setting dpms off')
call(['xset', 's', 'off'])
call(['xset', '-dpms'])
def on_fullscreen_mode(i3, e):
set_dpms(not len(find_fullscreen(i3.get_tree())))
def on_window_close(i3, e):
if not len(find_fullscreen(i3.get_tree())):
set_dpms(True)
i3.on('window::fullscreen_mode', on_fullscreen_mode)
i3.on('window::close', on_window_close)
i3.main()

2
i3/lock.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
i3lock -k -i /usr/share/backgrounds/archlinux/wave.png --time-color FFFFFF --date-color FFFFFF --ignore-empty-password --show-failed-attempts -C

18
i3/screenoff.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Only exported variables can be used within the timer's command.
#export PRIMARY_DISPLAY="$(xrandr | awk '/ primary/{print $1}')"
# Run xidlehook
xidlehook \
`# Don't lock when there's a fullscreen application` \
--not-when-fullscreen \
`# Don't lock when there's audio playing` \
--not-when-audio \
`# Dim the screen after 60 seconds, undim if user becomes active` \
--timer 15 \
'xset dpms force off' \
'xset dpms force on' \
#--timer 300 \
# 'systemctl suspend' \
# ''

24
i3/screensaver.sh Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Only exported variables can be used within the timer's command.
#export PRIMARY_DISPLAY="$(xrandr | awk '/ primary/{print $1}')"
# Run xidlehook
xidlehook \
--not-when-fullscreen \
--not-when-audio \
--timer 180 \
'notify-send -u low "Locking in 15 seconds..."' \
'' \
--timer 15 \
'xset dpms force off' \
'xset dpms force on'
# --timer 300 \
# 'systemctl suspend' \
# ''
# --timer 15 \
# 'loginctl lock-session' \
# '' \
# --timer 15 \
# 'i3lock -k -i /usr/share/backgrounds/archlinux/wave.png --timecolor FFFFFF --datecolor FFFFFF --ignore-empty-password --show-failed-attempts -C' \
# '' \

60
i3/setup_tablet.sh Executable file
View File

@ -0,0 +1,60 @@
#!/bin/sh
#HID_STYLUS="HID 256c:006e Pen stylus"
#HID_PAD="HID 256c:006e Pad pad"
HID_STYLUS="HID 256c:006e"
HID_PAD="HID 256c:006e Pad"
# xsetwacom --set "$HID_PAD" Area 0 0 50800 28575
xsetwacom --set "$HID_STYLUS" MapToOutput DVI-D-0
# Tester
#xsetwacom --set "$HID_PAD" Button 1 "key a"
#xsetwacom --set "$HID_PAD" Button 2 "key b"
#xsetwacom --set "$HID_PAD" Button 3 "key c"
#xsetwacom --set "$HID_PAD" Button 4 "key d"
#xsetwacom --set "$HID_PAD" Button 5 "key e"
#xsetwacom --set "$HID_PAD" Button 6 "key f"
#xsetwacom --set "$HID_PAD" Button 7 "key g"
#xsetwacom --set "$HID_PAD" Button 8 "key h"
#xsetwacom --set "$HID_PAD" Button 9 "key i"
#xsetwacom --set "$HID_PAD" Button 10 "key j"
#xsetwacom --set "$HID_PAD" Button 11 "key k"
#xsetwacom --set "$HID_PAD" Button 12 "key l"
#xsetwacom --set "$HID_PAD" Button 13 "key m"
#xsetwacom --set "$HID_PAD" Button 14 "key n"
#xsetwacom --set "$HID_PAD" Button 15 "key o"
#xsetwacom --set "$HID_PAD" Button 16 "key p"
# Huion 1060 New buttons from top to bottom:
# 1 2
# 3 8
# 9 10
# ----
# 11 12
# 13 14
# 15 16
## 1
xsetwacom --set "$HID_PAD" Button 1 "key +ctrl +z -z -ctrl"
xsetwacom --set "$HID_PAD" Button 2 "key +ctrl +shift +z -z -ctrl -shift"
## 2
xsetwacom --set "$HID_PAD" Button 3 "key L"
xsetwacom --set "$HID_PAD" Button 8 "key K"
## 3
xsetwacom --set "$HID_PAD" Button 9 "key -"
xsetwacom --set "$HID_PAD" Button 10 "key +"
#
#xsetwacom --set "$HID_PAD" Button 13 "key p"
#xsetwacom --set "$HID_PAD" Button 12 "key ["
## 2
#xsetwacom --set "$HID_PAD" Button 11 "key ]"
#xsetwacom --set "$HID_PAD" Button 10 "key +"
## 5
#xsetwacom --set "$HID_PAD" Button 3 "key b"
## 6

47
i3/xscreensaverstopper.sh Executable file
View File

@ -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

17
import-gsettings Executable file
View File

@ -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"

9
imv-dir Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
image="$1"
declare -a ARGS
for a in "$(dirname "$image")"/*; do
if [ -f "$a" ]; then
ARGS+=("$a")
fi
done
exec imv "${ARGS[@]}" -n "$image"

12
killwine Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
killall -9 conhost.exe
killall -9 svchost.exe
killall -9 explorer.exe
killall -9 winedevice.exe
killall -9 plugplay.exe
killall -9 winedevice.exe
killall -9 services.exe
killall -9 wineboot.exe
killall -9 wineserver
killall -9 wine

View File

@ -1,14 +0,0 @@
#!/bin/sh
# First check if lastpass is correctly initialized
if lpass ls 1>/dev/null 2>&1; then
# success
lpass ls | grep --ignore-case $1 | awk '{ if (match($0,/\[id: (.*)?\]/,m)) print m[1] }' | xargs lpass show
# --color=always --format="%ai %au %ap" # unable to use because lpass is buggy with the formatting
else
# failure
echo -n "Enter login name: "
read loginname
lpass login $loginname
fi

19
maintenance/aur-restore.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
#REPOSITORY=/home/lanxu/Arch/localrepo
REPOSITORY=/var/cache/pacman/localrepo
# This script restores local aur repository after fuckup with cleaning which
# happens way too often for me
#echo "Creating custom repository..."
#sudo install -d $REPOSITORY -o lanxu
repo-add $REPOSITORY/localrepo.db.tar.gz
aur sync -u
#echo "Retrieving aur packages which are installed..."
#pacman -Qm | cut -f 1 -d " " > aur-packages.txt
echo "Installing..."
xargs -a aur-packages.txt aur sync -n
#echo "Done."

15
mount-phone Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
MTP_ENDPOINT=$(gio mount -li | rg activation_root | cut -d "=" -f 2)
if [ $# -gt 0 ] && [ $1 == "-u" ]; then
gio mount -u $MTP_ENDPOINT
exit 1
fi
gio mount $MTP_ENDPOINT >/dev/null 2>&1
MTP_PATH=$(gio info $MTP_ENDPOINT | rg local | cut -d ":" -f 2- | sed 's/ *//')
echo $MTP_PATH

20
powermenu.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
op=$( echo -e " Poweroff\n Reboot\n Suspend\n Lock\n Logout" | wofi -i --dmenu | awk '{print tolower($2)}' )
case $op in
poweroff)
;&
reboot)
;&
suspend)
systemctl $op
;;
lock)
#loginctl lock-session
swaylock -f -c 000000
;;
logout)
swaymsg exit
;;
esac

View File

@ -1,6 +0,0 @@
#!/bin/sh
URI=$1
REALPATH=$(echo "$URI" | sed 's/file\:\/\///g')
export TERMCMD=kitty
notify-send "Opening '$REALPATH'"
kitty -1 ranger '$REALPATH'

View File

@ -1,22 +0,0 @@
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No arguments supplied"
exit -1
fi
WINEDIR=$HOME/Pelit/Wine/$1/
export WINEDEBUG=-all
#export WINEARCH=win32
export WINEPREFIX=$WINEDIR
echo "Run in $WINEDIR"
#if [ $# -eq 1 ]
#then
# wine $2
#fi
shift 1;
exec $@

5
run-xhost Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
echo "$@"
xhost +si:lanxu:root
pkexec "$@"
xhost -si:lanxu:root

View File

@ -1,5 +0,0 @@
#!/bin/sh
if [ -z $1 ]; then echo "Search requires search string"; exit 1; fi
grep -Irn "$1" .

View File

@ -1,56 +0,0 @@
#!/bin/sh
# xsetwacom --set "HID 256c:006e Pen stylus" Area 0 0 50800 28575
xsetwacom --set "HID 256c:006e Pen stylus" MapToOutput DVI-D-0
# Tester
#xsetwacom --set 'HID 256c:006e Pad pad' Button 1 "key a"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 2 "key b"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 3 "key c"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 4 "key d"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 5 "key e"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 6 "key f"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 7 "key g"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 8 "key h"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 9 "key i"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 10 "key j"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 11 "key k"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 12 "key l"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 13 "key m"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 14 "key n"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 15 "key o"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 16 "key p"
# Huion 1060 New buttons from top to bottom:
# 1 2
# 3 8
# 9 10
# ----
# 11 12
# 13 14
# 15 16
## 1
xsetwacom --set 'HID 256c:006e Pad pad' Button 1 "key +ctrl +z -z -ctrl"
xsetwacom --set 'HID 256c:006e Pad pad' Button 2 "key +ctrl +shift +z -z -ctrl -shift"
## 2
xsetwacom --set 'HID 256c:006e Pad pad' Button 3 "key L"
xsetwacom --set 'HID 256c:006e Pad pad' Button 8 "key K"
## 3
xsetwacom --set 'HID 256c:006e Pad pad' Button 9 "key -"
xsetwacom --set 'HID 256c:006e Pad pad' Button 10 "key +"
#
#xsetwacom --set 'HID 256c:006e Pad pad' Button 13 "key p"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 12 "key ["
## 2
#xsetwacom --set 'HID 256c:006e Pad pad' Button 11 "key ]"
#xsetwacom --set 'HID 256c:006e Pad pad' Button 10 "key +"
## 5
#xsetwacom --set 'HID 256c:006e Pad pad' Button 3 "key b"
## 6

View File

@ -1,17 +1,31 @@
#!/bin/sh
export XKB_DEFAULT_LAYOUT=fi
#export XKB_DEFAULT_VARIANT=fi
export XKB_DEFAULT_VARIANT=fi
export XKB_DEFAULT_MODEL=pc105
#export XDG_RUNTIME_DIR=/tmp/wayland
#export WAYLAND_DISPLAY=wayland-0
# force all generic backend to use wayland backend
# configure wayland backend
export GDK_BACKEND=wayland
export QT_QPA_PLATFORM=wayland-egl
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
sway
# 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
# start!
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

5
steam Executable file
View File

@ -0,0 +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-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

View File

@ -0,0 +1,6 @@
[Unit]
Description=fullscreen inhibiter for sway
[Service]
Type=oneshot
ExecStart=/bin/sh /home/lanxu/Scripts/sway/fullscreen-inhibiter.sh

11
sway/fullscreen-inhibitor.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# Get all open windows from sway
IN_FULLSCREEN_NODES=$(swaymsg -t get_tree | jq '[paths(objects | select(.nodes)) as $p | getpath($p) | select((.window_properties.class) or (.app_id)) | {name: .name, app_id: .app_id, class: .window_properties.class, fullscreen_mode: .fullscreen_mode, focused: .focused}]' | jq 'any(.fullscreen_mode == 1)')
IN_FULLSCREEN_FLOATING_NODES=$(swaymsg -t get_tree | jq '[paths(objects | select(.floating_nodes)) as $p | getpath($p) | select((.window_properties.class) or (.app_id)) | {name: .name, app_id: .app_id, class: .window_properties.class, fullscreen_mode: .fullscreen_mode, focused: .focused}]' | jq 'any(.fullscreen_mode == 1)')
if [ $IN_FULLSCREEN_NODES = "true" ] || [ $IN_FULLSCREEN_FLOATING_NODES = "true" ]; then
dunstctl set-paused true
else
dunstctl set-paused false
fi

View File

@ -0,0 +1,9 @@
[Unit]
Description=Fullscreen inhibiter for Sway timer
[Timer]
OnUnitActiveSec=10s
OnBootSec=10s
[Install]
WantedBy=timers.target

13
sway/setup-tablet.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# Get inputs
# swaymsg -t get_inputs
# Get ouputs
# swaymsg -t get_outputs
#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'"
swaymsg 'input '$PAD_ID' map_to_output '$OUTPUT

21
sway/take_screencast.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
MODE=$1
FILENAME=$(xdg-user-dir VIDEOS)/$(date +%F_%T_wf-recorder.mp4)
TEMP_FILENAME=$(mktemp).mp4
#PARAMS='-c libvpx-vp9'
PARAMS='--audio -o DP-2'
WF_RECORDERS=$(ps -Al | rg 'wf-recorder' | wc -l)
if [ $WF_RECORDERS -gt 0 ]; then
killall -2 wf-recorder
exit 0
fi
case $MODE in
"stop") killall -2 wf-recorder;;
"region-copy") wf-recorder -g "$(slurp)" $PARAMS -f $TEMP_FILENAME && wl-copy --type text/uri-list file://$TEMP_FILENAME;;
"region") wf-recorder -g "$(slurp)" $PARAMS -f $FILENAME && notify-send -i "$FILENAME" "Screencast saved";;
*) wf-recorder $PARAMS -f $FILENAME && notify-send -i "$FILENAME" "Screencast saved";;
esac

10
sway/take_screenshot.sh Executable file
View File

@ -0,0 +1,10 @@
#!/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

3
sway_lock.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
#i3lock -k -i /usr/share/backgrounds/archlinux/wave.png --time-color FFFFFF --date-color FFFFFF --ignore-empty-password --show-failed-attempts -C
swaylock -f -c 000000

6
sway_screensaver.sh Executable file
View File

@ -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'

9
testing/run_zandronum.sh Normal file
View File

@ -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

3
testing/sheet_process.sh Normal file
View File

@ -0,0 +1,3 @@
mogrify -format png *.tga
rm *.tga
mogrify -crop 256x400+0+0 +repage *.png

100
tools/24-bit-color.sh Normal file
View File

@ -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;<r>;<g>;<b>m
# The background escape sequence is ^[48;2;<r>;<g>;<b>m
# <r> <g> <b> 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

View File

@ -14,6 +14,9 @@ def main(argv):
inputFile = ''
outputFile = ''
loglevel = 'error'
#bitrate = '2000k'
bitrate = '0'
crf = '15'
try:
opts, args = getopt.getopt(argv,"hi:o:v",["ifile=","ofile="])
@ -43,8 +46,8 @@ def main(argv):
os.environ['AV_LOG_FORCE_NOCOLOR'] = '1'
# Define commands
command_pass1 = ['ffmpeg', '-i', inputFile, '-loglevel',loglevel,'-c:v', 'libvpx-vp9', '-pass', '1', '-b:v', '1000K', '-threads', '8', '-speed', '4', '-tile-columns', '6', '-frame-parallel', '1', '-auto-alt-ref', '1', '-lag-in-frames', '25', '-an', '-f', 'webm', '-y', '/dev/null']
command_pass2 = ['ffmpeg', '-i', inputFile, '-loglevel',loglevel,'-c:v', 'libvpx-vp9', '-pass', '2', '-b:v', '1000K', '-threads', '8', '-speed', '1', '-tile-columns', '6', '-frame-parallel', '1', '-auto-alt-ref', '1', '-lag-in-frames', '25', '-c:a', 'libopus', '-b:a', '64k', '-f', 'webm', outputFile]
command_pass1 = ['ffmpeg', '-i', inputFile, '-loglevel',loglevel,'-c:v', 'libvpx-vp9', '-pass', '1', '-b:v', bitrate, '-crf', crf, '-threads','16', '-slices','16','-cpu-used','-4', '-f', 'null', '-y', '/dev/null']
command_pass2 = ['ffmpeg', '-i', inputFile, '-loglevel',loglevel,'-c:v', 'libvpx-vp9', '-pass', '2', '-b:v', bitrate, '-crf', crf, '-threads','16', '-slices','16','-cpu-used','-4', outputFile]
# Run commands
print('Input file is "'+inputFile+'"')
@ -78,6 +81,3 @@ def main(argv):
if __name__ == "__main__":
main(sys.argv[1:])

119
tools/gif_anim_montage.sh Executable file
View File

@ -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

81
tools/updateorigin.sh Normal file
View File

@ -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

105
tools/vimeo-audio-and-video.py Executable file
View File

@ -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'])

View File

@ -0,0 +1,4 @@
#!/bin/sh
# First, set flatpak overrides
flatpak override --user --socket=wayland io.freetubeapp.FreeTube