I3 to Sway (#1)
Added some ignored folders and files Updated waybar clock for Debian 11 Fixed bug on screen definition Fixed Iiyama North America PL2483H 1173700204528 Merge branch 'gentoo-sway' of git.darkou.fr:dbroqua/home into gentoo-sway Some changes for work environment Some changes for work environment Merge branch 'gentoo-sway' of git.darkou.fr:dbroqua/home into gentoo-sway Added .mp3 files Updated waybar config for laptop Added vim-jsx Added Teams to startup section (sad day in life!) Updated mpd config (local source) Added script for syncing my music Merge branch 'gentoo-sway' of git.darkou.fr:dbroqua/home into gentoo-sway Updated ranger config Merge branch 'gentoo-sway' of git.darkou.fr:dbroqua/home into gentoo-sway Replaced termite with alacritty Replaced termite by alacritty Updated rsync.sh results Merge branch 'gentoo-sway' of git.darkou.fr:dbroqua/home into gentoo-sway Updated github user Updated irc alias Minor changes Added master if fail fait dev* Added zsh prompt Updated output definitions Added KDEConnect at startup Added second screen Merge branch 'gentoo-sway' of git.darkou.fr:dbroqua/home into gentoo-sway Updated README Added C.A.V.A. Fixed bug for vte Added Tofu HHKB keyboard config Added script to update system Updated FuzzFm entry Added menu entry for Carnet Added qcad's ebuild Updated waybar for Thinkpad Updated temperature list for Thinkpad Fixed bug Updated input for thinkpad Added script to order files for Alpine car audio system Updated Fuzz url Added Grammalecte plugin Added displays for ThinkStation and ThinkPad Merge branch 'gentoo-sway' of framagit.org:dbroqua/home into gentoo-sway Updated waybar for laptop Fixed bug on adjust brightness Moved applications Co-authored-by: dbroqua <contact@darkou.fr> Co-authored-by: dbroqua <dbroqua@mousur.org> Reviewed-on: https://git.darkou.fr/dbroqua/home/pulls/1 Co-Authored-By: Damien Broqua <dbroqua@noreply.localhost> Co-Committed-By: Damien Broqua <dbroqua@noreply.localhost>
This commit is contained in:
parent
9969d212cc
commit
0d384b22bf
148 changed files with 5837 additions and 4018 deletions
4
bin/.directory
Normal file
4
bin/.directory
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Dolphin]
|
||||
Timestamp=2014,5,29,15,46,0
|
||||
Version=3
|
||||
ViewMode=2
|
15
bin/attachTmux.sh
Executable file
15
bin/attachTmux.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#! /bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Missing session name"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TMUXSESSION=$1
|
||||
EXISTS=`tmux ls|grep "${TMUXSESSION}:"`
|
||||
|
||||
if [ -z "${EXISTS}" ]; then
|
||||
tmux new -s ${TMUXSESSION}
|
||||
else
|
||||
tmux attach-session -t ${TMUXSESSION}
|
||||
fi
|
9
bin/autoFocus.sh
Executable file
9
bin/autoFocus.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#! /bin/bash
|
||||
|
||||
swaymsg -t get_outputs|grep 'eDP-1' > /dev/null
|
||||
|
||||
if [ $? == 0 ]; then
|
||||
swaymsg focus output eDP-1
|
||||
else
|
||||
swaymsg focus output HDMI-A-3
|
||||
fi
|
48
bin/bluetooth_headphones_status.sh
Executable file
48
bin/bluetooth_headphones_status.sh
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/zsh
|
||||
DIR=$(dirname $0)
|
||||
CMD=$1
|
||||
|
||||
# Get the first bluetooth device info
|
||||
# This comes as a CSV
|
||||
BT_SINK=$(pacmd list-cards | $DIR/bt_dev_info.awk | grep "bluez" | head -n 1)
|
||||
|
||||
if [ ! -z ${BT_SINK} ]; then
|
||||
# if there is a device connected, then we can either list or change profile
|
||||
# otherwise we do nothing
|
||||
id=$(echo ${BT_SINK} | cut -d "," -f 1)
|
||||
current_profile=$(echo ${BT_SINK} | cut -d "," -f 4)
|
||||
case ${current_profile} in
|
||||
"<a2dp_sink>")
|
||||
icon="headphones"
|
||||
next_profile="headset_head_unit"
|
||||
;;
|
||||
"<headset_head_unit>")
|
||||
icon="phone"
|
||||
next_profile="a2dp_sink"
|
||||
;;
|
||||
*)
|
||||
icon="unknown"
|
||||
next_profile=""
|
||||
;;
|
||||
esac
|
||||
case $CMD in
|
||||
"toggle_profile")
|
||||
pacmd set-card-profile ${id} ${next_profile}
|
||||
;;
|
||||
*)
|
||||
case ${current_profile} in
|
||||
"<a2dp_sink>")
|
||||
echo ""
|
||||
;;
|
||||
"<headset_head_unit>")
|
||||
echo ""
|
||||
;;
|
||||
*)
|
||||
echo "-"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "none"
|
||||
fi
|
24
bin/brightness.sh
Executable file
24
bin/brightness.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#! /bin/bash
|
||||
|
||||
CURRENT=`xrandr --verbose | grep -m 1 -i brightness | cut -f2 -d ' '`
|
||||
OUTPUT=`xrandr|grep ' connected'|grep 'primary'|cut -d' ' -f 1`
|
||||
GAP=0.1
|
||||
NEWVALUE=${CURRENT}
|
||||
|
||||
case $1 in
|
||||
up)
|
||||
NEWVALUE=`echo "${CURRENT}+${GAP}"|bc -l`
|
||||
;;
|
||||
down)
|
||||
NEWVALUE=`echo "${CURRENT}-${GAP}"|bc -l`
|
||||
;;
|
||||
reset)
|
||||
NEWVALUE=1
|
||||
;;
|
||||
read)
|
||||
echo "${CURRENT}*100/1"|bc
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
xrandr --output ${OUTPUT} --brightness ${NEWVALUE}
|
16
bin/bt_dev_info.awk
Executable file
16
bin/bt_dev_info.awk
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/awk -f
|
||||
BEGIN {
|
||||
FS = "([ ]?:[ ])|([ ]=[ ])";
|
||||
print "INDEX,NICE_NAME,DEVICE,ACTIVE_PROFILE"
|
||||
count = 0;
|
||||
}
|
||||
/index/ { i=$2; indices[count++] = $2 }
|
||||
/^\s+name:/ { names[i] = $2 }
|
||||
/^\s+active profile:/ { profiles[i] = $2 }
|
||||
/^\s+device\.description/ { nice[i] = $2 }
|
||||
END {
|
||||
for (j=0; j<count; j++) {
|
||||
i=indices[j];
|
||||
print i "," nice[i] "," names[i] "," profiles[i]
|
||||
}
|
||||
}
|
39
bin/btswitch.sh
Executable file
39
bin/btswitch.sh
Executable file
|
@ -0,0 +1,39 @@
|
|||
#! /bin/bash
|
||||
|
||||
HEADPHONE="88:D0:39:7D:6A:70"
|
||||
SPEAKERS="EC:81:93:94:92:73"
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Missing profil"
|
||||
echo "example: btswitch.sh <headphone|speakers>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case ${1} in
|
||||
headphone)
|
||||
bluetoothctl disconnect ${SPEAKERS}
|
||||
bluetoothctl connect ${HEADPHONE}
|
||||
# INFO: Dirty
|
||||
sleep 5
|
||||
;;
|
||||
speakers)
|
||||
bluetoothctl disconnect ${HEADPHONE}
|
||||
bluetoothctl connect ${SPEAKERS}
|
||||
;;
|
||||
*)
|
||||
echo "Unknown mode"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
|
||||
OUTPUTID=`pactl list short sinks|grep bluez|cut -f 1`
|
||||
|
||||
echo "Set Bluetooth as default output"
|
||||
pacmd set-default-sink ${OUTPUTID}
|
||||
|
||||
echo "Move streams to default output"
|
||||
pactl list short sink-inputs|while read stream; do
|
||||
streamId=$(echo $stream|cut '-d ' -f1)
|
||||
echo "moving stream $streamId"
|
||||
pactl move-sink-input "$streamId" "${OUTPUTID}"
|
||||
done
|
13
bin/build-kernel.sh
Executable file
13
bin/build-kernel.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#! /bin/bash
|
||||
|
||||
cd /usr/src/linux
|
||||
|
||||
make oldconfig
|
||||
|
||||
make menuconfig
|
||||
|
||||
make -j17
|
||||
make modules_install
|
||||
make install
|
||||
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
6
bin/device_battery.sh
Executable file
6
bin/device_battery.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#! /bin/bash
|
||||
|
||||
MOUSE_PATH=`qdbus --system org.freedesktop.UPower|grep $1`
|
||||
PERCENTAGE=`qdbus --system org.freedesktop.UPower ${MOUSE_PATH} org.freedesktop.UPower.Device.Percentage`
|
||||
|
||||
echo ${PERCENTAGE}%
|
14
bin/i3quit.sh
Executable file
14
bin/i3quit.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
# a simple logout dialog
|
||||
|
||||
# launch exit menu
|
||||
choice=`echo -e "0: Logout\n1: Shutdown\n2: Suspend\n3: Reboot\n4: Cancel" | rofi -dmenu -p "select an action" | cut -d ':' -f 1`
|
||||
|
||||
# execute the choice in background
|
||||
case "$choice" in
|
||||
0) i3-msg exit & ;;
|
||||
1) systemctl poweroff & ;;
|
||||
2) ~/bin/lock.sh & sleep 2 && systemctl suspend & ;;
|
||||
3) systemctl reboot & ;;
|
||||
4) exit ;;
|
||||
esac
|
8
bin/lock.sh
Executable file
8
bin/lock.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
#notify-send --icon=gtk-info Lock "Screen lock in progress..."
|
||||
|
||||
i3lock-fancy
|
||||
#/opt/i3lock-fancy-multimonitor/lock
|
||||
#dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause
|
||||
|
12
bin/logitech.py
Executable file
12
bin/logitech.py
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env python2.7
|
||||
|
||||
# dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/devices/battery_BAT0 org.freedesktop.DBus.Properties.Get string:org.freedesktop.UPower.Device string:'Percentage'
|
||||
|
||||
import dbus
|
||||
|
||||
bus = dbus.SystemBus()
|
||||
bat0_object = bus.get_object('org.freedesktop.UPower',
|
||||
'/org/freedesktop/UPower/devices/mouse_hidpp_battery_0')
|
||||
bat0 = dbus.Interface(bat0_object, 'org.freedesktop.DBus.Properties')
|
||||
|
||||
print bat0.Get("org.freedesktop.UPower.Device", "Percentage")
|
6
bin/mouse_battery.sh
Executable file
6
bin/mouse_battery.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#! /bin/bash
|
||||
|
||||
MOUSE_PATH=`qdbus --system org.freedesktop.UPower|grep mouse`
|
||||
PERCENTAGE=`qdbus --system org.freedesktop.UPower ${MOUSE_PATH} org.freedesktop.UPower.Device.Percentage`
|
||||
|
||||
echo ${PERCENTAGE}%
|
18
bin/music.sh
Executable file
18
bin/music.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#! /bin/bash
|
||||
|
||||
service=""
|
||||
spotifyIsUp=`pidof spotify`
|
||||
rhythmboxIsUp=`pidof rhythmbox`
|
||||
|
||||
if [ "${spotifyIsUp}" ]; then
|
||||
echo "Spotify is up!"
|
||||
service="spotify"
|
||||
elif [ "${rhythmboxIsUp}" ]; then
|
||||
echo "Rhythmbox is up!"
|
||||
service="rhythmbox"
|
||||
else
|
||||
echo "All down…"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
qdbus org.mpris.MediaPlayer2.${service} /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.$1
|
12
bin/nowPlaying.sh
Executable file
12
bin/nowPlaying.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#! /bin/bash
|
||||
|
||||
spotifyIsUp=`pidof spotify`
|
||||
rhythmboxIsUp=`pidof rhythmbox`
|
||||
|
||||
if [ "${spotifyIsUp}" ]; then
|
||||
echo $(qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata | grep "^xesam:\(title\|artist\):" | grep -o " .*" | column | sed "s/\t\+/:/g")
|
||||
elif [ "${rhythmboxIsUp}" ]; then
|
||||
echo $(rhythmbox-client --print-playing-format "%ta - %tt (%at)")
|
||||
else
|
||||
echo ""
|
||||
fi
|
16
bin/orderForAlpine.sh
Executable file
16
bin/orderForAlpine.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#! /bin/bash
|
||||
|
||||
DATE=`date +%Y%m%e%k`
|
||||
INC=1
|
||||
|
||||
DATE=$((DATE*100 + 00))
|
||||
|
||||
for file in *; do
|
||||
echo ${file} $((DATE+INC))
|
||||
touch -a -m -t $((DATE+INC)).00 "${file}"
|
||||
INC=$((INC+1))
|
||||
if [ ${INC} == 60 ]; then
|
||||
INC=0
|
||||
DATE=$((DATE+100))
|
||||
fi
|
||||
done
|
423
bin/pishrink.sh
Executable file
423
bin/pishrink.sh
Executable file
|
@ -0,0 +1,423 @@
|
|||
#!/bin/bash
|
||||
|
||||
version="v0.1.2"
|
||||
|
||||
CURRENT_DIR="$(pwd)"
|
||||
SCRIPTNAME="${0##*/}"
|
||||
MYNAME="${SCRIPTNAME%.*}"
|
||||
LOGFILE="${CURRENT_DIR}/${SCRIPTNAME%.*}.log"
|
||||
REQUIRED_TOOLS="parted losetup tune2fs md5sum e2fsck resize2fs"
|
||||
ZIPTOOLS=("gzip xz")
|
||||
declare -A ZIP_PARALLEL_TOOL=( [gzip]="pigz" [xz]="xz" ) # parallel zip tool to use in parallel mode
|
||||
declare -A ZIP_PARALLEL_OPTIONS=( [gzip]="-f9" [xz]="-T0" ) # options for zip tools in parallel mode
|
||||
declare -A ZIPEXTENSIONS=( [gzip]="gz" [xz]="xz" ) # extensions of zipped files
|
||||
|
||||
function info() {
|
||||
echo "$SCRIPTNAME: $1 ..."
|
||||
}
|
||||
|
||||
function error() {
|
||||
echo -n "$SCRIPTNAME: ERROR occured in line $1: "
|
||||
shift
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
if losetup "$loopback" &>/dev/null; then
|
||||
losetup -d "$loopback"
|
||||
fi
|
||||
if [ "$debug" = true ]; then
|
||||
local old_owner=$(stat -c %u:%g "$src")
|
||||
chown "$old_owner" "$LOGFILE"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function logVariables() {
|
||||
if [ "$debug" = true ]; then
|
||||
echo "Line $1" >> "$LOGFILE"
|
||||
shift
|
||||
local v var
|
||||
for var in "$@"; do
|
||||
eval "v=\$$var"
|
||||
echo "$var: $v" >> "$LOGFILE"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function checkFilesystem() {
|
||||
info "Checking filesystem"
|
||||
e2fsck -pf "$loopback"
|
||||
(( $? < 4 )) && return
|
||||
|
||||
info "Filesystem error detected!"
|
||||
|
||||
info "Trying to recover corrupted filesystem"
|
||||
e2fsck -y "$loopback"
|
||||
(( $? < 4 )) && return
|
||||
|
||||
if [[ $repair == true ]]; then
|
||||
info "Trying to recover corrupted filesystem - Phase 2"
|
||||
e2fsck -fy -b 32768 "$loopback"
|
||||
(( $? < 4 )) && return
|
||||
fi
|
||||
error $LINENO "Filesystem recoveries failed. Giving up..."
|
||||
exit 9
|
||||
|
||||
}
|
||||
|
||||
function set_autoexpand() {
|
||||
#Make pi expand rootfs on next boot
|
||||
mountdir=$(mktemp -d)
|
||||
partprobe "$loopback"
|
||||
mount "$loopback" "$mountdir"
|
||||
|
||||
if [ ! -d "$mountdir/etc" ]; then
|
||||
info "/etc not found, autoexpand will not be enabled"
|
||||
umount "$mountdir"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -f "$mountdir/etc/rc.local" ]] && [[ "$(md5sum "$mountdir/etc/rc.local" | cut -d ' ' -f 1)" != "1c579c7d5b4292fd948399b6ece39009" ]]; then
|
||||
echo "Creating new /etc/rc.local"
|
||||
if [ -f "$mountdir/etc/rc.local" ]; then
|
||||
mv "$mountdir/etc/rc.local" "$mountdir/etc/rc.local.bak"
|
||||
fi
|
||||
|
||||
#####Do not touch the following lines#####
|
||||
cat <<\EOF1 > "$mountdir/etc/rc.local"
|
||||
#!/bin/bash
|
||||
do_expand_rootfs() {
|
||||
ROOT_PART=$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p')
|
||||
|
||||
PART_NUM=${ROOT_PART#mmcblk0p}
|
||||
if [ "$PART_NUM" = "$ROOT_PART" ]; then
|
||||
echo "$ROOT_PART is not an SD card. Don't know how to expand"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Get the starting offset of the root partition
|
||||
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g')
|
||||
[ "$PART_START" ] || return 1
|
||||
# Return value will likely be error for fdisk as it fails to reload the
|
||||
# partition table because the root fs is mounted
|
||||
fdisk /dev/mmcblk0 <<EOF
|
||||
p
|
||||
d
|
||||
$PART_NUM
|
||||
n
|
||||
p
|
||||
$PART_NUM
|
||||
$PART_START
|
||||
|
||||
p
|
||||
w
|
||||
EOF
|
||||
|
||||
cat <<EOF > /etc/rc.local &&
|
||||
#!/bin/sh
|
||||
echo "Expanding /dev/$ROOT_PART"
|
||||
resize2fs /dev/$ROOT_PART
|
||||
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
|
||||
|
||||
EOF
|
||||
reboot
|
||||
exit
|
||||
}
|
||||
raspi_config_expand() {
|
||||
/usr/bin/env raspi-config --expand-rootfs
|
||||
if [[ $? != 0 ]]; then
|
||||
return -1
|
||||
else
|
||||
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
|
||||
reboot
|
||||
exit
|
||||
fi
|
||||
}
|
||||
raspi_config_expand
|
||||
echo "WARNING: Using backup expand..."
|
||||
sleep 5
|
||||
do_expand_rootfs
|
||||
echo "ERROR: Expanding failed..."
|
||||
sleep 5
|
||||
if [[ -f /etc/rc.local.bak ]]; then
|
||||
cp -f /etc/rc.local.bak /etc/rc.local
|
||||
/etc/rc.local
|
||||
fi
|
||||
exit 0
|
||||
EOF1
|
||||
#####End no touch zone#####
|
||||
chmod +x "$mountdir/etc/rc.local"
|
||||
fi
|
||||
umount "$mountdir"
|
||||
}
|
||||
|
||||
help() {
|
||||
local help
|
||||
read -r -d '' help << EOM
|
||||
Usage: $0 [-adhrspvzZ] imagefile.img [newimagefile.img]
|
||||
|
||||
-s Don't expand filesystem when image is booted the first time
|
||||
-v Be verbose
|
||||
-r Use advanced filesystem repair option if the normal one fails
|
||||
-z Compress image after shrinking with gzip
|
||||
-Z Compress image after shrinking with xz
|
||||
-a Compress image in parallel using multiple cores
|
||||
-p Remove logs, apt archives, dhcp leases and ssh hostkeys
|
||||
-d Write debug messages in a debug log file
|
||||
EOM
|
||||
echo "$help"
|
||||
exit 1
|
||||
}
|
||||
|
||||
should_skip_autoexpand=false
|
||||
debug=false
|
||||
repair=false
|
||||
parallel=false
|
||||
verbose=false
|
||||
prep=false
|
||||
ziptool=""
|
||||
|
||||
while getopts ":adhprsvzZ" opt; do
|
||||
case "${opt}" in
|
||||
a) parallel=true;;
|
||||
d) debug=true;;
|
||||
h) help;;
|
||||
p) prep=true;;
|
||||
r) repair=true;;
|
||||
s) should_skip_autoexpand=true ;;
|
||||
v) verbose=true;;
|
||||
z) ziptool="gzip";;
|
||||
Z) ziptool="xz";;
|
||||
*) help;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
if [ "$debug" = true ]; then
|
||||
info "Creating log file $LOGFILE"
|
||||
rm "$LOGFILE" &>/dev/null
|
||||
exec 1> >(stdbuf -i0 -o0 -e0 tee -a "$LOGFILE" >&1)
|
||||
exec 2> >(stdbuf -i0 -o0 -e0 tee -a "$LOGFILE" >&2)
|
||||
fi
|
||||
|
||||
echo "${0##*/} $version"
|
||||
|
||||
#Args
|
||||
src="$1"
|
||||
img="$1"
|
||||
|
||||
#Usage checks
|
||||
if [[ -z "$img" ]]; then
|
||||
help
|
||||
fi
|
||||
|
||||
if [[ ! -f "$img" ]]; then
|
||||
error $LINENO "$img is not a file..."
|
||||
exit 2
|
||||
fi
|
||||
if (( EUID != 0 )); then
|
||||
error $LINENO "You need to be running as root."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# check selected compression tool is supported and installed
|
||||
if [[ -n $ziptool ]]; then
|
||||
if [[ ! " ${ZIPTOOLS[@]} " =~ $ziptool ]]; then
|
||||
error $LINENO "$ziptool is an unsupported ziptool."
|
||||
exit 17
|
||||
else
|
||||
if [[ $parallel == true && $ziptool == "gzip" ]]; then
|
||||
REQUIRED_TOOLS="$REQUIRED_TOOLS pigz"
|
||||
else
|
||||
REQUIRED_TOOLS="$REQUIRED_TOOLS $ziptool"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#Check that what we need is installed
|
||||
for command in $REQUIRED_TOOLS; do
|
||||
command -v $command >/dev/null 2>&1
|
||||
if (( $? != 0 )); then
|
||||
error $LINENO "$command is not installed."
|
||||
exit 4
|
||||
fi
|
||||
done
|
||||
|
||||
#Copy to new file if requested
|
||||
if [ -n "$2" ]; then
|
||||
f="$2"
|
||||
if [[ -n $ziptool && "${f##*.}" == "${ZIPEXTENSIONS[$ziptool]}" ]]; then # remove zip extension if zip requested because zip tool will complain about extension
|
||||
f="${f%.*}"
|
||||
fi
|
||||
info "Copying $1 to $f..."
|
||||
cp --reflink=auto --sparse=always "$1" "$f"
|
||||
if (( $? != 0 )); then
|
||||
error $LINENO "Could not copy file..."
|
||||
exit 5
|
||||
fi
|
||||
old_owner=$(stat -c %u:%g "$1")
|
||||
chown "$old_owner" "$f"
|
||||
img="$f"
|
||||
fi
|
||||
|
||||
# cleanup at script exit
|
||||
trap cleanup EXIT
|
||||
|
||||
#Gather info
|
||||
info "Gathering data"
|
||||
beforesize="$(ls -lh "$img" | cut -d ' ' -f 5)"
|
||||
parted_output="$(parted -ms "$img" unit B print)"
|
||||
rc=$?
|
||||
if (( $rc )); then
|
||||
error $LINENO "parted failed with rc $rc"
|
||||
info "Possibly invalid image. Run 'parted $img unit B print' manually to investigate"
|
||||
exit 6
|
||||
fi
|
||||
partnum="$(echo "$parted_output" | tail -n 1 | cut -d ':' -f 1)"
|
||||
partstart="$(echo "$parted_output" | tail -n 1 | cut -d ':' -f 2 | tr -d 'B')"
|
||||
if [ -z "$(parted -s "$img" unit B print | grep "$partstart" | grep logical)" ]; then
|
||||
parttype="primary"
|
||||
else
|
||||
parttype="logical"
|
||||
fi
|
||||
loopback="$(losetup -f --show -o "$partstart" "$img")"
|
||||
tune2fs_output="$(tune2fs -l "$loopback")"
|
||||
rc=$?
|
||||
if (( $rc )); then
|
||||
echo "$tune2fs_output"
|
||||
error $LINENO "tune2fs failed. Unable to shrink this type of image"
|
||||
exit 7
|
||||
fi
|
||||
|
||||
currentsize="$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -d ':' -f 2)"
|
||||
blocksize="$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)"
|
||||
|
||||
logVariables $LINENO beforesize parted_output partnum partstart parttype tune2fs_output currentsize blocksize
|
||||
|
||||
#Check if we should make pi expand rootfs on next boot
|
||||
if [ "$parttype" == "logical" ]; then
|
||||
echo "WARNING: PiShrink does not yet support autoexpanding of this type of image"
|
||||
elif [ "$should_skip_autoexpand" = false ]; then
|
||||
set_autoexpand
|
||||
else
|
||||
echo "Skipping autoexpanding process..."
|
||||
fi
|
||||
|
||||
if [[ $prep == true ]]; then
|
||||
info "Syspreping: Removing logs, apt archives, dhcp leases and ssh hostkeys"
|
||||
mountdir=$(mktemp -d)
|
||||
mount "$loopback" "$mountdir"
|
||||
rm -rvf $mountdir/var/cache/apt/archives/* $mountdir/var/lib/dhcpcd5/* $mountdir/var/log/* $mountdir/var/tmp/* $mountdir/tmp/* $mountdir/etc/ssh/*_host_*
|
||||
umount "$mountdir"
|
||||
fi
|
||||
|
||||
|
||||
#Make sure filesystem is ok
|
||||
checkFilesystem
|
||||
|
||||
if ! minsize=$(resize2fs -P "$loopback"); then
|
||||
rc=$?
|
||||
error $LINENO "resize2fs failed with rc $rc"
|
||||
exit 10
|
||||
fi
|
||||
minsize=$(cut -d ':' -f 2 <<< "$minsize" | tr -d ' ')
|
||||
logVariables $LINENO currentsize minsize
|
||||
if [[ $currentsize -eq $minsize ]]; then
|
||||
error $LINENO "Image already shrunk to smallest size"
|
||||
exit 11
|
||||
fi
|
||||
|
||||
#Add some free space to the end of the filesystem
|
||||
extra_space=$(($currentsize - $minsize))
|
||||
logVariables $LINENO extra_space
|
||||
for space in 5000 1000 100; do
|
||||
if [[ $extra_space -gt $space ]]; then
|
||||
minsize=$(($minsize + $space))
|
||||
break
|
||||
fi
|
||||
done
|
||||
logVariables $LINENO minsize
|
||||
|
||||
#Shrink filesystem
|
||||
info "Shrinking filesystem"
|
||||
resize2fs -p "$loopback" $minsize
|
||||
rc=$?
|
||||
if (( $rc )); then
|
||||
error $LINENO "resize2fs failed with rc $rc"
|
||||
mount "$loopback" "$mountdir"
|
||||
mv "$mountdir/etc/rc.local.bak" "$mountdir/etc/rc.local"
|
||||
umount "$mountdir"
|
||||
losetup -d "$loopback"
|
||||
exit 12
|
||||
fi
|
||||
sleep 1
|
||||
|
||||
#Shrink partition
|
||||
partnewsize=$(($minsize * $blocksize))
|
||||
newpartend=$(($partstart + $partnewsize))
|
||||
logVariables $LINENO partnewsize newpartend
|
||||
parted -s -a minimal "$img" rm "$partnum"
|
||||
rc=$?
|
||||
if (( $rc )); then
|
||||
error $LINENO "parted failed with rc $rc"
|
||||
exit 13
|
||||
fi
|
||||
|
||||
parted -s "$img" unit B mkpart "$parttype" "$partstart" "$newpartend"
|
||||
rc=$?
|
||||
if (( $rc )); then
|
||||
error $LINENO "parted failed with rc $rc"
|
||||
exit 14
|
||||
fi
|
||||
|
||||
#Truncate the file
|
||||
info "Shrinking image"
|
||||
endresult=$(parted -ms "$img" unit B print free)
|
||||
rc=$?
|
||||
if (( $rc )); then
|
||||
error $LINENO "parted failed with rc $rc"
|
||||
exit 15
|
||||
fi
|
||||
|
||||
endresult=$(tail -1 <<< "$endresult" | cut -d ':' -f 2 | tr -d 'B')
|
||||
logVariables $LINENO endresult
|
||||
truncate -s "$endresult" "$img"
|
||||
rc=$?
|
||||
if (( $rc )); then
|
||||
error $LINENO "trunate failed with rc $rc"
|
||||
exit 16
|
||||
fi
|
||||
|
||||
# handle compression
|
||||
if [[ -n $ziptool ]]; then
|
||||
options=""
|
||||
envVarname="${MYNAME^^}_${ziptool^^}" # PISHRINK_GZIP or PISHRINK_XZ environment variables allow to override all options for gzip or xz
|
||||
[[ $parallel == true ]] && options="${ZIP_PARALLEL_OPTIONS[$ziptool]}"
|
||||
[[ -v $envVarname ]] && options="${!envVarname}" # if environment variable defined use these options
|
||||
[[ $verbose == true ]] && options="$options -v" # add verbose flag if requested
|
||||
|
||||
if [[ $parallel == true ]]; then
|
||||
parallel_tool="${ZIP_PARALLEL_TOOL[$ziptool]}"
|
||||
info "Using $parallel_tool on the shrunk image"
|
||||
if ! $parallel_tool ${options} "$img"; then
|
||||
rc=$?
|
||||
error $LINENO "$parallel_tool failed with rc $rc"
|
||||
exit 18
|
||||
fi
|
||||
|
||||
else # sequential
|
||||
info "Using $ziptool on the shrunk image"
|
||||
if ! $ziptool ${options} "$img"; then
|
||||
rc=$?
|
||||
error $LINENO "$ziptool failed with rc $rc"
|
||||
exit 19
|
||||
fi
|
||||
fi
|
||||
img=$img.${ZIPEXTENSIONS[$ziptool]}
|
||||
fi
|
||||
|
||||
aftersize=$(ls -lh "$img" | cut -d ' ' -f 5)
|
||||
logVariables $LINENO aftersize
|
||||
|
||||
info "Shrunk $img from $beforesize to $aftersize"
|
28
bin/plymouth.sh
Executable file
28
bin/plymouth.sh
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
## Preview Plymouth Splash ##
|
||||
## by _khAttAm_ ##
|
||||
## www.khattam.info ##
|
||||
## License: GPL v3 ##
|
||||
|
||||
chk_root () {
|
||||
if [ ! $( id -u ) -eq 0 ]; then
|
||||
echo Must be run as root
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
chk_root
|
||||
|
||||
DURATION=$1
|
||||
if [ $# -ne 1 ]; then
|
||||
DURATION=5
|
||||
fi
|
||||
|
||||
plymouthd
|
||||
plymouth --show-splash
|
||||
for ((I=0; I<$DURATION; I++)); do
|
||||
plymouth --update=test$I;
|
||||
sleep 1;
|
||||
done;
|
||||
plymouth quit
|
14
bin/qmkCreateBranch.sh
Executable file
14
bin/qmkCreateBranch.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#! /bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Missing branch name"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git checkout master
|
||||
git fetch upstream
|
||||
git pull upstream master
|
||||
git push origin master
|
||||
|
||||
git checkout -b $1
|
||||
git push --set-upstream origin $1
|
5
bin/rebuild-world.sh
Executable file
5
bin/rebuild-world.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#! /bin/bash
|
||||
|
||||
emerge --ask --verbose --update --changed-use --deep @world
|
||||
|
||||
emerge --ask --verbose --depclean
|
21
bin/removeMerged.sh
Executable file
21
bin/removeMerged.sh
Executable file
|
@ -0,0 +1,21 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Checkout develop
|
||||
git develop
|
||||
|
||||
if [ $? = 1 ] ; then
|
||||
git checkout dev
|
||||
fi
|
||||
|
||||
if [ $? = 1 ] ; then
|
||||
git checkout master
|
||||
fi
|
||||
|
||||
# Get last changes
|
||||
git pull
|
||||
|
||||
# Get list of available remote's branch
|
||||
git fetch --prune origin
|
||||
|
||||
# List merged branch and remove it
|
||||
git branch --merged | egrep -v "(^\*|master|dev)" |xargs git branch -d
|
9
bin/rpi-create.sh
Executable file
9
bin/rpi-create.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#! /bin/bash
|
||||
|
||||
sudo dd if=$1 of=$2.raw.img
|
||||
sudo ~dbroqua/Bin/pishrink.sh $2.raw.img $2.img
|
||||
sudo chown dbroqua: $2.*
|
||||
|
||||
gzip $2.img
|
||||
|
||||
rm $2.raw.img
|
102
bin/rsync.sh
Executable file
102
bin/rsync.sh
Executable file
|
@ -0,0 +1,102 @@
|
|||
#!/bin/bash
|
||||
|
||||
TYPE='' # usb / sshfs
|
||||
CMD=rsync
|
||||
ARGS='-avz --delete
|
||||
--exclude /Nextcloud
|
||||
--exclude /.cache
|
||||
--exclude /Downloads
|
||||
--exclude /.thunderbird
|
||||
--exclude /Projects
|
||||
--exclude /Software
|
||||
--exclude /tmp
|
||||
--exclude /fonts
|
||||
--exclude /Music
|
||||
--exclude /node_modules
|
||||
--exclude /snap
|
||||
--exclude /.local/share/Trash
|
||||
--exclude /.npm
|
||||
--exclude /.thumbnails
|
||||
--exclude /Android
|
||||
--exclude /.AndroidStudio*
|
||||
--exclude /.android
|
||||
--exclude /.bundle/cache
|
||||
--exclude /.config/cache
|
||||
--exclude /.config/Code/Cache
|
||||
--exclude /.config/Code/CachedData
|
||||
--exclude /.config/Slack
|
||||
--exclude /.config/*/Cache
|
||||
--exclude /.config/chromium
|
||||
--exclude /.mozilla
|
||||
--exclude /.config/discord
|
||||
--exclude /.config/spotify
|
||||
--exclude /.crashlytics
|
||||
--exclude /.fastlane
|
||||
--exclude /.gradle
|
||||
--exclude ./Software
|
||||
--exclude /.local
|
||||
--exclude /.DataGrip*'
|
||||
ORIG='/home/dbroqua/'
|
||||
DEST=''
|
||||
HOSTNAME=`hostname`
|
||||
|
||||
|
||||
# USB
|
||||
UUID='6e3f7ae3-8fa1-43f3-88c0-a12651519ffb'
|
||||
MOUNT='/mnt/backup'
|
||||
DEST_USB="/mnt/backup/${HOSTNAME}/dbroqua/"
|
||||
# SSHFS
|
||||
DEST_SSHFS="storage:Backup/${HOSTNAME}/dbroqua/"
|
||||
|
||||
|
||||
while getopts t:h opt
|
||||
do
|
||||
case $opt in
|
||||
t)
|
||||
case ${OPTARG} in
|
||||
usb)
|
||||
TYPE='usb'
|
||||
DEST=${DEST_USB}
|
||||
;;
|
||||
sshfs)
|
||||
TYPE='sshfs'
|
||||
DEST=${DEST_SSHFS}
|
||||
;;
|
||||
*)
|
||||
echo "usb / sshfs attendu"
|
||||
exit 1;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if [ "${TYPE}" != '' ] ; then
|
||||
case ${TYPE} in
|
||||
usb)
|
||||
sudo cryptsetup luksOpen /dev/sdb1 backup
|
||||
sudo mount /dev/mapper/backup ${MOUNT}
|
||||
echo "Go !"
|
||||
if [ $? == 0 ] ; then
|
||||
${CMD} ${ARGS} ${ORIG} ${DEST}
|
||||
fi
|
||||
sudo umount ${MOUNT}
|
||||
sudo cryptsetup luksClose backup
|
||||
;;
|
||||
sshfs)
|
||||
${CMD} ${ARGS} ${ORIG} ${DEST}
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo $?
|
||||
|
||||
if [ $? == 0 ] ; then
|
||||
echo `date` > ${ORIG}/lastBackup
|
||||
echo "Method: ${TYPE}" >> ${ORIG}/lastBackup
|
||||
rm ${ORIG}/lastFailBackup
|
||||
else
|
||||
echo `date` > ${ORIG}/lastFailBackup
|
||||
echo "Method: ${TYPE}" >> ${ORIG}/lastFailBackup
|
||||
fi
|
||||
|
72
bin/screenlayout.sh
Executable file
72
bin/screenlayout.sh
Executable file
|
@ -0,0 +1,72 @@
|
|||
#! /bin/bash
|
||||
|
||||
activeconfig='laptop'
|
||||
|
||||
if [ -f ~/.screenlayout.info ] ; then
|
||||
activeconfig=`cat ~/.screenlayout.info`
|
||||
fi
|
||||
|
||||
nextconfig='laptop'
|
||||
|
||||
case $activeconfig in
|
||||
home)
|
||||
nextconfig='homeoffice'
|
||||
;;
|
||||
homeoffice)
|
||||
nextconfig='laptop'
|
||||
;;
|
||||
laptop)
|
||||
nextconfig='home'
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $1 ]; then
|
||||
if [ "$1" = "menu" ]; then
|
||||
chosen="$(echo -e "$options" | $rofi_command -dmenu -selected-row 1)"
|
||||
exit 0
|
||||
else
|
||||
nextconfig=$1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ${nextconfig} > ~/.screenlayout.info
|
||||
|
||||
case $nextconfig in
|
||||
home)
|
||||
# Home
|
||||
xrandr --output DP-2-1 --primary --mode 2560x1080 --pos 0x0 --rotate normal \
|
||||
--output DP-2-2 --off \
|
||||
--output DP-2-3 --off \
|
||||
--output eDP-1 --off \
|
||||
--output HDMI-2 --off \
|
||||
--output HDMI-1 --off \
|
||||
--output DP-2 --off \
|
||||
--output DP-1 --off
|
||||
;;
|
||||
homeoffice)
|
||||
# Home Office
|
||||
xrandr --output DP-2-1 --primary --mode 2560x1080 --pos 0x0 --rotate normal \
|
||||
--output DP-2-2 --mode 1920x1080 --pos 2560x0 --rotate normal \
|
||||
# --output DP-2-2 --mode 1920x1080 --pos 2560x0 --rotate left \
|
||||
--output DP-2-3 --off \
|
||||
--output eDP-1 --off \
|
||||
--output HDMI-2 --off \
|
||||
--output HDMI-1 --off \
|
||||
--output DP-2 --off \
|
||||
--output DP-1 --off
|
||||
;;
|
||||
laptop)
|
||||
# Laptop mode
|
||||
xrandr --output DP-2-1 --off \
|
||||
--output DP-2-2 --off \
|
||||
--output DP-2-3 --off \
|
||||
--output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal \
|
||||
--output HDMI-2 --off \
|
||||
--output HDMI-1 --off \
|
||||
--output DP-2 --off \
|
||||
--output DP-1 --off
|
||||
;;
|
||||
esac
|
||||
|
||||
# Reset wallpaper
|
||||
~/bin/wallpaper.sh
|
26
bin/screenlayoutrofi.sh
Executable file
26
bin/screenlayoutrofi.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#! /bin/bash
|
||||
|
||||
rofi_command="rofi"
|
||||
mode="laptop"
|
||||
### Options ###
|
||||
laptop=" Laptop only"
|
||||
home=" Wide screen"
|
||||
homeoffice=" Dual screen"
|
||||
# Variable passed to rofi
|
||||
options="$laptop\n$home\n$homeoffice"
|
||||
|
||||
chosen="$(echo -e "$options" | $rofi_command -dmenu -selected-row 1)"
|
||||
|
||||
case $chosen in
|
||||
$latpop)
|
||||
mode="laptop"
|
||||
;;
|
||||
$home)
|
||||
mode="home"
|
||||
;;
|
||||
$homeoffice)
|
||||
mode="homeoffice"
|
||||
;;
|
||||
esac
|
||||
|
||||
~/bin/screenlayout.sh $mode
|
7
bin/screenshooter.sh
Executable file
7
bin/screenshooter.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#! /bin/bash
|
||||
|
||||
FILENAME="Screenshots-$(date +%Y%m%d-%H%M%S).png"
|
||||
|
||||
scrot -q 70 ${FILENAME} -e 'mv $f ~/Pictures/screenshots/'
|
||||
|
||||
notify-send -i screenie 'Screenshot!' "Saved as ${FILENAME}"
|
354
bin/slip
Executable file
354
bin/slip
Executable file
|
@ -0,0 +1,354 @@
|
|||
#! /bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
VERSION="2.0.4"
|
||||
|
||||
# Sane defaults in case of not being set in the config / config not existing.
|
||||
CREDENTIALS_FILE="$HOME/.config/slip/credentials"
|
||||
RECORD_PIDFILE="/tmp/slip_record.pid"
|
||||
IMAGES="$HOME/Pictures"
|
||||
VIDEOS="$HOME/Videos"
|
||||
GIF_SCALE="640"
|
||||
GIF_FPS=15
|
||||
SOUND=0
|
||||
NOUPLOAD=0
|
||||
|
||||
DMENU_CMD="rofi -dmenu -p slip"
|
||||
|
||||
# Load config.
|
||||
CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/slip/config"
|
||||
if [ -f $CONFIG ]; then
|
||||
source $CONFIG
|
||||
else
|
||||
echo "No config was found - using default options. Please copy the example configuration to ~/.config/slip/config from https://github.com/Toqozz/slip"
|
||||
fi
|
||||
|
||||
CLIENT_ID="abd3a90bbfb65e9"
|
||||
|
||||
# Dmenu prompts.
|
||||
DMENU_OPTS="screenshot
|
||||
video
|
||||
gif
|
||||
exit"
|
||||
DMENU_RECORD_OPTS="stop
|
||||
cancel"
|
||||
DMENU_UPLOAD_OPTS_BIG="upload (gfycat)
|
||||
delete
|
||||
exit"
|
||||
DMENU_UPLOAD_OPTS="upload (imgur)
|
||||
upload (gfycat)
|
||||
delete
|
||||
exit"
|
||||
|
||||
# Maximum size for upload (kb).
|
||||
# Gfycat does not have a file limit.
|
||||
MAX_GIF_SIZE_IMGUR=10000
|
||||
|
||||
function usage() {
|
||||
echo ""
|
||||
echo " slip [ -h | -v | -s | -r | -a | -q ] -nu"
|
||||
echo " Uploads images taken with ffmpeg via slop to imgur. Quick video recording."
|
||||
echo " That's all."
|
||||
echo ""
|
||||
echo " -h | --help show this help"
|
||||
echo " -v | --version show version"
|
||||
echo " -s | --screenshot take a screenshot (skip dmenu)"
|
||||
echo " -g | --gif take a gif (skip dmenu)"
|
||||
echo " -r | --record take a video (skip dmenu)"
|
||||
echo " -nu | --no-upload don't upload the result"
|
||||
echo " -q | --stop stop recording a video / gif (skip dmenu) (only when recording)"
|
||||
echo ""
|
||||
}
|
||||
|
||||
function upload_imgur() {
|
||||
file="$1"
|
||||
|
||||
if [ -f "$file" ]; then
|
||||
if [ -f "$CREDENTIALS_FILE" ]; then
|
||||
# We have an auth token to use.
|
||||
check_auth_credentials
|
||||
if [ $? -ne 1 ]; then
|
||||
# Token valid.
|
||||
curl -sH "Authorization: Bearer ${access_token}" -F "image=@$file" "https://api.imgur.com/3/upload"
|
||||
fi
|
||||
else
|
||||
# Imgur needs to know what program is using its services.
|
||||
curl -sH "Authorization: Client-ID ${CLIENT_ID}" -F "image=@$file" "https://api.imgur.com/3/upload"
|
||||
fi
|
||||
else
|
||||
echo "File does not exist, what happened?"
|
||||
fi
|
||||
}
|
||||
|
||||
function upload_gfycat() {
|
||||
local file="$1"
|
||||
|
||||
local result=$(curl -s -XPOST https://api.gfycat.com/v1/gfycats -H "Content-Type: application/json")
|
||||
local gfyname=$(parse "gfycat" $result)
|
||||
curl -s "https://filedrop.gfycat.com/$gfyname" --upload-file "$file"
|
||||
|
||||
# No new line so we can append it easily.
|
||||
echo -n "$gfyname"
|
||||
}
|
||||
|
||||
function check_auth_credentials() {
|
||||
token_expire_time=0
|
||||
if [ -f "${CREDENTIALS_FILE}" ]; then
|
||||
source "${CREDENTIALS_FILE}"
|
||||
fi
|
||||
|
||||
if [ ! -z ${access_token} ]; then
|
||||
current_time="$(date +%s)"
|
||||
preemptive_refresh_time="$((10*60))"
|
||||
expired="$((current_time > (token_expire_time - preemptive_refresh_time)))"
|
||||
|
||||
if [ "${expired}" -eq "0" ]; then
|
||||
#token has expired, get a new one.
|
||||
echo 'The authorization token has expired, please get a new one.'
|
||||
return 1;
|
||||
fi
|
||||
else
|
||||
return 1;
|
||||
fi
|
||||
}
|
||||
|
||||
function clip_clear() {
|
||||
# Clear x cliboard selection.
|
||||
xsel -bc # Ctrl-v / Shift-Insert.
|
||||
# xsel -pc # Middle click.
|
||||
}
|
||||
|
||||
# Run slop and get the geometry line.
|
||||
function slop_geom() {
|
||||
if [ "$1" = "image" ]; then
|
||||
slop -f '%wx%h+%x+%y'
|
||||
else
|
||||
slop -f '%wx%h|%x,%y' # | sed -e s/+/\|/ -e s/+/,/
|
||||
fi
|
||||
#elif [ "$1" = "video" ]; then
|
||||
#slop -f '%wx%h+%x+%y' | sed -e s/+/\|/ -e s/+/,/
|
||||
#slop | sed -n 5p | sed -e s/G=// -e s/+/\|/ -e s/+/,/
|
||||
#elif [ "$1" = "gif" ]; then
|
||||
#slop -f '%wx%h+%x+%y' | sed -e s/+/\|/ -e s/+/,/
|
||||
}
|
||||
|
||||
# Take the shot (or start the video.)
|
||||
function shot() {
|
||||
if [ "$1" = "image" ]; then
|
||||
extension=".png" # img-2016-04-16-153906.png
|
||||
filename="$IMAGES/img-`date +%Y-%m-%d-%H%M%S`$extension" # .png, .jpg
|
||||
maim -g "$2" $filename
|
||||
# TODO, do we want more dependencies? (optional dependencies?)
|
||||
#ffmpeg -f x11grab -video_size "$2" -i "$DISPLAY+$3" -vframes 1 $filename &> /dev/null
|
||||
elif [ "$1" = "video" ]; then
|
||||
extension=".mkv" # vid-2016-04-16-153906.mkv
|
||||
filename="$VIDEOS/vid-`date +%Y-%m-%d-%H%M%S`$extension" # .mkv, .mp4
|
||||
if [ $SOUND == 0 ]; then
|
||||
ffmpeg -f x11grab -video_size "$2" -framerate 60 -i "$DISPLAY+$3" -loglevel quiet -c:v libx264 -preset ultrafast $filename &
|
||||
else
|
||||
ffmpeg -f pulse -i 1 -f x11grab -video_size "$2" -framerate 60 -i "$DISPLAY+$3" -loglevel quiet -c:v libx264 -preset ultrafast $filename &
|
||||
fi
|
||||
echo "$! vid $filename" > "$RECORD_PIDFILE"
|
||||
elif [ "$1" = "gif" ]; then
|
||||
extension=".gif" # gif-2016-04-16-153906.gif
|
||||
tmpfilename="/tmp/gif-`date +%Y-%m-%d-%H%M%S-tmp`.mkv"
|
||||
filename="$VIDEOS/gif-`date +%Y-%m-%d-%H%M%S`$extension" # .gif
|
||||
# Record a video to be converted to gif.
|
||||
ffmpeg -f x11grab -video_size "$2" -framerate $GIF_FPS -i "$DISPLAY+$3" -loglevel quiet -c:v libx264 -preset ultrafast $tmpfilename &
|
||||
#ffmpeg -f x11grab -video_size "$2" -framerate 15 -i "$DISPLAY+$3" -vf scale="$GIF_SCALE:-1" $filename &> /dev/null &
|
||||
|
||||
# We need to access this information later.
|
||||
ratio=$(awk -F"x" '{ print int($1/$2) }' <<< "$2") # We only really need a binary answer.
|
||||
if [ "$ratio" -ge 1 ]; then echo "$! gif $tmpfilename $filename 0" > "$RECORD_PIDFILE"
|
||||
else echo "$! gif $tmpfilename $filename 1" > "$RECORD_PIDFILE"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function kill_ffmpeg() {
|
||||
# Kill ffmpeg (stopping the recording.)
|
||||
kill $1 || echo "Failed to kill ffmpeg, did it crash? Removing $RECORD_PIDFILE anyway."
|
||||
# Remove the pid file so that slip can be used as normal again.
|
||||
rm "$RECORD_PIDFILE"
|
||||
}
|
||||
|
||||
function convert_to_gif() {
|
||||
local tfn=$1
|
||||
local pfn=$2
|
||||
local fn=$3
|
||||
local wh=$4 # 0 = width larger than height, 1 = height larger than width
|
||||
|
||||
local ratio
|
||||
# If the width is larger than the height, we want to scale with the width, otherwise scale with the height.
|
||||
if [ $wh -eq 0 ]; then
|
||||
ratio="$GIF_SCALE:-1"
|
||||
else
|
||||
ratio="-1:$GIF_SCALE"
|
||||
fi
|
||||
|
||||
notify "Converting to gif…"
|
||||
# Give enough time to save the file.
|
||||
sleep 1 && ffmpeg -i "$tfn" -loglevel quiet -vf fps=$GIF_FPS,scale="$ratio":flags=lanczos,palettegen "$pfn" &&
|
||||
ffmpeg -i "$tfn" -i "$pfn" -loglevel quiet -filter_complex "fps=$GIF_FPS,scale=$ratio:flags=lanczos[x];[x][1:v]paletteuse" "$fn" &&
|
||||
|
||||
echo "$fn"
|
||||
}
|
||||
|
||||
function stop_rec() {
|
||||
local choice
|
||||
|
||||
local pid=$1 # Process id (for killing ffmpeg).
|
||||
local tfn=$3 # Temp file name (for gifs).
|
||||
local fn=$4 # File name for the gif/vid we're saving.
|
||||
local pfn="${tfn}-palette.png" # Palette file name (for gif rendering).
|
||||
|
||||
# Stop recording.
|
||||
kill_ffmpeg "$pid"
|
||||
|
||||
# When processing a gif, we canvert it straight away and then upload.
|
||||
# NOTE: gfycat does not require the video to be converted, but we convert it anyway to store
|
||||
# the .gif file.
|
||||
# Is this actually a good idea? We could just store the .mkv instead, but then we lose the ability to store .gif.
|
||||
if [ "$2" = "gif" ]; then
|
||||
fn=$(convert_to_gif "$tfn" "$pfn" "$fn" "$5")
|
||||
size=$(du -k $fn | cut -f1)
|
||||
|
||||
if [ $NOUPLOAD == 0 ]; then
|
||||
if [ "$size" -lt "${MAX_GIF_SIZE_IMGUR}" ]; then
|
||||
choice=$($DMENU_CMD <<< $DMENU_UPLOAD_OPTS)
|
||||
else
|
||||
choice=$($DMENU_CMD <<< $DMENU_UPLOAD_OPTS_BIG)
|
||||
fi
|
||||
|
||||
if [ "$choice" = "upload (gfycat)" ]; then
|
||||
clip_clear
|
||||
name=$(upload_gfycat "$tfn")
|
||||
url="https://gfycat.com/$name"
|
||||
notify "Uploading to $url ..."
|
||||
echo "$url"
|
||||
echo -n "$url" | xsel -bi # Read to clipboard.
|
||||
elif [ "$choice" = "upload (imgur)" ]; then
|
||||
clip_clear
|
||||
output=$(upload_imgur "$fn")
|
||||
url=$(parse "imgur" "$output")
|
||||
notify "$url"
|
||||
echo "$url"
|
||||
echo -n "$url" | xsel -bi # Read to clipboard.
|
||||
elif [ "$choice" = "delete" ]; then
|
||||
rm $fn
|
||||
fi
|
||||
fi
|
||||
else
|
||||
notify "$fn"
|
||||
fi
|
||||
}
|
||||
|
||||
# Parse x,y -- but also imgur.
|
||||
function parse() {
|
||||
if [ "$1" = "geometryx" ]; then
|
||||
awk -F"|" '{ print $1 }' <<< "$2"
|
||||
elif [ "$1" = "geometry+" ]; then
|
||||
awk -F"|" '{ print $2 }' <<< "$2"
|
||||
elif [ "$1" = "imgur" ]; then
|
||||
jq -r ".data.link" <<< "$2"
|
||||
#sed -e 's/.*\"link\":"\([^"]*\).*/\1/' -e 's/\\//g' <<< "$2"
|
||||
#sed -e 's/\"link\":"\([^"]*\)/\1/' -e 's/\\//g' <<< "$2"
|
||||
elif [ "$1" = "gfycat" ]; then
|
||||
jq -r ".gfyname" <<< "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
function notify() {
|
||||
notify-send -t 7000 "slip" "$1"
|
||||
}
|
||||
|
||||
function main() {
|
||||
if [ "$1" = "screenshot" ]; then
|
||||
# Run slop and get geometry from it.
|
||||
# maim naturally supports slop's output coordinates.
|
||||
geometry=$(slop_geom "image")
|
||||
# Take the shot.
|
||||
shot "image" "$geometry"
|
||||
# Parse imgur json into link.
|
||||
|
||||
# If noupload is not set.
|
||||
if [ $NOUPLOAD == 0 ]; then
|
||||
#echo "uploading..."
|
||||
# Clear cliboard before doing anything, so we can copy link to it later.
|
||||
clip_clear
|
||||
output=$(upload_imgur "$filename")
|
||||
url=$(parse "imgur" "$output")
|
||||
# Notify user that upload has finished.
|
||||
notify "$url"
|
||||
echo "$url"
|
||||
# Read to clipboard, removing trailing newline.
|
||||
echo -n "$url" | xsel -bi
|
||||
else
|
||||
notify "$filename"
|
||||
fi
|
||||
|
||||
# echo "$url" | xsel -pi # Read to primary.
|
||||
elif [ "$1" = "video" ]; then
|
||||
geometry=$(slop_geom "video")
|
||||
wxh=$(parse "geometryx" $geometry)
|
||||
off=$(parse "geometry+" $geometry)
|
||||
shot "video" "$wxh" "$off"
|
||||
elif [ "$1" = "gif" ]; then
|
||||
geometry=$(slop_geom "gif")
|
||||
wxh=$(parse "geometryx" $geometry)
|
||||
off=$(parse "geometry+" $geometry)
|
||||
shot "gif" "$wxh" "$off"
|
||||
elif [ "$1" = "stop" ]; then
|
||||
# Get info of recording process.
|
||||
local info
|
||||
# Get infor from the pidfile.
|
||||
info=$(cat "$RECORD_PIDFILE")
|
||||
# Stop with parameters ("<pid> <type> <filename> <ratio>")
|
||||
stop_rec $info
|
||||
exit 0
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Dependencies.
|
||||
depends="curl
|
||||
jq
|
||||
maim
|
||||
slop
|
||||
ffmpeg"
|
||||
while read line
|
||||
do
|
||||
if ! type $line &> /dev/null ; then
|
||||
echo "$line not found, expect unexpected or breakage."
|
||||
fi
|
||||
done <<< "$depends"
|
||||
|
||||
# Main.
|
||||
# Yes, we could call this stuff with integers, but this is much clearer.
|
||||
if [ "$1" = "-nu" -o "$1" = "--no-upload" -o "$2" = "-nu" -o "$2" = "--no-upload" ]; then
|
||||
NOUPLOAD=1
|
||||
fi
|
||||
|
||||
if [ "$1" = "-h" -o "$1" = "--help" ]; then
|
||||
usage
|
||||
exit 0
|
||||
elif [ "$1" = "-v" -o "$1" = "--version" ]; then
|
||||
echo "Version: $VERSION"
|
||||
exit 0
|
||||
elif [ "$1" = "-s" -o "$1" = "--screenshot" ]; then
|
||||
main "screenshot"
|
||||
elif [ "$1" = "-g" -o "$1" = "--gif" ]; then
|
||||
main "gif"
|
||||
elif [ "$1" = "-r" -o "$1" = "--record" ]; then
|
||||
main "video"
|
||||
elif [ "$1" = "-q" -o "$1" = "--stop" ]; then
|
||||
main "stop"
|
||||
elif [ $# == 0 ]; then
|
||||
if [ -a "$RECORD_PIDFILE" ]; then
|
||||
main $($DMENU_CMD <<< "$DMENU_RECORD_OPTS")
|
||||
else
|
||||
main $($DMENU_CMD <<< "$DMENU_OPTS")
|
||||
fi
|
||||
fi
|
5
bin/syncMusic.sh
Executable file
5
bin/syncMusic.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#! /bin/bash
|
||||
|
||||
chmod a+r ~/Music/**/*.flac ~/Music/**/*.mp3
|
||||
|
||||
rsync -avz --delete ~/Music storage:/srv/dev-disk-by-label-storage/medias/
|
7
bin/timelapse.sh
Executable file
7
bin/timelapse.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#! /bin/bash
|
||||
|
||||
ls -1tr | grep -v files.txt > files.txt
|
||||
|
||||
mencoder -nosound -noskip -oac copy -ovc copy -o output.avi -mf fps=20 'mf://@files.txt'
|
||||
|
||||
ffmpeg -i output.avi -y -sameq -vf scale=1920:1440,crop=1920:1080 output-final.avi
|
6
bin/to_utf-8
Executable file
6
bin/to_utf-8
Executable file
|
@ -0,0 +1,6 @@
|
|||
#! /bin/bash
|
||||
|
||||
for i in "*.${1}"; do
|
||||
iconv -f iso-8859-15 -t utf-8 ${i} > ${i}.tmp
|
||||
mv ${i}.tmp ${i}
|
||||
done
|
33
bin/tunnel.sh
Executable file
33
bin/tunnel.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#! /bin/bash
|
||||
|
||||
LOCAL_PORT=6660
|
||||
CLIENT=127.0.0.1
|
||||
REMOTE="-"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--local-port=*)
|
||||
LOCAL_PORT="${1#*=}"
|
||||
;;
|
||||
--remote=*)
|
||||
REMOTE="${1#*=}"
|
||||
;;
|
||||
--client=*)
|
||||
CLIENT="${1#*=}"
|
||||
;;
|
||||
*)
|
||||
printf "Invalid parameter $1"
|
||||
exit 1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "${REMOTE}" = "-" ] ; then
|
||||
printf "Invalid value for --remote="
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REMOTE_SERVER=`echo ${REMOTE}|cut -d: -f1`
|
||||
REMOTE_PORT=`echo ${REMOTE}|cut -d: -f2`
|
||||
|
||||
ssh -L ${LOCAL_PORT}:${CLIENT}:${REMOTE_PORT} ${REMOTE_SERVER}
|
19
bin/umount.sh
Executable file
19
bin/umount.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
# A mettre dans le dossier : /lib/systemd/system-sleep
|
||||
|
||||
PATH=/bin:/usr/bin
|
||||
|
||||
case ${1} in
|
||||
pre)
|
||||
fusermount -u /home/dbroqua/Gdrive
|
||||
fusermount -u /home/dbroqua/S3FS
|
||||
umount -f /media/freebox
|
||||
umount -f /media/malpartida/dbroqua
|
||||
umount -f /media/malpartida/medias
|
||||
umount -f /media/malpartida/family
|
||||
|
||||
;;
|
||||
*)
|
||||
exit ${NA}
|
||||
esac
|
8
bin/update-world.sh
Executable file
8
bin/update-world.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#! /bin/bash
|
||||
|
||||
emerge --sync
|
||||
emaint sync -a
|
||||
|
||||
emerge --ask --verbose --update --changed-use --deep @world
|
||||
|
||||
emerge --ask --verbose --depclean
|
11
bin/wallpaper.sh
Executable file
11
bin/wallpaper.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#! /bin/bash
|
||||
|
||||
# CONFIG
|
||||
DIRECTORY="/home/dbroqua/Nextcloud/images/Wallpaper/Rotation"
|
||||
|
||||
|
||||
|
||||
# SCRIPT START HERE
|
||||
SELECTED=`find ${DIRECTORY} -type f | shuf -n 1`
|
||||
|
||||
feh --bg-fill ${SELECTED}
|
Loading…
Add table
Add a link
Reference in a new issue