Added new scripts for various use-cases

This commit is contained in:
lanxu 2021-08-28 20:09:31 +03:00 committed by lanxu
parent 1ce822854d
commit dccfecec74
17 changed files with 217 additions and 17 deletions

View File

@ -4,3 +4,4 @@
__pycache__ __pycache__
temp temp
.scr .scr
fetchers

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

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

46
i3-disable-standby-fs.py Normal file
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()

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"

15
keepass.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
# Store password like this:
# ´´secret-tool store --label='KeepassPassword' password keepass``
DATABASE=~/Nextcloud/Avaimet/Passwords.kdbx
PW=$(secret-tool lookup password keepass)
PASSWORDS=$(echo $PW | keepassxc-cli ls -R $DATABASE)
for pass in $PASSWORDS; do
found=$(echo $pass | grep --ignore-case $1)
if [ -n "$found" ]; then
echo $PW | keepassxc-cli show -s -q $DATABASE $found &
fi
done

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

2
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

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

8
md_create_eplist.py Executable file
View File

@ -0,0 +1,8 @@
#!/bin/python
import sys
if __name__ == "__main__":
ret = '- [ ] ' + sys.argv[1] + "\n"
for ep in range(1, int(sys.argv[2])+1):
ret += " - [ ] Ep. "+str(ep)+"\n"
print(ret)

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 221122
;;
logout)
swaymsg exit
;;
esac

18
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
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' \
# '' \

12
setup_table_sway.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# Get inputs
# swaymsg -t get_inputs
# Get ouputs
# swaymsg -t get_outputs
PAD_ID="9580:110:HID_256c:006e_Pad"
OUTPUT="DP-2"
echo "swaymsg 'input $PAD_ID map_to_output $OUTPUT'"
swaymsg 'input '$PAD_ID' map_to_output '$OUTPUT

4
steam Executable file
View File

@ -0,0 +1,4 @@
#!/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.*=*" &
DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/steam-bus-proxy" /usr/bin/steam
kill %1

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