-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
1,432 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#! /bin/bash | ||
|
||
echo "- [ ] $@" >> "/home/a8ka/Dev/@A/notes/todo - inbox.md" | ||
content=$(zenity --entry --text "Create a ToDo") | ||
[ ! -z "$content" ] && echo "- [ ] $content" >> "/home/$(whoami)/Dev/@A/notes/todo.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
# btrfs-undelete | ||
# Copyright (C) 2013 Jörg Walter <[email protected]> | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the term of the GNU General Public License as published by the Free Software | ||
# Foundation; either version 2 of the License, or any later version. | ||
|
||
if [ ! -b "$1" -o -z "$2" -o -z "$3" ]; then | ||
echo "Usage: $0 <dev> <file/dir> <dest>" 1>&2 | ||
echo | ||
echo "This program tries to recover the most recent version of the" | ||
echo "given file or directory (recursively)" | ||
echo | ||
echo "<dev> must not be mounted, otherwise this program may appear" | ||
echo "to work but find nothing." | ||
echo | ||
echo "<file/dir> must be specified relative to the filesystem root," | ||
echo "obviously. It may contain * and ? as wildcards, but in that" | ||
echo "case, empty files might be 'recovered'. If <file/dir> is a" | ||
echo "single file name, this program tries to recover the most" | ||
echo "recent non-empty version of the file." | ||
echo | ||
echo "<dest> must be a writable directory with enough free space" | ||
echo "to hold the files you're trying to restore." | ||
exit 1 | ||
fi | ||
dev="$1" | ||
file="$2" | ||
|
||
file="${file#/}" | ||
file="${file%/}" | ||
regex="${file//\\/\\\\}" | ||
|
||
# quote regex special characters | ||
regex="${regex//./\.}" | ||
regex="${regex//+/\+}" | ||
regex="${regex//|/\|}" | ||
regex="${regex//(/\(}" | ||
regex="${regex//)/\)}" | ||
regex="${regex//\[/\[}" | ||
regex="${regex//]/\]}" | ||
regex="${regex//\{/\{}" | ||
regex="${regex//\}/\}}" | ||
|
||
# treat shell wildcards specially | ||
regex="${regex//\*/.*}" | ||
regex="${regex//\?/.}" | ||
|
||
# extract number of slashes in order to get correct number of closing parens | ||
slashes="${regex//[^\/]/}" | ||
|
||
# build final regex | ||
regex="^/(|${regex//\//(|/}(|/.*${slashes//?/)}))\$" | ||
|
||
roots="$(mktemp --tmpdir btrfs-undelete.roots.XXXXX)" | ||
out="$(mktemp --tmpdir="$3" -d btrfs-undelete.XXXXX)" | ||
cd $out | ||
|
||
trap "rm $roots" EXIT | ||
trap "rm -r $out &> /dev/null; exit 1" SIGINT | ||
|
||
echo -ne "Searching roots..." | ||
btrfs-find-root -a "$dev" 2>&1 \ | ||
| grep ^Well \ | ||
| sed -r -e 's/Well block ([0-9]+).*/\1/' \ | ||
| sort -rn >$roots || exit 1 | ||
echo | ||
|
||
i=0 | ||
max="$(wc -l <$roots)" | ||
|
||
while read id; do | ||
((i+=1)) | ||
echo -e "Trying root $id... ($i/$max)" | ||
btrfs restore -t $id --path-regex "$regex" "$dev" . &>/dev/null | ||
if [ "$?" = 0 ]; then | ||
found=$(find . -type f ! -size 0c | wc -l) | ||
if [ $found -gt 0 ]; then | ||
echo "Recovered $found non-empty file(s) into $out" | ||
exit 0 | ||
fi | ||
find . -type f -size 0c -exec echo "Found {} but it's empty" \; -delete | ||
fi | ||
done <$roots | ||
rm -r $out | ||
echo "Didn't find '$file'" | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
SOURCE=~/Music/Collection/ | ||
DEST=~/Music/MP3/ | ||
|
||
|
||
SAVEIFS=${IFS} | ||
IFS=' | ||
' | ||
FILE_LIST=`find "$SOURCE" -type f -iname '*.wav' -o -iname '*.mp3' -o -iname '*.flac'` | ||
|
||
for FILE in ${FILE_LIST}; do | ||
echo $FILE | ||
PREFIX=`echo $FILE | awk -F \. 'OFS="."{ $NF="" }1' | sed 's/.$//'` | ||
echo $PREFIX | ||
done; | ||
# -exec echo {} | ||
# # ffmpeg -i {} -acodec libmp3lame \ | ||
# # $DEST$(readlink -f {} | cut -d"/" -f 5-)/{} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#! /bin/python3 | ||
|
||
import os | ||
import argparse, sys | ||
import taglib | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--collection", help="Path to music collection") | ||
parser.add_argument("--title", help="Playlist title") | ||
|
||
parser.add_argument("--genre_contains", action='append', help="Text to match against the GENRE") | ||
parser.add_argument("--genre_not_contains", action='append', help="Text to match against the GENRE") | ||
|
||
parser.add_argument("--comment_contains", action='append', help="Text to match against the COMMENT") | ||
parser.add_argument("--comment_not_contains", action='append', help="Text to match against the COMMENT") | ||
|
||
parser.add_argument("--output", help="Path to the resulting playlist") | ||
args=parser.parse_args() | ||
|
||
|
||
EXTENSIONS = ['.flac', '.mp3'] | ||
COLLECTION_PATH = os.path.expanduser(args.collection) | ||
PLAYLIST_PATH = os.path.expanduser(args.output) | ||
|
||
GENRE_CONTAINS = args.genre_contains or [] | ||
GENRE_NOT_CONTAINS = args.genre_not_contains or [] | ||
|
||
COMMENT_CONTAINS = args.comment_contains or [] | ||
COMMENT_NOT_CONTAINS = args.comment_not_contains or [] | ||
PLAYLIST_TITLE = args.title or "" | ||
|
||
|
||
def get_files(dir): | ||
for root, _, files in os.walk(dir): | ||
for file in files: | ||
for ext in EXTENSIONS: | ||
if file.endswith(ext): | ||
yield os.path.join(root, file) | ||
|
||
|
||
def get_tags(file): | ||
with taglib.File(file) as song: | ||
return song.tags | ||
|
||
|
||
def get_dir_from_filepath(s): | ||
f = os.path.basename(s) | ||
p = s[:-(len(f))-1] | ||
return p | ||
|
||
|
||
def match_genre(tags): | ||
matched_contains = [] | ||
matched_not_contains = [] | ||
|
||
if "GENRE" in tags: | ||
genre = ", ".join(tags["GENRE"]).lower() | ||
|
||
if len(GENRE_CONTAINS): | ||
for s in GENRE_CONTAINS: | ||
matched_contains.append(s.lower() in genre) | ||
|
||
if len(GENRE_NOT_CONTAINS): | ||
for s in GENRE_NOT_CONTAINS: | ||
matched_not_contains.append(s.lower() not in genre) | ||
|
||
return all([ | ||
False if len(GENRE_CONTAINS) and not any(matched_contains) else True, | ||
False if len(GENRE_NOT_CONTAINS) and not any(matched_not_contains) else True | ||
]) | ||
|
||
return False | ||
|
||
|
||
def match_comment(tags): | ||
matched_contains = [] | ||
matched_not_contains = [] | ||
|
||
if "COMMENT" in tags: | ||
comment = ", ".join(tags["COMMENT"]).lower() | ||
|
||
if len(COMMENT_CONTAINS): | ||
for s in COMMENT_CONTAINS: | ||
matched_contains.append(s.lower() in comment) | ||
|
||
if len(COMMENT_NOT_CONTAINS): | ||
for s in COMMENT_NOT_CONTAINS: | ||
matched_not_contains.append(s.lower() not in comment) | ||
|
||
result = all([ | ||
False if len(COMMENT_CONTAINS) and not any(matched_contains) else True, | ||
False if len(COMMENT_NOT_CONTAINS) and not any(matched_not_contains) else True | ||
]) | ||
|
||
return result | ||
|
||
return False | ||
|
||
|
||
def main(): | ||
playlist_root = get_dir_from_filepath(PLAYLIST_PATH) | ||
print(playlist_root) | ||
print(f"Creating a playlist: '{PLAYLIST_TITLE}'") | ||
with open(PLAYLIST_PATH, encoding="utf-8", mode='w+') as f: | ||
|
||
f.write(f"#EXTM3U\n\n") | ||
|
||
f.write(f"#PLAYLIST:{PLAYLIST_TITLE}\n") | ||
|
||
for file in get_files(COLLECTION_PATH): | ||
tags = get_tags(file) | ||
matched = [] | ||
|
||
if GENRE_CONTAINS or GENRE_NOT_CONTAINS: | ||
matched.append(match_genre(tags)) | ||
|
||
if COMMENT_CONTAINS or COMMENT_NOT_CONTAINS: | ||
matched.append(match_comment(tags)) | ||
|
||
if all(matched): | ||
file = os.path.relpath(file, playlist_root) | ||
f.write(f"{file}\n") | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#! /bin/bash | ||
|
||
find -path "./Downloads/*.mp3" -exec mv {} ./Inbox/ \; | ||
find -path "./Downloads/*.flac" -exec mv {} ./Inbox/ \; | ||
find -path "./Downloads/*.wav" -exec mv {} ./Inbox/ \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
STATS=$(nvidia-smi -q) | ||
|
||
G_UTILIZATION=$(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits) | ||
G_TEMP=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits) | ||
|
||
echo "$G_POWER" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
bold=$(tput bold) | ||
normal=$(tput sgr0) | ||
|
||
print_help() { | ||
echo "${bold}Pacman helper${normal}" | ||
echo "Set of pacman helper scripts to manage an arch linux system." | ||
echo "" | ||
echo " pacman-helper ${bold}new-deps${normal} <package>" | ||
echo " Prints new dependencies to be installed along with a given package" | ||
echo "" | ||
echo " pacman-helper ${bold}update-dates${normal} <package>" | ||
echo " Prints dates when a given package has been installed or updated" | ||
echo "" | ||
} | ||
|
||
if [ "$1" = "new-deps" ]; then | ||
comm -12 <(pactree -srl $2 | sort) <(pacman -Qq | sort) | ||
exit 0 | ||
fi | ||
|
||
if [ "$1" = "update-dates" ]; then | ||
grep "\(upgraded\|installed\) $2 " /var/log/pacman.log | ||
exit 0 | ||
fi | ||
|
||
print_help; | ||
exit 1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
export IFS=' | ||
' | ||
|
||
PICKED_CONTAINER=/Picked/$(date '+%Y-%m')/ | ||
MUSIC_DIR=~/Music/ | ||
PICKED_DIR=$(zenity --width=600 --height=450 --list --column Directory $(ls ${MUSIC_DIR})) | ||
|
||
DEST=${MUSIC_DIR}${PICKED_DIR}${PICKED_CONTAINER} | ||
|
||
mkdir -p "${DEST}" | ||
mv "$1" "${DEST}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/python | ||
|
||
import re | ||
import dbus | ||
import os | ||
|
||
def dbus_to_python(data): | ||
''' | ||
convert dbus data types to python native data types | ||
''' | ||
if isinstance(data, dbus.String): | ||
data = str(data) | ||
elif isinstance(data, dbus.Boolean): | ||
data = bool(data) | ||
elif isinstance(data, dbus.Int64): | ||
data = int(data) | ||
elif isinstance(data, dbus.Double): | ||
data = float(data) | ||
elif isinstance(data, dbus.Array): | ||
data = [dbus_to_python(value) for value in data] | ||
elif isinstance(data, dbus.Dictionary): | ||
new_data = dict() | ||
for key in data.keys(): | ||
new_data[dbus_to_python(key)] = dbus_to_python(data[key]) | ||
data = new_data | ||
return data | ||
|
||
|
||
bus = dbus.SessionBus() | ||
|
||
for service in bus.list_names(): | ||
if service.startswith('org.mpris.MediaPlayer2.'): | ||
player = dbus.SessionBus().get_object(service, '/org/mpris/MediaPlayer2') | ||
|
||
status=player.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus', dbus_interface='org.freedesktop.DBus.Properties') | ||
|
||
metadata = player.Get('org.mpris.MediaPlayer2.Player', 'Metadata', dbus_interface='org.freedesktop.DBus.Properties') | ||
metadata = dbus_to_python(metadata) | ||
|
||
trackid = str(metadata["mpris:trackid"]) | ||
|
||
if "DeaDBeeF" in trackid: | ||
file_url = metadata["xesam:url"] | ||
file = re.sub(r"file:\/\/", "", file_url) | ||
if os.path.isfile(file): | ||
print(file) | ||
os.system(f"~/.bin/pick-track '{file}'") |
Oops, something went wrong.