Removed commit history
Signed-off-by: Marko Korhonen <marko.korhonen@reekynet.com>
This commit is contained in:
commit
b1335a3628
199 changed files with 36930 additions and 0 deletions
4
home/Scripts/check-mail.sh
Executable file
4
home/Scripts/check-mail.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
mbsync -a
|
||||
notmuch new
|
||||
notifymuch
|
26
home/Scripts/confgen/termite.conf.gen.sh
Executable file
26
home/Scripts/confgen/termite.conf.gen.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
source ~/.cache/wal/colors.sh
|
||||
echo "[colors]
|
||||
foreground = $foreground
|
||||
background = $background
|
||||
color0 = $color0
|
||||
color1 = $color1
|
||||
color2 = $color2
|
||||
color3 = $color3
|
||||
color4 = $color4
|
||||
color5 = $color5
|
||||
color6 = $color6
|
||||
color7 = $color7
|
||||
color8 = $color8
|
||||
color9 = $color9
|
||||
color10 = $color10
|
||||
color11 = $color11
|
||||
color12 = $color12
|
||||
color13 = $color13
|
||||
color14 = $color14
|
||||
color15 = $color15
|
||||
|
||||
[options]
|
||||
font = Noto Color Emoji 12
|
||||
font = Material Design Icons 12
|
||||
font = Hack Nerd Font 12" > ~/.config/termite/config
|
40
home/Scripts/confgen/zathura.conf.gen.sh
Executable file
40
home/Scripts/confgen/zathura.conf.gen.sh
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Generates zathura configuration file with pywal colors
|
||||
|
||||
. $HOME/.cache/wal/colors.sh
|
||||
|
||||
cat <<CONF > ~/.config/zathura/zathurarc
|
||||
set completion-bg "$background"
|
||||
set recolor-darkcolor "$foreground"
|
||||
set recolor-lightcolor "$background"
|
||||
set completion-fg "$foreground"
|
||||
set completion-group-bg "$background"
|
||||
set completion-group-fg "$color2"
|
||||
set completion-highlight-bg "$foreground"
|
||||
set completion-highlight-fg "$background"
|
||||
set default-bg "$background"
|
||||
set default-fg "$foreground"
|
||||
set inputbar-bg "$background"
|
||||
set inputbar-fg "$foreground"
|
||||
set notification-bg "$background"
|
||||
set notification-fg "$foreground"
|
||||
set notification-error-bg "$color1"
|
||||
set notification-error-fg "$foreground"
|
||||
set notification-warning-bg "$color1"
|
||||
set notification-warning-fg "$foreground"
|
||||
set statusbar-bg "$background"
|
||||
set statusbar-fg "$foreground"
|
||||
set index-bg "$background"
|
||||
set index-fg "$foreground"
|
||||
set index-active-bg "$foreground"
|
||||
set index-active-fg "$background"
|
||||
set render-loading-bg "$background"
|
||||
set render-loading-fg "$foreground"
|
||||
|
||||
set smooth-scroll true
|
||||
set window-title-home-tilde true
|
||||
set statusbar-basename true
|
||||
set selection-clipboard clipboard
|
||||
set recolor false
|
||||
CONF
|
49
home/Scripts/dim-screen.sh
Executable file
49
home/Scripts/dim-screen.sh
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
save="/tmp/bkl"
|
||||
|
||||
idle_backlight=0
|
||||
fade_step_time=0.02
|
||||
|
||||
get_brightness() {
|
||||
float=$(light -G $1)
|
||||
printf '%.*f\n' 0 $float
|
||||
}
|
||||
|
||||
save(){
|
||||
get_brightness > "$save"
|
||||
}
|
||||
|
||||
resume(){
|
||||
val=$(cat "$save")
|
||||
set_backlight "$val"
|
||||
}
|
||||
|
||||
set_backlight(){
|
||||
local level
|
||||
for level in $(eval echo {$(get_brightness)..$1}); do
|
||||
light -S $level
|
||||
sleep $fade_step_time
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
while getopts "drs0" opt; do
|
||||
case $opt in
|
||||
d)
|
||||
set_backlight "$idle_backlight"
|
||||
;;
|
||||
r)
|
||||
resume
|
||||
;;
|
||||
s)
|
||||
save
|
||||
;;
|
||||
0)
|
||||
set_backlight 0
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
3
home/Scripts/fonts.sh
Executable file
3
home/Scripts/fonts.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
sudo ln -s /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d
|
||||
sudo ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d
|
||||
sudo ln -s /etc/fonts/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d
|
1
home/Scripts/fzf-pass.sh
Executable file
1
home/Scripts/fzf-pass.sh
Executable file
|
@ -0,0 +1 @@
|
|||
Moved to https://git.reekynet.com/ReekyMarko/fzf-pass
|
64
home/Scripts/fzf-shot.sh
Executable file
64
home/Scripts/fzf-shot.sh
Executable file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/bash
|
||||
|
||||
TYPE=$(cat <<EOF | fzf
|
||||
Region
|
||||
One monitor
|
||||
All monitors
|
||||
EOF
|
||||
);
|
||||
|
||||
LOC=$(cat <<EOF | fzf
|
||||
Copy to clipboard
|
||||
Save as
|
||||
Save with a generated name
|
||||
EOF
|
||||
);
|
||||
|
||||
swaymsg move container to workspace 9
|
||||
|
||||
case "$TYPE" in
|
||||
Region)
|
||||
case "$LOC" in
|
||||
|
||||
Copy to clipboard)
|
||||
grim -g "$(slurp)" | wl-copy
|
||||
;;
|
||||
Save as)
|
||||
grim -g "$(slurp)"
|
||||
;;
|
||||
Save with a generated name)
|
||||
grim -g "$(slurp)" $(xdg-user-dir PICTURES)/Screenshots/$(date +'%Y-%m-%d-%H%M%S.png')
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
esac
|
||||
;;
|
||||
One monitor)
|
||||
case "$LOC" in
|
||||
|
||||
Copy to clipboard)
|
||||
;;
|
||||
Save as)
|
||||
;;
|
||||
Save with a generated name)
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
esac
|
||||
;;
|
||||
All monitors)
|
||||
case "$LOC" in
|
||||
|
||||
Copy to clipboard)
|
||||
;;
|
||||
Save as)
|
||||
;;
|
||||
Save with a generated name)
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
esac
|
9
home/Scripts/hibernate-lowbattery.sh
Executable file
9
home/Scripts/hibernate-lowbattery.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
acpi -b | awk -F'[,:%]' '{print $2, $3}' | {
|
||||
read -r status capacity
|
||||
|
||||
if [ "$status" = Discharging -a "$capacity" -lt 5 ]; then
|
||||
logger "Critical battery threshold"
|
||||
systemctl hibernate
|
||||
fi
|
||||
}
|
29
home/Scripts/imageviewer
Executable file
29
home/Scripts/imageviewer
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ @# -eq 1 ]; then
|
||||
DIR=/tmp/images
|
||||
IMGNAME=$(basename $1)
|
||||
|
||||
if [ ! -d $DIR ]; then
|
||||
mkdir $DIR
|
||||
fi
|
||||
|
||||
if [ ! -f $DIR/$IMGNAME ]; then
|
||||
wget $1 -O $DIR/$IMGNAME
|
||||
fi
|
||||
|
||||
mimeo $DIR/$IMGNAME
|
||||
|
||||
else
|
||||
DIR=/tmp/images/$(basename $1)
|
||||
|
||||
if [ ! -d $]; then
|
||||
mkdir -p $DIR
|
||||
fi
|
||||
|
||||
if [ ! -f $DIR/$IMGNAME ]; then
|
||||
wget -P $DIR $@
|
||||
fi
|
||||
|
||||
mimeo $DIR/*
|
||||
fi
|
11
home/Scripts/imgurviewer
Executable file
11
home/Scripts/imgurviewer
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
ALBUMNAME=$(basename $1)
|
||||
ALBUMDIR=/tmp/imgur/$ALBUMNAME
|
||||
|
||||
if [ ! -d $ALBUMDIR ]; then
|
||||
mkdir -p $ALBUMDIR
|
||||
imgur-album-downloader $1 $ALBUMDIR
|
||||
fi
|
||||
|
||||
mimeo $ALBUMDIR
|
9
home/Scripts/lidclose.sh
Executable file
9
home/Scripts/lidclose.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
displays=$(xrandr | grep " connected" | wc -l)
|
||||
if [ $displays -eq 1 ]; then
|
||||
i3lock-fancy; echo "systemctl suspend" > /home/reekymarko/Scripts/suspendcommand
|
||||
else
|
||||
echo "won't suspend, external display connected"
|
||||
echo " " > /home/reekymarko/Scripts/suspendcommand
|
||||
fi
|
9
home/Scripts/metadata.sh
Executable file
9
home/Scripts/metadata.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
ARTIST=$(playerctl metadata | grep 'xesam:artist' | cut -d' ' -f5- | sed 's/^[ \t]*//')
|
||||
TITLE=$(playerctl metadata title)
|
||||
|
||||
if [ -n "$ARTIST" ]; then
|
||||
echo "$ARTIST - $TITLE"
|
||||
else
|
||||
echo "$TITLE"
|
||||
fi
|
33
home/Scripts/mpvqueue
Executable file
33
home/Scripts/mpvqueue
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
MPVPIPE=/tmp/mpvqueue.playlist
|
||||
|
||||
notify="notify-send -i mpv -a mpv"
|
||||
|
||||
# if link is a youtube playlist, open recursively
|
||||
if [[ ${1} =~ (^.*(youtu.be\/|list=)([^#\&\?]*).*) ]]; then
|
||||
$notify "Adding playlist ${@}"
|
||||
/usr/local/bin/mpvqueue $(youtube-dl -j --flat-playlist "${1}" | jq -r '.id' | sed 's_^_https://youtube.com/watch?v=_')
|
||||
exit
|
||||
fi
|
||||
|
||||
# See if MPV is already running
|
||||
if [ -z "$(pidof mpv)" ]; then
|
||||
# mpv is not running
|
||||
# remove fifo
|
||||
rm -f $MPVPIPE && mkfifo $MPVPIPE
|
||||
|
||||
# start mpv
|
||||
/usr/bin/mpv --no-terminal --input-file="${MPVPIPE}" "${@}" & disown
|
||||
|
||||
# Wait for mpv to be up before moving on to adding anything else to playlist
|
||||
while [ -z "$(pidof mpv)" ]; do
|
||||
sleep 1
|
||||
done
|
||||
$notify "Playing ${@}"
|
||||
|
||||
else
|
||||
# mpv is running, so add stuff to playlist
|
||||
$notify "Adding ${@}"
|
||||
echo "loadfile \"${@}\" append-play" >> "${MPVPIPE}"
|
||||
fi
|
184
home/Scripts/open_with_linux.py
Executable file
184
home/Scripts/open_with_linux.py
Executable file
|
@ -0,0 +1,184 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import struct
|
||||
import subprocess
|
||||
|
||||
VERSION = '7.1b2'
|
||||
|
||||
try:
|
||||
sys.stdin.buffer
|
||||
|
||||
# Python 3.x version
|
||||
# Read a message from stdin and decode it.
|
||||
def getMessage():
|
||||
rawLength = sys.stdin.buffer.read(4)
|
||||
if len(rawLength) == 0:
|
||||
sys.exit(0)
|
||||
messageLength = struct.unpack('@I', rawLength)[0]
|
||||
message = sys.stdin.buffer.read(messageLength).decode('utf-8')
|
||||
return json.loads(message)
|
||||
|
||||
# Send an encoded message to stdout
|
||||
def sendMessage(messageContent):
|
||||
encodedContent = json.dumps(messageContent).encode('utf-8')
|
||||
encodedLength = struct.pack('@I', len(encodedContent))
|
||||
|
||||
sys.stdout.buffer.write(encodedLength)
|
||||
sys.stdout.buffer.write(encodedContent)
|
||||
sys.stdout.buffer.flush()
|
||||
|
||||
except AttributeError:
|
||||
# Python 2.x version (if sys.stdin.buffer is not defined)
|
||||
# Read a message from stdin and decode it.
|
||||
def getMessage():
|
||||
rawLength = sys.stdin.read(4)
|
||||
if len(rawLength) == 0:
|
||||
sys.exit(0)
|
||||
messageLength = struct.unpack('@I', rawLength)[0]
|
||||
message = sys.stdin.read(messageLength)
|
||||
return json.loads(message)
|
||||
|
||||
# Send an encoded message to stdout
|
||||
def sendMessage(messageContent):
|
||||
encodedContent = json.dumps(messageContent)
|
||||
encodedLength = struct.pack('@I', len(encodedContent))
|
||||
|
||||
sys.stdout.write(encodedLength)
|
||||
sys.stdout.write(encodedContent)
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def install():
|
||||
home_path = os.getenv('HOME')
|
||||
|
||||
manifest = {
|
||||
'name': 'open_with',
|
||||
'description': 'Open With native host',
|
||||
'path': os.path.realpath(__file__),
|
||||
'type': 'stdio',
|
||||
}
|
||||
locations = {
|
||||
'chrome': os.path.join(home_path, '.config', 'google-chrome', 'NativeMessagingHosts'),
|
||||
'chromium': os.path.join(home_path, '.config', 'chromium', 'NativeMessagingHosts'),
|
||||
'firefox': os.path.join(home_path, '.mozilla', 'native-messaging-hosts'),
|
||||
}
|
||||
filename = 'open_with.json'
|
||||
|
||||
for browser, location in locations.items():
|
||||
if os.path.exists(os.path.dirname(location)):
|
||||
if not os.path.exists(location):
|
||||
os.mkdir(location)
|
||||
|
||||
browser_manifest = manifest.copy()
|
||||
if browser == 'firefox':
|
||||
browser_manifest['allowed_extensions'] = ['openwith@darktrojan.net']
|
||||
else:
|
||||
browser_manifest['allowed_origins'] = [
|
||||
'chrome-extension://cogjlncmljjnjpbgppagklanlcbchlno/', # Chrome
|
||||
'chrome-extension://fbmcaggceafhobjkhnaakhgfmdaadhhg/', # Opera
|
||||
]
|
||||
|
||||
with open(os.path.join(location, filename), 'w') as file:
|
||||
file.write(
|
||||
json.dumps(browser_manifest, indent=2, separators=(',', ': '), sort_keys=True).replace(' ', '\t') + '\n'
|
||||
)
|
||||
|
||||
|
||||
def _read_desktop_file(path):
|
||||
with open(path, 'r') as desktop_file:
|
||||
current_section = None
|
||||
name = None
|
||||
command = None
|
||||
for line in desktop_file:
|
||||
if line[0] == '[':
|
||||
current_section = line[1:-2]
|
||||
if current_section != 'Desktop Entry':
|
||||
continue
|
||||
|
||||
if line.startswith('Name='):
|
||||
name = line[5:].strip()
|
||||
elif line.startswith('Exec='):
|
||||
command = line[5:].strip()
|
||||
|
||||
return {
|
||||
'name': name,
|
||||
'command': command
|
||||
}
|
||||
|
||||
|
||||
def find_browsers():
|
||||
apps = [
|
||||
'Chrome',
|
||||
'Chromium',
|
||||
'chromium-browser',
|
||||
'firefox',
|
||||
'Firefox',
|
||||
'Google Chrome',
|
||||
'google-chrome',
|
||||
'opera',
|
||||
'Opera',
|
||||
'SeaMonkey',
|
||||
'seamonkey',
|
||||
]
|
||||
paths = [
|
||||
os.path.join(os.getenv('HOME'), '.local/share/applications'),
|
||||
'/usr/local/share/applications',
|
||||
'/usr/share/applications'
|
||||
]
|
||||
suffix = '.desktop'
|
||||
|
||||
results = []
|
||||
for p in paths:
|
||||
for a in apps:
|
||||
fp = os.path.join(p, a) + suffix
|
||||
if os.path.exists(fp):
|
||||
results.append(_read_desktop_file(fp))
|
||||
return results
|
||||
|
||||
|
||||
def listen():
|
||||
receivedMessage = getMessage()
|
||||
if receivedMessage == 'ping':
|
||||
sendMessage({
|
||||
'version': VERSION,
|
||||
'file': os.path.realpath(__file__)
|
||||
})
|
||||
elif receivedMessage == 'find':
|
||||
sendMessage(find_browsers())
|
||||
else:
|
||||
for k, v in os.environ.items():
|
||||
if k.startswith('MOZ_'):
|
||||
try:
|
||||
os.unsetenv(k)
|
||||
except:
|
||||
os.environ[k] = ''
|
||||
|
||||
devnull = open(os.devnull, 'w')
|
||||
subprocess.Popen(receivedMessage, stdout=devnull, stderr=devnull)
|
||||
sendMessage(None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) == 2:
|
||||
if sys.argv[1] == 'install':
|
||||
install()
|
||||
sys.exit(0)
|
||||
elif sys.argv[1] == 'find_browsers':
|
||||
print(find_browsers())
|
||||
sys.exit(0)
|
||||
|
||||
allowed_extensions = [
|
||||
'openwith@darktrojan.net',
|
||||
'chrome-extension://cogjlncmljjnjpbgppagklanlcbchlno/',
|
||||
'chrome-extension://fbmcaggceafhobjkhnaakhgfmdaadhhg/',
|
||||
]
|
||||
for ae in allowed_extensions:
|
||||
if ae in sys.argv:
|
||||
listen()
|
||||
sys.exit(0)
|
||||
|
||||
print('Open With native helper, version %s.' % VERSION)
|
32
home/Scripts/panextsink.sh
Normal file
32
home/Scripts/panextsink.sh
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Get the pid of the window that is to be moved to the next sink
|
||||
pid_to_move=$(swaymsg -t get_tree | jq -r '.nodes[]?.nodes[]?.nodes[]?.nodes[]?.nodes[] | select(.focused==true).pid')
|
||||
|
||||
# Assign all the sink indices into an array
|
||||
sink_array=($(pacmd list-sinks | grep index | sed 's/index://' | sed 's/*//' | xargs))
|
||||
|
||||
# Get the sink inputs to prepare to be inserted into array of arrays
|
||||
# The following raw string format is index sink pid\nindex sink pid
|
||||
sink_inputs_raw=$(pacmd list-sink-inputs | grep -e index -e sink: -e process.id | sed 's/<[^"]*>//' | sed 's/[^0-9]*//g' | tr '\n' ' ' | xargs | sed 's/\([[:digit:]]*\) \([[:digit:]]*\) \([[:digit:]]*\) /\1 \2 \3\n/g')
|
||||
|
||||
# Find the corresponding pid
|
||||
sink_input_selected_pid=$(echo "$sink_inputs_raw" | grep $pid_to_move)
|
||||
|
||||
# Parse the individual values from the info retrieved above
|
||||
selected_input_index=$(echo $sink_input_selected_pid | awk '{print $1;}')
|
||||
selected_input_sink=$(echo $sink_input_selected_pid | awk '{print $2;}')
|
||||
selected_input_pid=$(echo $sink_input_selected_pid | awk '{print $3;}')
|
||||
|
||||
len=${#sink_array[@]}
|
||||
|
||||
for (( i=0; i<$len; i++ )); do
|
||||
if [[ $selected_input_sink == "${sink_array[$i]}" ]]; then
|
||||
len_idx=$((len-1))
|
||||
if (( $i == $len_idx )); then
|
||||
pacmd move-sink-input $selected_input_index ${sink_array[0]}
|
||||
else
|
||||
pacmd move-sink-input $selected_input_index ${sink_array[$((i+1))]}
|
||||
fi
|
||||
fi
|
||||
done
|
13
home/Scripts/polybar.sh
Executable file
13
home/Scripts/polybar.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Terminate already running bar instances
|
||||
killall -q polybar
|
||||
|
||||
# Wait until the processes have been shut down
|
||||
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
|
||||
|
||||
# Launch bar1 and bar2
|
||||
polybar top &
|
||||
|
||||
|
||||
echo "Bars launched..."
|
26
home/Scripts/sway-exit.sh
Executable file
26
home/Scripts/sway-exit.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
RESP=$(cat <<EOF | fzf
|
||||
Exit
|
||||
Sleep
|
||||
Reboot
|
||||
Shutdown
|
||||
EOF
|
||||
);
|
||||
|
||||
case "$RESP" in
|
||||
Exit)
|
||||
swaymsg exit
|
||||
;;
|
||||
Sleep)
|
||||
systemctl suspend
|
||||
;;
|
||||
Reboot)
|
||||
systemctl reboot
|
||||
;;
|
||||
Shutdown)
|
||||
systemctl poweroff
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
esac
|
165
home/Scripts/sway-launcher-desktop.sh
Executable file
165
home/Scripts/sway-launcher-desktop.sh
Executable file
|
@ -0,0 +1,165 @@
|
|||
#!/usr/bin/env bash
|
||||
# terminal application launcher for sway, using fzf
|
||||
# Based on: https://gitlab.com/FlyingWombat/my-scripts/blob/master/sway-launcher
|
||||
|
||||
shopt -s nullglob
|
||||
if [[ "$1" == 'describe' ]]; then
|
||||
shift
|
||||
if [[ $2 == 'command' ]]; then
|
||||
title=$1
|
||||
readarray arr < <(whatis -l "$1" 2>/dev/null)
|
||||
description="${arr[0]}"
|
||||
description="${description%*-}"
|
||||
else
|
||||
title=$(sed -ne '/^Name=/{s/^Name=//;p;q}' "$1")
|
||||
description=$(sed -ne '/^Comment=/{s/^Comment=//;p;q}' "$1")
|
||||
fi
|
||||
echo -e "\033[33m$title\033[0m"
|
||||
echo "${description:-No description}"
|
||||
exit
|
||||
fi
|
||||
|
||||
HIST_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/${0##*/}-history.txt"
|
||||
|
||||
DIRS=(
|
||||
/usr/share/applications
|
||||
"$HOME/.local/share/applications"
|
||||
/usr/local/share/applications
|
||||
)
|
||||
|
||||
GLYPH_COMMAND=" "
|
||||
GLYPH_DESKTOP=" "
|
||||
|
||||
touch "$HIST_FILE"
|
||||
readarray HIST_LINES <"$HIST_FILE"
|
||||
FZFPIPE=$(mktemp)
|
||||
PIDFILE=$(mktemp)
|
||||
trap 'rm "$FZFPIPE" "$PIDFILE"' EXIT INT
|
||||
|
||||
# Append Launcher History, removing usage count
|
||||
(printf '%s' "${HIST_LINES[@]#* }" >>"$FZFPIPE") &
|
||||
|
||||
# Load and append Desktop entries
|
||||
(
|
||||
for dir in "${DIRS[@]}"; do
|
||||
[[ -d "$dir" ]] || continue
|
||||
awk -v pre="$GLYPH_DESKTOP" -F= '
|
||||
BEGINFILE{application=0;block="";a=0}
|
||||
/^\[Desktop Entry\]/{block="entry"}
|
||||
/^Type=Application/{application=1}
|
||||
/^\[Desktop Action/{
|
||||
sub("^\\[Desktop Action ", "");
|
||||
sub("\\]$", "");
|
||||
block="action";
|
||||
a++;
|
||||
actions[a,"key"]=$0
|
||||
}
|
||||
/^Name=/{
|
||||
if(block=="action") {
|
||||
actions[a,"name"]=$2;
|
||||
} else {
|
||||
name=$2
|
||||
}
|
||||
}
|
||||
ENDFILE{
|
||||
if (application){
|
||||
print FILENAME "\034desktop\034\033[33m" pre name "\033[0m";
|
||||
if (a>0)
|
||||
for (i=1; i<=a; i++)
|
||||
print FILENAME "\034desktop\034\033[33m" pre name "\033[0m (" actions[i, "name"] ")\034" actions[i, "key"]
|
||||
}
|
||||
}' \
|
||||
"$dir/"*.desktop </dev/null >>"$FZFPIPE"
|
||||
# the empty stdin is needed in case no *.desktop files
|
||||
done
|
||||
) &
|
||||
|
||||
# Load and append command list
|
||||
(
|
||||
IFS=:
|
||||
read -ra path <<<"$PATH"
|
||||
for dir in "${path[@]}"; do
|
||||
printf '%s\n' "$dir/"* |
|
||||
awk -F / -v pre="$GLYPH_COMMAND" '{print $NF "\034command\034\033[31m" pre "\033[0m" $NF;}'
|
||||
done | sort -u >>"$FZFPIPE"
|
||||
) &
|
||||
|
||||
COMMAND_STR=$(
|
||||
(
|
||||
tail -n +0 -f "$FZFPIPE" &
|
||||
echo $! >"$PIDFILE"
|
||||
) |
|
||||
fzf +s -x -d '\034' --nth ..3 --with-nth 3 \
|
||||
--preview "$0 describe {1} {2}" \
|
||||
--preview-window=up:3:wrap --ansi
|
||||
kill -9 "$(<"$PIDFILE")" | tail -n1
|
||||
) || exit 1
|
||||
|
||||
[ -z "$COMMAND_STR" ] && exit 1
|
||||
|
||||
# update history
|
||||
for i in "${!HIST_LINES[@]}"; do
|
||||
if [[ "${HIST_LINES[i]}" == *" $COMMAND_STR"$'\n' ]]; then
|
||||
HIST_COUNT=${HIST_LINES[i]%% *}
|
||||
HIST_LINES[$i]="$((HIST_COUNT + 1)) $COMMAND_STR"$'\n'
|
||||
match=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if ! ((match)); then
|
||||
HIST_LINES+=("1 $COMMAND_STR"$'\n')
|
||||
fi
|
||||
|
||||
printf '%s' "${HIST_LINES[@]}" | sort -nr >"$HIST_FILE"
|
||||
|
||||
command='echo "nope"'
|
||||
# shellcheck disable=SC2086
|
||||
readarray -d $'\034' -t PARAMS <<<${COMMAND_STR}
|
||||
# COMMAND_STR is "<string>\034<type>"
|
||||
case ${PARAMS[1]} in
|
||||
desktop)
|
||||
# Define the search pattern that specifies the block to search for within the .desktop file
|
||||
PATTERN="^\\\\[Desktop Entry\\\\]"
|
||||
if [[ -n ${PARAMS[3]} ]]; then
|
||||
PATTERN="^\\\\[Desktop Action ${PARAMS[3]%?}\\\\]"
|
||||
fi
|
||||
# 1. We see a line starting [Desktop, but we're already searching: deactivate search again
|
||||
# 2. We see the specified pattern: start search
|
||||
# 3. We see an Exec= line during search: remove field codes and set variable
|
||||
# 3. We see a Path= line during search: set variable
|
||||
# 4. Finally, build command line
|
||||
command=$(awk -v pattern="${PATTERN}" -F= '
|
||||
BEGIN{a=0;exec=0; path=0}
|
||||
/^\[Desktop/{
|
||||
if(a){
|
||||
a=0
|
||||
}
|
||||
}
|
||||
$0 ~ pattern{
|
||||
a=1
|
||||
}
|
||||
/^Exec=/{
|
||||
if(a && !exec){
|
||||
sub("^Exec=", "");
|
||||
gsub(" ?%[cDdFfikmNnUuv]", "");
|
||||
exec=$0;
|
||||
}
|
||||
}
|
||||
/^Path=/{
|
||||
if(a && !path){
|
||||
path=$2
|
||||
}
|
||||
}
|
||||
|
||||
END{
|
||||
if(path){
|
||||
print "cd " path " &&"
|
||||
}
|
||||
print exec
|
||||
}' "${PARAMS[0]}")
|
||||
;;
|
||||
command)
|
||||
command="${PARAMS[0]}"
|
||||
;;
|
||||
esac
|
||||
swaymsg -t command exec "$command"
|
13
home/Scripts/swayidle.sh
Executable file
13
home/Scripts/swayidle.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
swaylock="$HOME/Scripts/swaylock.sh"
|
||||
dimscreen="$HOME/Scripts/dim-screen.sh"
|
||||
screenon="swaymsg 'output * dpms on'"
|
||||
screenoff="swaymsg 'output * dpms off'"
|
||||
swayidle \
|
||||
lock "$swaylock" \
|
||||
timeout 300 "$dimscreen -sd" \
|
||||
resume "$dimscreen -r" \
|
||||
timeout 600 "loginctl lock-session; sleep 0.5; $screenoff" \
|
||||
resume "$screenon; $dimscreen -r" \
|
||||
before-sleep "playerctl pause; loginctl lock-session" \
|
||||
unlock "pkill -9 swaylock"
|
15
home/Scripts/swaylock.sh
Executable file
15
home/Scripts/swaylock.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
swaylock \
|
||||
--screenshots \
|
||||
--indicator \
|
||||
--clock \
|
||||
--datestr %Y-%m-%d \
|
||||
--effect-blur 6x10 \
|
||||
--inside-color "#2E3440" \
|
||||
--ring-color "#88C0D0" \
|
||||
--text-color "#FFFFFF" \
|
||||
--key-hl-color "#EBCB8B" \
|
||||
--inside-ver-color "#88C0D0" \
|
||||
--ring-ver-color "#88C0D0" \
|
||||
--ring-wrong-color "#BF616A" \
|
||||
--inside-wrong-color "#BF616A" \
|
8
home/Scripts/switchlayout.sh
Executable file
8
home/Scripts/switchlayout.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
curLayout=$(setxkbmap -query | grep layout | sed 's/layout: //g')
|
||||
|
||||
if [ $curLayout == "eu" ]; then
|
||||
setxkbmap dvorak
|
||||
else
|
||||
setxkbmap eu
|
||||
fi
|
26
home/Scripts/touchpadtoggle.sh
Executable file
26
home/Scripts/touchpadtoggle.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
gr="FocalTechPS/2 FocalTech Touchpad"
|
||||
#gr="SynPS/2 Synaptics TouchPad"
|
||||
|
||||
|
||||
#Creates a file if it does not exist to store the 0 or 1 bit to check if touchpad is enabled or disabled. Set to 0 by default
|
||||
if [ ! -f .touchpad ];
|
||||
then
|
||||
echo 0 > .touchpad;
|
||||
|
||||
fi
|
||||
|
||||
if grep -q 0 ".touchpad";
|
||||
then
|
||||
xinput enable "$gr";
|
||||
echo 1 > .touchpad;
|
||||
echo "Touchpad enabled"
|
||||
notify-send "Touchpad enabled"
|
||||
else
|
||||
xinput disable "$gr";
|
||||
echo 0 > .touchpad;
|
||||
echo "Touchpad Disabled"
|
||||
notify-send "Touchpad disabled"
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue