Compare commits

...

4 Commits

7 changed files with 123 additions and 2 deletions

View File

@@ -1,4 +1,14 @@
#!/bin/sh
cd ~/Downloads
YTDL_WD=$(zenity --file-selection --directory --filename=.)
xfce4-terminal --default-working-directory $YTDL_WD --execute youtube-dl $@
YTDL_WD="."
if [ $(command -v zenity) ]; then
YTDL_WD=$(zenity --file-selection --directory --filename=.)
fi
if [ $(command -v xfce4-terminal) ]; then
xfce4-terminal --default-working-directory "$YTDL_WD" --execute youtube-dl $@
else
cd "$YTDL_WD"
youtube-dl $@
fi

14
genv Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env python3
import sys
import os
from subprocess import call
ENV_NAME=sys.argv[1]
ENV_COMMAND=sys.argv[2:]
ENVS_DIR=os.path.join(os.path.expanduser("~"), ".config", "guix", "envs")
env_packages = []
with open(os.path.join(ENVS_DIR, ENV_NAME)) as env_def:
env_packages = env_def.read().strip().split(" ")
call(["guix", "environment", "--ad-hoc"] + env_packages + ["--"] + ENV_COMMAND)

64
jackson Executable file
View File

@@ -0,0 +1,64 @@
#!/usr/bin/env python3
from subprocess import call, check_output
import argparse
import os
import sys
ADD_PACKAGE_PREFIX = " + "
def log (message, *args):
print(message.format(*args), file=sys.stderr)
def get_all_package_generations ():
package_generations = {}
for line in check_output(["guix", "package", "--list-generations"]).decode().split("\n"):
if not line.startswith(ADD_PACKAGE_PREFIX):
continue
(package, version, output, path) = line[len(ADD_PACKAGE_PREFIX):].split("\t")
if not package in package_generations:
package_generations[package] = []
package_generations[package].append({
"path": path,
"version": version,
"output": output,
"package": package
})
return package_generations
def run_with_packages (packages, command):
env = {}
env.update(os.environ)
env.update({
"PATH": ":".join(["{}/bin".format(package['path']) for package in packages] + [env.get("PATH", "")]),
"LD_LIBRARY_PATH": ":".join(["{}/lib".format(package['path']) for package in packages] + [env.get("PATH", "")])
})
call(args.run, env=env)
parser = argparse.ArgumentParser()
parser.add_argument("--package", help="package name", required=True)
parser.add_argument("--version", help="package version")
parser.add_argument("--index", help="", type=int, default=0)
parser.add_argument("--run", nargs="*", help="run command")
args = parser.parse_args()
all_package_generations = get_all_package_generations()
package_generations_for_package = all_package_generations[args.package]
package_generations_for_package.reverse()
log("Found {} generations for package {}", len(package_generations_for_package), args.package)
if args.version:
package_generations_for_package = [generation for generation in package_generations_for_package if generation['version'] == args.version]
log("Found {} generations for version {}", len(package_generations_for_package), args.version)
selected_package = package_generations_for_package[args.index]
log("Selected package: {}", selected_package)
if args.run:
run_with_packages([selected_package], args.run)
else:
print(selected_package)

8
sms/clear_sms Normal file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env python3
from sms import get_sms
from subprocess import call
from os.path import basename
for sms in get_sms():
print(sms)
call(["mmcli", "-m", "any", "--messaging-delete-sms", sms[0]])

10
sms/dump_sms Normal file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env python3
from sms import get_sms
from subprocess import call
from os.path import basename
for sms in get_sms():
print(sms)
out_file = "{}.{}.sms".format(basename(sms[0]), sms[1])
print(">> dump to {}".format(out_file))
call(["mmcli", "-m", "any", "--create-file-with-data", out_file, "--sms", sms[0]])

4
sms/list_sms Normal file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env python3
from sms import get_sms
for sms in get_sms():
print(sms)

11
sms/sms.py Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env python3
from subprocess import call, check_output
from os.path import basename
def parse_list_item(item):
item = item.strip().split(" ", 2)
item[1] = item[1][1:-1]
return tuple(item)
def get_sms():
return [parse_list_item(sms) for sms in check_output(["mmcli", "-m", "any", "--messaging-list-sms"]).decode().strip().split("\n")]