mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2025-06-29 12:10:42 +00:00
Remove everything and restart blank
This commit removes all files currently present in the repo, to prepare for a start from a nothing. This is done due to my recent migration from X11 to Wayland, which has rendered most of these config files no longer releveant. I've currently been tracking my dotfiles in a separate repository, in hopes to get it to a state where it would be mergable here, but that turned out to be much more difficult than I anticipated, and I think it will be much easier to simply move over the history from this temporary repository I've been using onto this one. That however requires a start from a clean point, which this commit creates.
This commit is contained in:
parent
eadb37961b
commit
b912871070
206 changed files with 0 additions and 15683 deletions
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null || echo 'ERR')
|
||||
|
||||
if [ "$BTC_DATA" != "ERR" ]; then
|
||||
BTC_PRICE=$(echo $BTC_DATA | jq -r ".bpi.USD.rate_float")
|
||||
BTC_PRICE=$(printf "%.2f" "$BTC_PRICE")
|
||||
echo \$"$BTC_PRICE"
|
||||
else
|
||||
echo "N/A"
|
||||
fi
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
# Parse arguments
|
||||
# ------------------------------------------------------------------------------------
|
||||
BRIGHTNESS_DIR="/sys/class/backlight/*"
|
||||
SEND_NOTIFICATION=0
|
||||
URGENCY="normal"
|
||||
INCREASE=0
|
||||
DECREASE=0
|
||||
SET=0
|
||||
BRIGHTNESS=0
|
||||
|
||||
while [ "$1" ]; do
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
cat << EOF
|
||||
brightness is a cli tool that for displaying or modifying screen brightness.
|
||||
|
||||
Options:
|
||||
-h | --help: Display this message
|
||||
-n | --notification: Produce a desktop notification with brightness info
|
||||
-N | --no-notification: Don't produce a desktop notification with brightness info
|
||||
-u | --urgency [URGENCY]: Pass over notify-send urgency attribute (default: normal)
|
||||
-i | --increase [BRIGHTNESS]: Increase the brightness by given amount
|
||||
-d | --decrease [BRIGHTNESS]: Decrease the brightness by given amount
|
||||
-s | --set [BRIGHTNESS]: Set new brightness level
|
||||
-p | --path [DIR_PATH]: Path to brightness directory (default: /sys/class/backlight/*)
|
||||
|
||||
Valid values:
|
||||
URGENCY: low, normal, critical
|
||||
DIR_PATH: Valid path to a directory
|
||||
BRIGHTNESS:
|
||||
specific value - Example: 10
|
||||
percentage value - Example: 10%
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
-n | --notification)
|
||||
SEND_NOTIFICATION=1
|
||||
;;
|
||||
-N | --no-notification)
|
||||
SEND_NOTIFICATION=0
|
||||
;;
|
||||
-u | --urgency)
|
||||
URGENCY="$2"
|
||||
shift
|
||||
;;
|
||||
-i | --increase)
|
||||
INCREASE=1
|
||||
BRIGHTNESS="$2"
|
||||
shift
|
||||
;;
|
||||
-d | --decrease)
|
||||
DECREASE=1
|
||||
BRIGHTNESS="$2"
|
||||
shift
|
||||
;;
|
||||
-s | --set)
|
||||
SET=1
|
||||
BRIGHTNESS="$2"
|
||||
shift
|
||||
;;
|
||||
-p | --path)
|
||||
BRIGHTNESS_DIR="$2"
|
||||
shift
|
||||
;;
|
||||
* )
|
||||
echo "Unknown argument '$1', use -h or --help for help"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Define constants based on parsed arguments
|
||||
# ------------------------------------------------------------------------------------
|
||||
BRIGHTNESS_FILE="$BRIGHTNESS_DIR/brightness"
|
||||
BRIGHTNESS_MAX="$(cat $BRIGHTNESS_DIR/max_brightness)"
|
||||
|
||||
|
||||
# Helper functins
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
# Send brightness level desktop notification, showing the given brightness level
|
||||
# as progress bar, along with given message.
|
||||
# $1 - brightness level (number 0-100)
|
||||
# $2 - message (notification body)
|
||||
send_brightness_notify() {
|
||||
percent_brightness="$1"
|
||||
msg="$2"
|
||||
|
||||
notify-send \
|
||||
--app-name=brightness \
|
||||
--urgency="$URGENCY" \
|
||||
-h int:value:$percent_brightness \
|
||||
-h string:synchronous:brightness \
|
||||
"brightness" "$msg"
|
||||
}
|
||||
|
||||
|
||||
# Set brightness to given absolute value
|
||||
# $1 - brightness absolute value
|
||||
set_brightness() {
|
||||
# there should be sudo config allowing this command without password
|
||||
echo "$1" | sudo tee $BRIGHTNESS_FILE >/dev/null
|
||||
}
|
||||
|
||||
|
||||
# Main Logic
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
# Determine the absolute new brightness level
|
||||
if [ $INCREASE -eq 1 ] || [ $DECREASE -eq 1 ] || [ $SET -eq 1 ]; then
|
||||
# If we're dealing with percentages, change to absolutes
|
||||
if echo "$BRIGHTNESS" | grep -qE '%$'; then
|
||||
numeric=$(echo "$BRIGHTNESS" | sed 's/.$//')
|
||||
absolute=$(echo "($BRIGHTNESS_MAX / 100) * $numeric" | bc -l)
|
||||
BRIGHTNESS=$(printf "%.0f" $absolute)
|
||||
fi
|
||||
|
||||
# Get the new requested absolute brightness
|
||||
if [ $SET -eq 1 ]; then
|
||||
new_brightness=$BRIGHTNESS
|
||||
elif [ $DECREASE -eq 1 ]; then
|
||||
cur_brightness=$(cat $BRIGHTNESS_FILE)
|
||||
new_brightness=$(($cur_brightness - $BRIGHTNESS))
|
||||
else
|
||||
cur_brightness=$(cat $BRIGHTNESS_FILE)
|
||||
new_brightness=$(($cur_brightness + $BRIGHTNESS))
|
||||
fi
|
||||
|
||||
# Ensure we respect max/min boundaries
|
||||
if [ $new_brightness -lt 0 ]; then
|
||||
new_brightness=0
|
||||
elif [ $new_brightness -gt $BRIGHTNESS_MAX ]; then
|
||||
new_brightness=$BRIGHTNESS_MAX
|
||||
fi
|
||||
|
||||
# Update the brightness
|
||||
set_brightness $new_brightness
|
||||
fi
|
||||
|
||||
cur_brightness=$(cat $BRIGHTNESS_FILE)
|
||||
percent_brightness=$(echo "($cur_brightness / $BRIGHTNESS_MAX) * 100" | bc -l)
|
||||
percent_brightness_2f=$(printf "%.2f" $percent_brightness)
|
||||
percent_brightness_rounded=$(printf "%.0f" $percent_brightness)
|
||||
|
||||
if [ $SEND_NOTIFICATION -eq 1 ]; then
|
||||
send_brightness_notify "$percent_brightness_rounded" "Level: $percent_brightness_rounded"
|
||||
fi
|
||||
|
||||
echo "Brightness: ${percent_brightness_2f}% (absolute: $cur_brightness)"
|
|
@ -1,111 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# rm_trailing_slashes(string)
|
||||
#
|
||||
# Prints a string without any trailing slashes.
|
||||
# This is used because cheat.sh doesn't play nicely with multiple slashes in
|
||||
# URLs.
|
||||
rm_trailing_slashes() {
|
||||
string="$1"
|
||||
last_char="$(printf "$string" | tail -c 1)"
|
||||
if [ "$last_char" = "/" ]; then
|
||||
echo "$(rm_trailing_slashes "${string%?}")"
|
||||
else
|
||||
echo "$string"
|
||||
fi
|
||||
}
|
||||
|
||||
# pick_category(must_match, query, argument, recurse)
|
||||
#
|
||||
# Pick cheat.sh category.
|
||||
# if must_match is 1, only allow listed options to be picked.
|
||||
# if query is specified, pick sub-category of it, else pick global categories.
|
||||
# if argument is specified, optionally perform must_match check and print it.
|
||||
# if recurse is 1, if the selected option ends with /, run the function again.
|
||||
#
|
||||
# Prints the chosen category
|
||||
pick_category() {
|
||||
must_match="$1"
|
||||
query="$(rm_trailing_slashes "$2")"
|
||||
argument="$3"
|
||||
recurse="$4"
|
||||
|
||||
# Query all possible options
|
||||
if [ -n "$query" ]; then
|
||||
url="cheat.sh/$query/:list"
|
||||
else
|
||||
url="cheat.sh/:list"
|
||||
fi
|
||||
selectable="$(curl -s "$url")"
|
||||
|
||||
# If argument is specified, print it, optionally perform must_match check.
|
||||
if [ -n "$argument" ]; then
|
||||
if [ "$must_match" -ne 1 ] || echo "$selectable" | grep -qe "\b$1\b"; then
|
||||
selected="$argument"
|
||||
else
|
||||
echo "Invalid selection: '$argument'"
|
||||
echo "For all selections, query $url"
|
||||
exit 1
|
||||
fi
|
||||
# Select the option with fzf, optionally allow other matches if must_match isn't set.
|
||||
else
|
||||
if [ "$must_match" -ne 1 ]; then
|
||||
if [ -z "$selectable" ]; then
|
||||
header="No selections found, you can use empty query to show category help, or type a custom query."
|
||||
else
|
||||
header="Use alt-enter to enter non-listed query. You can use empty queries to show category help."
|
||||
fi
|
||||
selected="$(printf "\n$selectable" | \
|
||||
fzf --bind=alt-enter:print-query \
|
||||
--print-query \
|
||||
--prompt="cheat.sh/$query query>" \
|
||||
--header="$header"\
|
||||
)"
|
||||
else
|
||||
selected=$(printf "$selectable" | fzf --prompt="cheat.sh/$query category>")
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Invalid selection: '$selected'"
|
||||
echo "For all selections, query $url"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
selected=$(printf "$selected" | tail -1)
|
||||
fi
|
||||
|
||||
|
||||
# Replace spaces with '+' (cheat.sh resolves those as spaces)
|
||||
selected="$(echo "$selected" | tr ' ' '+')"
|
||||
|
||||
# Prepend the original query, if we have one
|
||||
# Print the selected category, or subcategory with the category
|
||||
if [ -n "$query" ]; then
|
||||
result="$query/$selected"
|
||||
else
|
||||
result="$selected"
|
||||
fi
|
||||
|
||||
# Recurse, if specified and the result ended with /
|
||||
if [ "$recurse" -eq 1 ]; then
|
||||
if [ "$(printf "$selected" | tail -c 1)" = "/" ]; then
|
||||
result="$(pick_category "$must_match" "$result" "$argument" 1)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Print the result
|
||||
printf "$result"
|
||||
}
|
||||
|
||||
# Select the cheatsheat category (language/core-util/...)
|
||||
query=$(pick_category 1 "" "$1" 0)
|
||||
|
||||
# If the query isn't already complete, select a sub-category
|
||||
if ! echo "$query" | grep -qe ":"; then
|
||||
query="$(pick_category 0 "$query" "$2" 1)"
|
||||
fi
|
||||
|
||||
# Construct the URL from given query and print it
|
||||
url="cheat.sh/$query"
|
||||
echo "$url"
|
||||
|
||||
# Show the output of cheat.sh request
|
||||
curl -s "$url"
|
|
@ -1,102 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# # Print out 256 colors, with each number printed in its corresponding colour
|
||||
#
|
||||
# This file is uploaded on <https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/>
|
||||
# It was originally intended to be used as an alias that curled this URL and piped it into bash, however
|
||||
# this is very unsafe as the owner can change the content of this gist at his convenience, meaning it was
|
||||
# a potential security vulnerability. This is a script version of this alias to avoid this issue.
|
||||
#
|
||||
# The copyright for this file belongs to the original author: Tom Hale, 2016
|
||||
# This file was released under MIT license
|
||||
|
||||
set -eu # Fail on errors or undeclared variables
|
||||
|
||||
printable_colours=256
|
||||
|
||||
# Return a colour that contrasts with the given colour
|
||||
# Bash only does integer division, so keep it integral
|
||||
function contrast_colour {
|
||||
local r g b luminance
|
||||
colour="$1"
|
||||
|
||||
if (( colour < 16 )); then # Initial 16 ANSI colours
|
||||
(( colour == 0 )) && printf "15" || printf "0"
|
||||
return
|
||||
fi
|
||||
|
||||
# Greyscale # rgb_R = rgb_G = rgb_B = (number - 232) * 10 + 8
|
||||
if (( colour > 231 )); then # Greyscale ramp
|
||||
(( colour < 244 )) && printf "15" || printf "0"
|
||||
return
|
||||
fi
|
||||
|
||||
# All other colours:
|
||||
# 6x6x6 colour cube = 16 + 36*R + 6*G + B # Where RGB are [0..5]
|
||||
# See http://stackoverflow.com/a/27165165/5353461
|
||||
|
||||
# r=$(( (colour-16) / 36 ))
|
||||
g=$(( ((colour-16) % 36) / 6 ))
|
||||
# b=$(( (colour-16) % 6 ))
|
||||
|
||||
# If luminance is bright, print number in black, white otherwise.
|
||||
# Green contributes 587/1000 to human perceived luminance - ITU R-REC-BT.601
|
||||
(( g > 2)) && printf "0" || printf "15"
|
||||
return
|
||||
|
||||
# Uncomment the below for more precise luminance calculations
|
||||
|
||||
# # Calculate percieved brightness
|
||||
# # See https://www.w3.org/TR/AERT#color-contrast
|
||||
# # and http://www.itu.int/rec/R-REC-BT.601
|
||||
# # Luminance is in range 0..5000 as each value is 0..5
|
||||
# luminance=$(( (r * 299) + (g * 587) + (b * 114) ))
|
||||
# (( $luminance > 2500 )) && printf "0" || printf "15"
|
||||
}
|
||||
|
||||
# Print a coloured block with the number of that colour
|
||||
function print_colour {
|
||||
local colour="$1" contrast
|
||||
contrast=$(contrast_colour "$1")
|
||||
printf "\e[48;5;%sm" "$colour" # Start block of colour
|
||||
printf "\e[38;5;%sm%3d" "$contrast" "$colour" # In contrast, print number
|
||||
printf "\e[0m " # Reset colour
|
||||
}
|
||||
|
||||
# Starting at $1, print a run of $2 colours
|
||||
function print_run {
|
||||
local i
|
||||
for (( i = "$1"; i < "$1" + "$2" && i < printable_colours; i++ )) do
|
||||
print_colour "$i"
|
||||
done
|
||||
printf " "
|
||||
}
|
||||
|
||||
# Print blocks of colours
|
||||
function print_blocks {
|
||||
local start="$1" i
|
||||
local end="$2" # inclusive
|
||||
local block_cols="$3"
|
||||
local block_rows="$4"
|
||||
local blocks_per_line="$5"
|
||||
local block_length=$((block_cols * block_rows))
|
||||
|
||||
# Print sets of blocks
|
||||
for (( i = start; i <= end; i += (blocks_per_line-1) * block_length )) do
|
||||
printf "\n" # Space before each set of blocks
|
||||
# For each block row
|
||||
for (( row = 0; row < block_rows; row++ )) do
|
||||
# Print block columns for all blocks on the line
|
||||
for (( block = 0; block < blocks_per_line; block++ )) do
|
||||
print_run $(( i + (block * block_length) )) "$block_cols"
|
||||
done
|
||||
(( i += block_cols )) # Prepare to print the next row
|
||||
printf "\n"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
print_run 0 16 # The first 16 colours are spread over the whole spectrum
|
||||
printf "\n"
|
||||
print_blocks 16 231 6 6 3 # 6x6x6 colour cube between 16 and 231 inclusive
|
||||
print_blocks 232 255 12 2 1 # Not 50, but 24 Shades of Grey
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Compile given file
|
||||
|
||||
file=$(readlink -f "$1")
|
||||
base="$(dirname "$file")/$(basename "$file" | sed 's/\..*//')"
|
||||
|
||||
case "$file" in
|
||||
*.md) pandoc --filter pandoc-crossref "$file" -o "$base".pdf ;;
|
||||
*.asm) nasm -f elf64 "$file" -o "$base".o && ld "$base".o -o "$base" ;;
|
||||
*.c) gcc "$file" -o "$base" ;;
|
||||
*.cpp) g++ "$file" -o "$base" ;;
|
||||
*) echo "Can't compile!" && exit 1 ;;
|
||||
esac
|
|
@ -1,11 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Find the line with exec, if there's multiple lines
|
||||
# use the last one
|
||||
exec_line=$(grep '^Exec' "$1" | tail -1)
|
||||
# Remove 'Exec' and arguments (%u, %f, ...)
|
||||
cmd=$(echo $exec_line | sed 's/^Exec=//' | sed 's/%.//')
|
||||
# Remove "" around command (if present)
|
||||
cmd=$(echo $cmd | sed 's/^"//g' | sed 's/" *$//g')
|
||||
# Run the exec line of the application using /bin/sh
|
||||
/bin/sh -c "$cmd"
|
|
@ -1,82 +0,0 @@
|
|||
|
||||
#!/bin/sh
|
||||
|
||||
# A UI for detecting and selecting all displays. Probes xrandr for connected
|
||||
# displays and lets user select one to use. User may also select "manual
|
||||
# selection" which opens arandr.
|
||||
|
||||
twoscreen() { # If multi-monitor is selected and there are two screens.
|
||||
|
||||
mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?")
|
||||
# Mirror displays using native resolution of external display and a scaled
|
||||
# version for the internal display
|
||||
if [ "$mirror" = "yes" ]; then
|
||||
external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
|
||||
internal=$(echo "$screens" | grep -v "$external")
|
||||
|
||||
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
|
||||
tail -n 1 | awk '{print $1}')
|
||||
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
|
||||
tail -n 1 | awk '{print $1}')
|
||||
|
||||
res_ext_x=$(echo "$res_external" | sed 's/x.*//')
|
||||
res_ext_y=$(echo "$res_external" | sed 's/.*x//')
|
||||
res_int_x=$(echo "$res_internal" | sed 's/x.*//')
|
||||
res_int_y=$(echo "$res_internal" | sed 's/.*x//')
|
||||
|
||||
scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l)
|
||||
scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l)
|
||||
|
||||
xrandr --output "$external" --auto --scale 1.0x1.0 \
|
||||
--output "$internal" --auto --same-as "$external" \
|
||||
--scale "$scale_x"x"$scale_y"
|
||||
else
|
||||
|
||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||
secondary=$(echo "$screens" | grep -v "$primary")
|
||||
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
|
||||
fi
|
||||
}
|
||||
|
||||
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
|
||||
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||
tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
|
||||
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
|
||||
}
|
||||
|
||||
multimon() { # Multi-monitor handler.
|
||||
case "$(echo "$screens" | wc -l)" in
|
||||
2) twoscreen ;;
|
||||
*) morescreen ;;
|
||||
esac ;}
|
||||
|
||||
onescreen() { # If only one output available or chosen.
|
||||
xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -)
|
||||
}
|
||||
|
||||
postrun() { # Stuff to run to clean up.
|
||||
command -v setbg >/dev/null && setbg # Fix background if screen size/arangement has changed.
|
||||
}
|
||||
|
||||
# Get all possible displays
|
||||
allposs=$(xrandr -q | grep "connected")
|
||||
|
||||
# Get all connected screens.
|
||||
screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
|
||||
|
||||
# If there's only one screen
|
||||
[ "$(echo "$screens" | wc -l)" -lt 2 ] &&
|
||||
{ onescreen "$screens"; postrun; notify-send "💻 Only one screen detected." "Using it in its optimal settings..."; exit ;}
|
||||
|
||||
# Get user choice including multi-monitor and manual selection:
|
||||
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
|
||||
case "$chosen" in
|
||||
"manual selection") arandr ; exit ;;
|
||||
"multi-monitor") multimon ;;
|
||||
*) onescreen "$chosen" ;;
|
||||
esac
|
||||
|
||||
postrun
|
|
@ -1,68 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Gives dmenu prompt to mount unmounted drives and Android phones.
|
||||
# If they're in /etc/fstab they'll be mounted automatically.
|
||||
# Otherwise, you'll be prompted to give a mountpoint from already
|
||||
# existing directories. If you input a novel directory, it will
|
||||
# prompt you to create that directory.
|
||||
|
||||
getmount() { \
|
||||
[ -z "$chosen" ] && exit 1
|
||||
# shellcheck disable=SC2086
|
||||
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
|
||||
test -z "$mp" && exit 1
|
||||
if [ ! -d "$mp" ]; then
|
||||
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
|
||||
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
|
||||
fi
|
||||
}
|
||||
|
||||
mountusb() { \
|
||||
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
|
||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
||||
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
|
||||
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
|
||||
partitiontype="$(lsblk -no "fstype" "$chosen")"
|
||||
case "$partitiontype" in
|
||||
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
|
||||
"exfat") sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)";;
|
||||
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
|
||||
esac
|
||||
notify-send "💻 USB mounting" "$chosen mounted to $mp."
|
||||
}
|
||||
|
||||
mountandroid() { \
|
||||
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
|
||||
chosen="$(echo "$chosen" | cut -d : -f 1)"
|
||||
getmount "$HOME -maxdepth 3 -type d"
|
||||
simple-mtpfs --device "$chosen" "$mp"
|
||||
echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
|
||||
simple-mtpfs --device "$chosen" "$mp"
|
||||
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
|
||||
}
|
||||
|
||||
asktype() { \
|
||||
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1
|
||||
case $choice in
|
||||
USB) mountusb ;;
|
||||
Android) mountandroid ;;
|
||||
esac
|
||||
}
|
||||
|
||||
anddrives=$(simple-mtpfs -l 2>/dev/null)
|
||||
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
|
||||
|
||||
if [ -z "$usbdrives" ]; then
|
||||
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
|
||||
echo "Android device(s) detected."
|
||||
mountandroid
|
||||
else
|
||||
if [ -z "$anddrives" ]; then
|
||||
echo "USB drive(s) detected."
|
||||
mountusb
|
||||
else
|
||||
echo "Mountable USB drive(s) and Android device(s) detected."
|
||||
asktype
|
||||
fi
|
||||
fi
|
|
@ -1,6 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script is the value for SUDO_ASKPASS variable,
|
||||
# meaning that it will be used as a password prompt if needed.
|
||||
|
||||
dmenu -P -p "$1"
|
|
@ -1,121 +0,0 @@
|
|||
|
||||
#!/bin/sh
|
||||
|
||||
# Usage:
|
||||
# `$0`: Ask for recording type via dmenu
|
||||
# `$0 screencast`: Record both audio and screen
|
||||
# `$0 video`: Record only screen
|
||||
# `$0 audio`: Record only audio
|
||||
# `$0 kill`: Kill existing recording
|
||||
#
|
||||
# If there is already a running instance, user will be prompted to end it.
|
||||
|
||||
screencast() {
|
||||
ffmpeg -y \
|
||||
-f x11grab \
|
||||
-framerate 60 \
|
||||
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
|
||||
-i "$DISPLAY" \
|
||||
-f alsa -i default \
|
||||
-r 30 \
|
||||
-c:v h264 -crf 0 -preset ultrafast -c:a aac \
|
||||
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
|
||||
echo $! > /tmp/recordingpid
|
||||
}
|
||||
|
||||
video() {
|
||||
ffmpeg \
|
||||
-f x11grab \
|
||||
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
|
||||
-i "$DISPLAY" \
|
||||
-c:v libx264 -qp 0 -r 30 \
|
||||
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
}
|
||||
|
||||
webcamhidef() {
|
||||
ffmpeg \
|
||||
-f v4l2 \
|
||||
-i /dev/video0 \
|
||||
-video_size 1920x1080 \
|
||||
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
}
|
||||
|
||||
webcam() {
|
||||
ffmpeg \
|
||||
-f v4l2 \
|
||||
-i /dev/video0 \
|
||||
-video_size 640x480 \
|
||||
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
}
|
||||
|
||||
|
||||
audio() {
|
||||
ffmpeg \
|
||||
-f alsa -i default \
|
||||
"$HOME/audio-$(date '+%y%m%d-%H%M-%S').mp3" &
|
||||
echo $! > /tmp/recordingpid
|
||||
}
|
||||
|
||||
asktoend() {
|
||||
response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
|
||||
[ "$response" = "Yes" ] && killrecording
|
||||
}
|
||||
|
||||
videoselected()
|
||||
{
|
||||
slop -f "%x %y %w %h" > /tmp/slop
|
||||
read -r X Y W H < /tmp/slop
|
||||
rm /tmp/slop
|
||||
|
||||
ffmpeg \
|
||||
-f x11grab \
|
||||
-framerate 60 \
|
||||
-video_size "$W"x"$H" \
|
||||
-i :0.0+"$X,$Y" \
|
||||
-c:v libx264 -qp 0 -r 30 \
|
||||
"$HOME/box-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
}
|
||||
|
||||
killrecording() {
|
||||
recpid="$(cat /tmp/recordingpid)"
|
||||
# kill with SIGTERM, allowing finishing touches.
|
||||
kill -15 "$recpid" 2>/dev/null
|
||||
rm -f /tmp/recordingpid
|
||||
# even after SIGTERM, ffmpeg may still run, so SIGKILL it.
|
||||
sleep 3
|
||||
kill -9 "$recpid" 2>/dev/null
|
||||
exit
|
||||
}
|
||||
|
||||
askrecording() { \
|
||||
choice=$(printf "screencast\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:")
|
||||
case "$choice" in
|
||||
screencast) screencast;;
|
||||
audio) audio;;
|
||||
video) video;;
|
||||
*selected) videoselected;;
|
||||
webcam) webcam;;
|
||||
"webcam (hi-def)") webcamhidef;;
|
||||
esac
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
screencast) screencast;;
|
||||
audio) audio;;
|
||||
video) video;;
|
||||
*selected) videoselected;;
|
||||
kill) killrecording;;
|
||||
*)
|
||||
if [ -f /tmp/recordingpid ]; then
|
||||
recpid="$(cat /tmp/recordingpid)"
|
||||
if ps -p $recpid > /dev/null; then
|
||||
asktoend
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
askrecording;;
|
||||
esac
|
|
@ -1,44 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# A dmenu prompt to unmount drives.
|
||||
# Provides you with mounted partitions, select one to unmount.
|
||||
# Drives mounted at /, /boot and /home will not be options to unmount.
|
||||
|
||||
unmountusb() {
|
||||
[ -z "$drives" ] && exit
|
||||
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
|
||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||
[ -z "$chosen" ] && exit
|
||||
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
|
||||
}
|
||||
|
||||
unmountandroid() { \
|
||||
chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1
|
||||
[ -z "$chosen" ] && exit
|
||||
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
|
||||
}
|
||||
|
||||
asktype() { \
|
||||
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" || exit 1
|
||||
case "$choice" in
|
||||
USB) unmountusb ;;
|
||||
Android) unmountandroid ;;
|
||||
esac
|
||||
}
|
||||
|
||||
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
|
||||
|
||||
if ! grep simple-mtpfs /etc/mtab; then
|
||||
[ -z "$drives" ] && echo "No drives to unmount." && exit
|
||||
echo "Unmountable USB drive detected."
|
||||
unmountusb
|
||||
else
|
||||
if [ -z "$drives" ]
|
||||
then
|
||||
echo "Unmountable Android device detected."
|
||||
unmountandroid
|
||||
else
|
||||
echo "Unmountable USB drive(s) and Android device(s) detected."
|
||||
asktype
|
||||
fi
|
||||
fi
|
|
@ -1,36 +0,0 @@
|
|||
#!/bin/sh
|
||||
# This is inspired by dmenu's todo script made by suckless
|
||||
#
|
||||
# Manage TODO tasks in dmenu by writing them, remove by selecting
|
||||
# an existing entry
|
||||
#
|
||||
# Configurable variables
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
FILE="${XDG_DATA_HOME:-$HOME/.local/share}/todos"
|
||||
PROMPT="Add/delete a task: "
|
||||
|
||||
# Logic
|
||||
# ---------------------------------------------------------------------
|
||||
mkdir -p "$(dirname $FILE)"
|
||||
touch "$FILE"
|
||||
|
||||
height=$(wc -l "$FILE" | awk '{print $1}')
|
||||
|
||||
# Run dmenu and keep restarting it until it returns an empty output
|
||||
cmd=$(dmenu -l "$height" -p "$PROMPT" "$@" < "$FILE")
|
||||
while [ -n "$cmd" ]; do
|
||||
# If the output matched an existing TODO, remove it
|
||||
if grep -q "^$cmd\$" "$FILE"; then
|
||||
grep -v "^$cmd\$" "$FILE" > "$FILE.$$"
|
||||
mv "$FILE.$$" "$FILE"
|
||||
height=$(( height - 1 ))
|
||||
# If the output didn't match an existing TODO, it's a new one, add it
|
||||
else
|
||||
echo "$cmd" >> "$FILE"
|
||||
height=$(( height + 1 ))
|
||||
fi
|
||||
|
||||
# Keep restarting until empty output
|
||||
cmd=$(dmenu -l "$height" -p "$PROMPT" "$@" < "$FILE")
|
||||
done
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
import feedparser
|
||||
import subprocess
|
||||
|
||||
|
||||
URL = "https://itsdrike.com/posts/index.xml"
|
||||
|
||||
|
||||
def main():
|
||||
feed = feedparser.parse(URL)
|
||||
titles = {entry['title']: entry['link'] for entry in feed['entries']}
|
||||
|
||||
selected_page = subprocess.check_output(
|
||||
["dmenu", "-i", "-p", "Post"],
|
||||
input="\n".join(titles.keys()), universal_newlines=True
|
||||
)
|
||||
link = titles[selected_page.strip()]
|
||||
|
||||
subprocess.check_output(["xsel", "-bi"], input=link, universal_newlines=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,119 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class CompiledPackage:
|
||||
name: str
|
||||
date: datetime
|
||||
compile_time: int
|
||||
|
||||
def __repr__(self) -> str:
|
||||
name = self.name
|
||||
date = self.date.strftime("%a %b %d %H:%M:%S %Y")
|
||||
compile_time = get_readable_duration(self.compile_time)
|
||||
return f"CompiledPackage({name=}, {date=}, {compile_time=})"
|
||||
|
||||
|
||||
def parse_time(time_line: str) -> int:
|
||||
"""Parse a line that contains time info, return seconds"""
|
||||
time = 0
|
||||
words = time_line.split()
|
||||
|
||||
if "hour" in words[1]:
|
||||
time += int(words[0]) * 60 * 60
|
||||
elif "minute" in words[1]:
|
||||
time += int(words[0]) * 60
|
||||
elif "second" in words[1]:
|
||||
time += int(words[0])
|
||||
|
||||
try:
|
||||
if "second" in words[3]:
|
||||
time += int(words[2])
|
||||
elif "minute" in words[3]:
|
||||
time += int(words[2]) * 60
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
return time
|
||||
|
||||
|
||||
def get_readable_duration(total_seconds: int) -> str:
|
||||
"""Get readable time duration string from total seconds"""
|
||||
hours, rem = divmod(total_seconds, 3600)
|
||||
minutes, rem = divmod(rem, 60)
|
||||
seconds = rem
|
||||
|
||||
output = []
|
||||
if hours > 0:
|
||||
output.append(f"{hours} hour{'s' if hours > 1 else ''}")
|
||||
if minutes > 0:
|
||||
output.append(f"{minutes} minute{'s' if minutes > 1 else ''}")
|
||||
if seconds > 0:
|
||||
output.append(f"{seconds} second{'s' if seconds > 1 else ''}")
|
||||
|
||||
if len(output) > 1:
|
||||
output.insert(-1, "and")
|
||||
|
||||
return " ".join(output)
|
||||
|
||||
|
||||
def get_packages() -> list[CompiledPackage]:
|
||||
"""Obtain compilation times for every compiled package"""
|
||||
x = subprocess.run(
|
||||
"sudo genlop -nlt",
|
||||
stdout=subprocess.PIPE,
|
||||
shell=True
|
||||
)
|
||||
txt = x.stdout.decode("utf-8")
|
||||
|
||||
# Cleanup the output
|
||||
txt = txt.replace("* packages merged:\n\n", "")
|
||||
txt = txt.replace("merge time: ", "")
|
||||
txt = txt.replace("and ", "")
|
||||
txt = txt.replace(".", "")
|
||||
|
||||
# Remove indents
|
||||
clean_lines = [line.lstrip() for line in txt.split("\n")]
|
||||
txt = "\n".join(clean_lines)
|
||||
|
||||
# Store (package name, date, compile time) for each package
|
||||
packages = []
|
||||
for pkg_txt in txt.split("\n\n"):
|
||||
if len(pkg_txt) == 0:
|
||||
continue
|
||||
|
||||
pkg_lines = pkg_txt.split("\n")
|
||||
|
||||
date, name = pkg_lines[0].split(" >>> ")
|
||||
time = parse_time(pkg_lines[1])
|
||||
date = datetime.strptime(date, "%a %b %d %H:%M:%S %Y")
|
||||
|
||||
pkg = CompiledPackage(name, date, time)
|
||||
packages.append(pkg)
|
||||
|
||||
return packages
|
||||
|
||||
|
||||
def get_compile_time(package_amount: int) -> int:
|
||||
"""Get compilation time of last n specified packages (seconds)"""
|
||||
packages = get_packages()
|
||||
last_packages = packages[-package_amount:]
|
||||
return sum(package.compile_time for package in last_packages)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
package_amt = int(sys.argv[1])
|
||||
except IndexError:
|
||||
print("Missing required argument: package amount")
|
||||
except TypeError:
|
||||
print("Argument must be a number (package amount)")
|
||||
else:
|
||||
time = get_compile_time(package_amt)
|
||||
print(get_readable_duration(time))
|
||||
|
|
@ -1,299 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Parse arguments
|
||||
# ------------------------------------------------------------------------------------
|
||||
ALL=0
|
||||
VERBOSE=0
|
||||
VERY_VERBOSE=0
|
||||
VERY_VERY_VERBOSE=0
|
||||
TEMP_SHOW=0
|
||||
DRY_RUN=0
|
||||
NO_CACHE=0
|
||||
NO_DISPLAY=0
|
||||
URGENCY="normal"
|
||||
RESET=0
|
||||
while [ "$1" ]; do
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
cat << EOF
|
||||
gh-notification is a tool that scrapes unread github notifications
|
||||
It uses github-cli with meiji163/gh-notify addon to obtain the unread notifications
|
||||
these are then parsed and sent as desktop notifications with notify-send
|
||||
|
||||
Options:
|
||||
-a | --all: Also process already read notifications
|
||||
-t | --temp-files: Show names of used temporary files for each notification
|
||||
-v | --verbose: Shows info about what's happening.
|
||||
-vv | --very-verbose: Implies --verbose, shows some more info about what's happening
|
||||
-vvv | --very-very-verbose: Implies --very-verbose and --temp-files, shows even more details, usually just for debugging
|
||||
-d | --dry-run: Run without sending any notificatinos, when ran with -r, this will also prevent any actual cache file removals
|
||||
-nc | --no-cache: Ignore the cache and send all found notifications, even if they were already sent before.
|
||||
-nd | --no-display: When the script is ran from headless mode (such as by crontab), this will still attempt to set the DISPLAY and send the desktop notification
|
||||
-r | --reset: Resets notification cache (storing which notifications were already sent), skips notification sending, WARNING: removes the whole cache, regardless of '--all')
|
||||
-u | --urgency [urgency-level]: pass over notify-send urgency attribute (low, normal, critical)
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
-a | --all)
|
||||
ALL=1
|
||||
;;
|
||||
-t | --temp-files)
|
||||
TEMP_SHOW=1
|
||||
;;
|
||||
-v | --verbose)
|
||||
VERBOSE=1
|
||||
;;
|
||||
-vv | --very-verbose)
|
||||
VERBOSE=1
|
||||
VERY_VERBOSE=1
|
||||
;;
|
||||
-vvv | --very-very-verbose)
|
||||
VERBOSE=1
|
||||
TEMP_SHOW=1
|
||||
VERY_VERBOSE=1
|
||||
VERY_VERY_VERBOSE=1
|
||||
;;
|
||||
-d | --dry-run)
|
||||
DRY_RUN=1
|
||||
;;
|
||||
-nc | --no-cache)
|
||||
NO_CACHE=1
|
||||
;;
|
||||
-nd | --no-display)
|
||||
NO_DISPLAY=1
|
||||
;;
|
||||
-u | --urgency)
|
||||
URGENCY="$2"
|
||||
shift
|
||||
;;
|
||||
-r | --reset)
|
||||
RESET=1
|
||||
;;
|
||||
* )
|
||||
echo "Unknown argument '$1', use -h or --help for help"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
# Perform cache resetting, if requested
|
||||
# ------------------------------------------------------------------------------------
|
||||
if [ $RESET -eq 1 ]; then
|
||||
if [ $NO_CACHE -eq 1 ]; then
|
||||
echo "Can't ignore cache when resetting the cache..."
|
||||
exit 1
|
||||
fi
|
||||
out="$(find /tmp -maxdepth 1 -name 'gh-notification-*' 2>/dev/null)"
|
||||
total="$(printf "%s\n" "$out" | wc -l)"
|
||||
# Since we always end with a newline (to count the last entry as a line), we always get
|
||||
# at least 1 as a total here, even if $out is empty. If we didn't use the \n, we'd always
|
||||
# get 0, even if there was a single line, since it wasn't ended with a newline. To figure
|
||||
# out whether there really is a line or not when we get a total of 1, we run character
|
||||
# amount check as well
|
||||
[ "$total" -eq 1 ] && [ "$(printf "%s" "$out" | wc -c)" -eq 0 ] && total=0
|
||||
|
||||
if [ $total -gt 0 ]; then
|
||||
# Since the loop is running in a pipe, it can't modify variables, but we need to know
|
||||
# which files have failed to be removed, so to get that information, we store it in a
|
||||
# teporary file
|
||||
fail_files_file="$(mktemp)"
|
||||
|
||||
printf "%s\n" "$out" | while read -r file_name; do
|
||||
# If desired, let user know about the found notification cache file
|
||||
if [ $VERY_VERBOSE -eq 1 ] || [ $TEMP_SHOW -eq 1 ]; then
|
||||
contents="$(cat "$file_name")"
|
||||
title="$(printf "%s" "$contents" | awk -F '~@~' '{ print $1 }')"
|
||||
|
||||
echo "Found cache tempfile: '$file_name' - $title"
|
||||
if [ $VERY_VERY_VERBOSE -eq 1 ]; then
|
||||
description="$(printf "%s" "$contents" | awk -F '~@~' '{ print $2 }')"
|
||||
echo "Notification description: $description"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $DRY_RUN -ne 1 ]; then
|
||||
# In case `rm` fails, keep track of which files it failed on
|
||||
if ! rm "$file_name" 2>/dev/null; then
|
||||
printf "%s\n" "$file_name" >> "$fail_files_file"
|
||||
fi
|
||||
else
|
||||
[ $VERY_VERY_VERBOSE -eq 1 ] && echo "Tempfile removal skipped (dry-run)"
|
||||
fi
|
||||
|
||||
# Add a new-line separator on very very verbose to group prints from each iteration
|
||||
[ $VERY_VERY_VERBOSE -eq 1 ] && echo ""
|
||||
done
|
||||
|
||||
# Recover failed files from the temporary file
|
||||
failed_files="$(cat "$fail_files_file")"
|
||||
failed="$(printf "%s" "$fail_files_file" | wc -l)"
|
||||
rm "$fail_files_file"
|
||||
|
||||
if [ $VERBOSE -eq 1 ]; then
|
||||
echo "Notification cache was reset."
|
||||
removed_count="$(("$total"-"$failed"))"
|
||||
if [ $DRY_RUN -eq 1 ]; then
|
||||
echo "Removed $removed_count files (dry-run: no files were actually removed)"
|
||||
else
|
||||
echo "Removed $removed_count files"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If some cache files were'nt removed successfully, inform the user about it
|
||||
# regardless of verbosity, this shouldn't go silent, even though it may be fine
|
||||
if [ "$failed" -gt 0 ]; then
|
||||
echo "WARNING: Failed to remove $failed files."
|
||||
echo "You probably don't have permission to remove these."
|
||||
echo "Perhaps these were made by someone else? If so, you can ignore this warning."
|
||||
if [ $VERBOSE -eq 0 ]; then
|
||||
echo "Run with --verbose to show exactly which files weren't removed."
|
||||
else
|
||||
echo "These are:"
|
||||
echo "$failed_files"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
[ $VERBOSE -eq 1 ] && echo "No cache files found, nothing to reset"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# Helper functins
|
||||
# ------------------------------------------------------------------------------------
|
||||
# This runs notify-send, and if NO_DISPLAY is set and we're running in headless
|
||||
# mode, this will still try to send the notification by manually setting DISPLAY
|
||||
# This also has a special handle that checks if dunst is the notification daemon
|
||||
# in which case instead of using notify-send, we use dunstify to send the
|
||||
# notification, with which we can also specify some more values.
|
||||
send_notify() {
|
||||
if [ $NO_DISPLAY -eq 1 ]; then
|
||||
XDG_RUNTIME_DIR="/run/user/$(id -u)" \
|
||||
DISPLAY=:0 \
|
||||
notify-send --app-name=github-notification --urgency="$URGENCY" "$1" "$2"
|
||||
else
|
||||
notify-send --app-name=github-notification --urgency="$URGENCY" "$1" "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Obtain notifications and show them, if they weren't showed (aren't in cache) already
|
||||
# ------------------------------------------------------------------------------------
|
||||
# Request unread notifications with gh-notify extension for github-cli
|
||||
[ "$ALL" -eq 1 ] && out="$(gh notify -s -a)" || out="$(gh notify -s)"
|
||||
total="$(printf "%s\n" "$out" | wc -l)"
|
||||
# Since we always end with a newline (to count the last entry as a line), we always get
|
||||
# at least 1 as a total here, even if $out is empty. If we didn't use the \n, we'd always
|
||||
# get 0, even if there was a single line, since it wasn't ended with a newline. To figure
|
||||
# out whether there really is a line or not when we get a total of 1, we run character
|
||||
# amount check as well
|
||||
[ "$total" -eq 1 ] && [ "$(printf "%s" "$out" | wc -c)" -eq 0 ] && total=0
|
||||
|
||||
# Only run if we actually found some notifications
|
||||
if [ "$total" -gt 0 ]; then
|
||||
# Since the loop is running in a pipe, it can't modify variables, but we need to know
|
||||
# how many notifications were sent, so to ge that information, we store it in a
|
||||
# temporary file
|
||||
sent_count_file="$(mktemp)"
|
||||
printf "0" > "$sent_count_file"
|
||||
|
||||
# Go through each notification, one by one
|
||||
printf "%s\n" "$out" | while read -r line; do
|
||||
# Parse out the data from given output lines
|
||||
issue_type="$(echo "$line" | awk '{print $4}' | sed 's/\x1b\[[0-9;]*m//g')"
|
||||
repo_id="$(echo "$line" | awk '{print $3}' | sed 's/\x1b\[[0-9;]*m//g')"
|
||||
|
||||
|
||||
if [ "$issue_type" == "PullRequest" ]; then
|
||||
issue_id="$(echo "$line" | awk '{print $5}' | sed 's/\x1b\[[0-9;]*m//g' | cut -c2-)"
|
||||
description="$(echo "$line" | awk '{for (i=6; i<NF; i++) printf $i " "; print $NF}' | sed 's/\x1b\[[0-9;]*m//g')"
|
||||
name="$repo_id ($issue_type #$issue_id)"
|
||||
|
||||
url="https://github.com/$repo_id/pull/$issue_id"
|
||||
elif [ "$issue_type" == "Issue" ]; then
|
||||
issue_id="$(echo "$line" | awk '{print $5}' | sed 's/\x1b\[[0-9;]*m//g' | cut -c2-)"
|
||||
description="$(echo "$line" | awk '{for (i=6; i<NF; i++) printf $i " "; print $NF}' | sed 's/\x1b\[[0-9;]*m//g')"
|
||||
name="$repo_id ($issue_type #$issue_id)"
|
||||
|
||||
url="https://github.com/$repo_id/issues/$issue_id"
|
||||
elif [ "$issue_type" == "Release" ]; then
|
||||
# There's no issue ID with github releases, they just have a title
|
||||
# this means if the name is the same, they will be treated as the same release
|
||||
# and they could end up being ignored, this could be fixed by using github API and
|
||||
# searching for that release's commit, but that's too much work here for little benefit
|
||||
description="$(echo "$line" | awk '{for (i=5; i<NF; i++) printf $i " "; print $NF}' | sed 's/\x1b\[[0-9;]*m//g')"
|
||||
name="$repo_id ($issue_type)"
|
||||
|
||||
# Because we don't know the tag or commit ID, best we can do is use the page for all releases
|
||||
# the new release will be the first one there anyway
|
||||
url="https://github.com/$repo_id/releases"
|
||||
else
|
||||
echo "Unknown issue type: '$issue_type'!"
|
||||
echo "Can't construct URL, falling back to just repository URL."
|
||||
echo "Please report this issue to ItsDrike/dotfiles repository."
|
||||
url="https://github.com/$repo_id"
|
||||
fi
|
||||
|
||||
[ $VERY_VERBOSE -eq 1 ] && echo "Found notification $name"
|
||||
[ $VERY_VERY_VERBOSE -eq 1 ] && echo "Description: $description"
|
||||
[ $VERY_VERY_VERBOSE -eq 1 ] && echo "Constructed url: $url"
|
||||
|
||||
# Create hash from the name and description and use it to construct
|
||||
# a path to a temporary file
|
||||
# To keep this POSIX compliant, we can't use <<< to feed a string to the
|
||||
# sum function, so we're using another temporary file which is then removed
|
||||
temp_file="$(mktemp)"
|
||||
printf "$name$description" > "$temp_file"
|
||||
hashsum="$(sum < "$temp_file" | cut -f 1 -d ' ')"
|
||||
rm "$temp_file"
|
||||
|
||||
tmpname="/tmp/gh-notification-$hashsum"
|
||||
[ $TEMP_SHOW -eq 1 ] && echo "Tempfile: $tmpname"
|
||||
|
||||
# If the temporary file is already present, this notification was already
|
||||
# send and we don't want to re-send it
|
||||
|
||||
# Only sent the notification if it wasn't already cached (doesn't have temp file)
|
||||
# this avoids resending the same notifications
|
||||
if [ ! -e "$tmpname" ] || [ $NO_CACHE -eq 1 ]; then
|
||||
if [ $DRY_RUN -eq 1 ]; then
|
||||
[ $VERY_VERBOSE -eq 1 ] && echo "Sending notification (dry-run, no actual notification was sent)"
|
||||
else
|
||||
[ $VERY_VERBOSE -eq 1 ] && echo "Sending notification"
|
||||
send_notify "$name" "$description <$url>"
|
||||
# Create the tempfile so that in the next run, we won't resend this notification again
|
||||
# NOTE: We're storing the name and description into this file to make it easier
|
||||
# to figure out what notification the tempfile belongs to, with ~@~ separator
|
||||
printf "%s~@~%s" "$name" "$description" > "$tmpname"
|
||||
fi
|
||||
# Keep track of how many notifications were sent (didn't have a cache file)
|
||||
sent="$(cat "$sent_count_file")"
|
||||
sent="$(("$sent"+1))"
|
||||
printf "%s" "$sent" > "$sent_count_file"
|
||||
else
|
||||
[ $VERY_VERBOSE -eq 1 ] && echo "Skipping (cached) - notification already sent"
|
||||
fi
|
||||
|
||||
# Add a new-line separator on very verbose to group prints from each iteration
|
||||
[ $VERY_VERBOSE -eq 1 ] && echo ""
|
||||
done
|
||||
|
||||
# Recover amount of sent notifications from the temporary file
|
||||
sent="$(cat "$sent_count_file")"
|
||||
rm "$sent_count_file"
|
||||
|
||||
if [ $VERBOSE -eq 1 ]; then
|
||||
unsent="$(("$total"-"$sent"))"
|
||||
if [ "$sent" -eq "$total" ]; then
|
||||
echo "Found and sent $total new notifications"
|
||||
elif [ "$unsent" -eq "$total" ]; then
|
||||
echo "Found $total notifications, all of which were already sent (no new notifications to send)"
|
||||
else
|
||||
echo "Found $total notifications, of which $sent were new and sent ($unsent were skipped - cached/already sent)"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
[ $VERBOSE -eq 1 ] && echo "No new notifications"
|
||||
fi
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ -n "$DISPLAY" ]; then
|
||||
export FIFO_UEBERZUG="${TMPDIR:-/tmp}/lf-ueberzug-$$"
|
||||
|
||||
cleanup() {
|
||||
exec 3>&-
|
||||
rm "$FIFO_UEBERZUG"
|
||||
}
|
||||
|
||||
mkfifo "$FIFO_UEBERZUG"
|
||||
ueberzug layer -s <"$FIFO_UEBERZUG" &
|
||||
exec 3>"$FIFO_UEBERZUG"
|
||||
trap cleanup EXIT
|
||||
|
||||
if ! [ -d "$HOME/.cache/lf" ]; then
|
||||
mkdir -p "$HOME/.cache/lf"
|
||||
fi
|
||||
|
||||
lf "$@" 3>&-
|
||||
else
|
||||
exec lf "$@"
|
||||
fi
|
|
@ -1,44 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$1" = "start" ]; then
|
||||
MODE="start"
|
||||
elif [ "$1" = "stop" ]; then
|
||||
MODE="stop"
|
||||
elif [ "$1" = "toggle" ]; then
|
||||
if pidof -s xss-lock > /dev/null 2>&1; then
|
||||
MODE="stop"
|
||||
else
|
||||
MODE="start"
|
||||
fi
|
||||
elif [ "$1" = "lock" ]; then
|
||||
MODE="lock"
|
||||
else
|
||||
echo "Invalid command usage, use: lockscreen [start/stop/toggle/lock]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "start" ]; then
|
||||
echo "Starting xss-lock"
|
||||
# Set X11 lockscreen delays (DPMS)
|
||||
xset s on
|
||||
xset s 600 10 # Dim screen after 10 minutes, lock 10s later
|
||||
|
||||
# XSS lock with xsecurelock
|
||||
xss-lock -n /usr/lib/xsecurelock/dimmer -l -- xsecurelock &
|
||||
elif [ "$MODE" = "stop" ]; then
|
||||
echo "Stopping xss-lock"
|
||||
# Remove X11 lockscreen delays (DPMS)
|
||||
xset s off
|
||||
# Stop XSS lock
|
||||
killall xss-lock
|
||||
elif [ "$MODE" = "lock" ]; then
|
||||
# Send a DPMS trigger if xss-lock is running to inform it
|
||||
# about the lockstate, if it's not running, run xsecurelock directly
|
||||
if pidof -s xss-lock > /dev/null 2>&1; then
|
||||
echo "Locking screen - using DPMS (xss-lock active)"
|
||||
xset s activate
|
||||
else
|
||||
echo "Locking screen - running xsecurelock directly (xss-lock isn't running)"
|
||||
xsecurelock
|
||||
fi
|
||||
fi
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script does the following:
|
||||
# Run by itself, set the wallpaper
|
||||
# If given a file, set that as the new wallpaper
|
||||
# If given a directory, recursively choose a random file in it.
|
||||
|
||||
# Location of the symlink to wallpaper image
|
||||
bgloc="${XDG_DATA_HOME:-$HOME/.local/share}/background"
|
||||
|
||||
trueloc="$(readlink -f "$1")" &&
|
||||
case "$(file --mime-type -b "$trueloc")" in
|
||||
image/* )
|
||||
ln -sf "$(readlink -f "$1")" "$bgloc"
|
||||
notify-send -i "$bgloc" "Changing wallpaper..."
|
||||
;;
|
||||
inode/directory )
|
||||
randimg="$(find -L $trueloc -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)"
|
||||
echo $randimg
|
||||
ln -sf "$randimg" "$bgloc"
|
||||
notify-send -i "$bgloc" "Random Wallpaper chosen."
|
||||
;;
|
||||
*)
|
||||
notify-send "Error" "Not a valid image."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Use xwallpaper to set the background
|
||||
xwallpaper --zoom "$bgloc"
|
|
@ -1,26 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
#original artwork by http://www.sanderfocus.nl/#/portfolio/tech-heroes
|
||||
#converted to shell by #nixers @ irc.unix.chat
|
||||
|
||||
cat << 'eof'
|
||||
[38;5;255m,_ ,_==▄▂[0m
|
||||
[38;5;255m, ▂▃▄▄▅▅[48;5;240m▅[48;5;20m▂[48;5;240m▅¾[0m. [38;5;199m/ [38;5;20m/[0m
|
||||
[38;5;255m[48;5;20m▄[0m[38;5;255m[48;5;199m▆[38;5;16m[48;5;255m<´ [38;5;32m"[38;5;34m»[38;5;255m▓▓[48;5;32m▓[48;5;240m%[0m\ [38;5;199m/ [38;5;20m/ [38;5;45m/ [38;5;118m/[0m
|
||||
[38;5;255m,[38;5;255m[48;5;240m▅[38;5;16m[48;5;255m7" [38;5;160m´[38;5;34m>[38;5;255m[48;5;39m▓▓[38;5;199m[48;5;255m▓[0m[38;5;255m% [38;5;20m/ [38;5;118m/ [38;5;199m> [38;5;118m/ [38;5;199m>[38;5;255m/[38;5;45m%[0m
|
||||
[38;5;255m▐[48;5;240m[38;5;255m¶[48;5;240m[38;5;255m▓[48;5;255m [38;5;196m,[38;5;34m»[48;5;201m[38;5;255m▓▓[0m[38;5;255m¾´[0m [38;5;199m/[38;5;255m> %[38;5;199m/[38;5;118m%[38;5;255m/[38;5;199m/ [38;5;45m/ [38;5;199m/[0m
|
||||
[38;5;255m[48;5;240m▓[48;5;255m[38;5;16m▃[48;5;16m[38;5;255m▅▅[38;5;16m[48;5;255m▅▃,,[38;5;32m▄[38;5;16m▅[38;5;255m[48;5;16m▅▅[38;5;255m[48;5;20mÆ[0m[38;5;255m\[0m[38;5;20m/[38;5;118m/[38;5;255m /[38;5;118m/[38;5;199m/[38;5;255m>[38;5;45m// [38;5;255m/[38;5;118m>[38;5;199m/ [38;5;20m/[0m
|
||||
[48;5;20m[38;5;255mV[48;5;255m[38;5;16m║[48;5;20m[38;5;255m«[0m[38;5;255m¼.;[48;5;240m[38;5;255m→[48;5;255m[38;5;16m ║[0m[38;5;255m<«.,[48;5;25m[38;5;255m`[48;5;240m=[0m[38;5;20m/[38;5;199m/ [38;5;255m/>[38;5;45m/[38;5;118m/[38;5;255m%/[38;5;199m% / [38;5;20m/[0m
|
||||
[38;5;20m//[48;5;255m[38;5;16m╠<´ -²,)[48;5;16m[38;5;255m(▓[48;5;255m[38;5;16m~"-[38;5;199m╝/[0m[38;5;255m¾[0m[38;5;199m/ [38;5;118m%[38;5;255m/[38;5;118m>[38;5;45m/ [38;5;118m/[38;5;199m>[0m
|
||||
[38;5;20m/ / [38;5;118m/ [48;5;20m[38;5;255m▐[48;5;240m[38;5;16m%[48;5;255m -./▄▃▄[48;5;16m[38;5;255m▅[48;5;255m[38;5;16m▐[48;5;255m[38;5;16m, [38;5;199m/[48;5;199m[38;5;255m7[0m[38;5;20m/[38;5;199m/[38;5;255m;/[38;5;199m/[38;5;118m% [38;5;20m/ /[0m
|
||||
[38;5;20m/ [38;5;199m/[38;5;255m/[38;5;45m/[38;5;118m/[38;5;255m[48;5;240m`[48;5;20m[38;5;255m▌[48;5;20m[38;5;255m▐[48;5;255m[38;5;16m %z[0m[38;5;255mWv xX[48;5;20m[38;5;255m▓[48;5;34m[38;5;255m▇[48;5;199m[38;255m▌[0m[38;5;20m/[38;5;199m/[38;5;255m&;[38;5;20m% [38;5;199m/ [38;5;20m/[0m
|
||||
[38;5;20m/ / [38;5;255m/ [38;5;118m%[38;5;199m/[38;5;255m/%/[48;5;240m[38;5;255m¾[48;5;255m[38;5;16m½´[38;5;255m[48;5;16m▌[0m[38;5;246m▃▄[38;5;255m▄▄[38;5;246m▄▃▃[0m[48;5;16m[38;5;255m▐[38;5;255m[48;5;199m¶[48;5;20m[38;5;255m\[0m[38;5;20m/[0m[48;5;255m[38;5;240m&[0m [38;5;20m/[0m
|
||||
[38;5;199m<[38;5;118m/ [38;5;45m/[38;5;255m</[38;5;118m%[38;5;255m/[38;5;45m/[38;5;255m`[48;5;16m▓[48;5;255m[38;5;16m![48;5;240m[38;5;255m%[48;5;16m[38;5;255m▓[0m[38;5;255m%[48;5;240m[38;5;255m╣[48;5;240m[38;5;255;╣[0m[38;5;255mW[0m[38;5;250mY<Y)[48;5;255m[38;5;16my&[0m[38;5;255m/`[48;5;240m\[0m
|
||||
[38;5;20m/ [38;5;199m/ [38;5;199m%[38;5;255m/%[38;5;118m/[38;5;45m/[38;5;255m<[38;5;118m/[38;5;199m%[38;5;45m/[38;5;20m/[48;5;240m[38;5;255m\[38;5;16m[48;5;255mi7; ╠N[0m[38;5;246m>[38;5;255m)VY>[48;5;240m[38;5;255m7[0m[38;5;255m; [38;5;255m[48;5;240m\[0m[38;5;255m_[0m [38;5;255mUNIX IS VERY SIMPLE [38;5;45mIT JUST NEEDS A[0m
|
||||
[38;5;20m/ [38;5;255m/[38;5;118m<[38;5;255m/ [38;5;45m/[38;5;255m/<[38;5;199m/[38;5;20m/[38;5;199m/[38;5;20m<[38;5;255m_/%\[38;5;255m[48;5;16m▓[48;5;255m[38;5;16m V[0m[38;5;255m%[48;5;255m[38;5;16mW[0m[38;5;255m%£)XY[0m [38;5;240m_/%[38;5;255m‾\_,[0m [38;5;45mGENIUS TO UNDERSTAND ITS SIMPLICITY[38;5;255m[0m
|
||||
[38;5;199m/ [38;5;255m/ [38;5;199m/[38;5;255m/[38;5;118m%[38;5;199m/[48;5;240m[38;5;255m_,=-[48;5;20m-^[0m[38;5;255m/%/%%[48;5;255m[38;5;16m\¾%[0m[38;5;255m¶[0m[48;5;255m[38;5;16m%[0m[38;5;255m%}[0m [38;5;240m/%%%[38;5;20m%%[38;5;240m%;\,[0m
|
||||
[38;5;45m%[38;5;20m/[38;5;199m< [38;5;20m/[48;5;20m[38;5;255m_/[48;5;240m [0m[38;5;255m%%%[38;5;240m%%[38;5;20m;[38;5;255mX[38;5;240m%[38;5;20m%[38;5;255m\%[38;5;240m%;, _/%%%;[38;5;20m,[38;5;240m \[0m
|
||||
[38;5;118m/ [38;5;20m/ [38;5;240m%[38;5;20m%%%%[38;5;240m%;, [38;5;255m\[38;5;240m%[38;5;20m%[38;5;255ml[38;5;240m%%;// _/[38;5;20m%;,[0m [38;5;234mdmr[0m
|
||||
[38;5;20m/ [38;5;240m%[38;5;20m%%;,[0m [38;5;255m<[38;5;20m;[38;5;240m\-=-/ /[0m
|
||||
[38;5;20m;,[0m [38;5;240ml[0m
|
||||
eof
|
|
@ -1,54 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
|
||||
|
||||
echo "Setting up Noto Emoji font..."
|
||||
# Install noto-fonts-emoji repository as the basic emoji font
|
||||
pacman -S noto-fonts-emoji --needed
|
||||
# Install powerline-fonts for powerline statusline
|
||||
pacman -S powerline-fonts --needed
|
||||
echo "Font packages installed, setting up font-config"
|
||||
# Make sure noto emojis are preferred font /etc/fonts/local.conf
|
||||
# another way to do this would be to manually figure out the number and use /etc/fonts/conf.d/01-notosans.conf
|
||||
# note that the `01` might be too agressive and override other fonts, it is therefore easier to just use `local.conf`
|
||||
# if you still want to use the manual numbered representation, make sure to store the file into /etc/fonts/conf.avail/XX-notosans.conf
|
||||
# from which you will then make a symlink pointing to /etc/fonts/conf.d (same name)
|
||||
echo '<?xml version="1.0"?>
|
||||
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
||||
<fontconfig>
|
||||
<alias>
|
||||
<family>sans-serif</family>
|
||||
<prefer>
|
||||
<family>Noto Sans</family>
|
||||
<family>Noto Color Emoji</family>
|
||||
<family>Noto Emoji</family>
|
||||
<family>DejaVu Sans</family>
|
||||
</prefer>
|
||||
</alias>
|
||||
|
||||
<alias>
|
||||
<family>serif</family>
|
||||
<prefer>
|
||||
<family>Noto Serif</family>
|
||||
<family>Noto Color Emoji</family>
|
||||
<family>Noto Emoji</family>
|
||||
<family>DejaVu Serif</family>
|
||||
</prefer>
|
||||
</alias>
|
||||
|
||||
<alias>
|
||||
<family>monospace</family>
|
||||
<prefer>
|
||||
<family>Noto Mono</family>
|
||||
<family>Noto Color Emoji</family>
|
||||
<family>Noto Emoji</family>
|
||||
<family>DejaVu Sans Mono</family>
|
||||
</prefer>
|
||||
</alias>
|
||||
</fontconfig>
|
||||
|
||||
' > /etc/fonts/local.conf
|
||||
# Update font cache
|
||||
fc-cache -f
|
||||
echo "Noto Emoji Font installed! You will need to restart application to see changes."
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Fix camera autofocus and exposure
|
||||
v4l2-ctl -d /dev/video0 --set-ctrl=focus_auto=0
|
||||
v4l2-ctl -d /dev/video0 --set-ctrl=exposure_auto=3
|
||||
v4l2-ctl -d /dev/video0 --set-ctrl=sharpness=150
|
||||
v4l2-ctl -d /dev/video0 --set-ctrl=exposure_auto_priority=0
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script will create a virtual microphone for PulseAudio to use and set it as the default device.
|
||||
|
||||
# Load the "module-pipe-source" module to read audio data from a FIFO special file.
|
||||
echo "Creating virtual microphone."
|
||||
pactl load-module module-pipe-source source_name=virtmic file=$HOME/.config/pulse/audioFiles/virtmic format=s16le rate=16000 channels=1
|
||||
|
||||
# Set the virtmic as the default source device.
|
||||
echo "Set the virtual microphone as the default device."
|
||||
pactl set-default-source virtmic
|
||||
|
||||
# Create a file that will set the default source device to virtmic for all
|
||||
PulseAudio client applications.
|
||||
echo "default-source = virtmic" > $HOME/.config/pulse/client.conf
|
||||
|
||||
# Write the audio file to the named pipe virtmic. This will block until the named pipe is read.
|
||||
echo "Writing audio file to virtual microphone."
|
||||
while true; do
|
||||
ffmpeg -re -i input.wav -f s16le -ar 16000 -ac 1 - > $HOME/.config/pulse/audioFiles/virtmic
|
||||
done
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Uninstall the virtual microphone.
|
||||
|
||||
pactl unload-module module-pipe-source
|
||||
rm $HOME/.config/pulse/client.conf
|
||||
|
Binary file not shown.
|
@ -1,40 +0,0 @@
|
|||
/* usbreset -- send a USB port reset to a USB device */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <linux/usbdevice_fs.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *filename;
|
||||
int fd;
|
||||
int rc;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: usbreset device-filename\n");
|
||||
return 1;
|
||||
}
|
||||
filename = argv[1];
|
||||
|
||||
fd = open(filename, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror("Error opening output file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Resetting USB device %s\n", filename);
|
||||
rc = ioctl(fd, USBDEVFS_RESET, 0);
|
||||
if (rc < 0) {
|
||||
perror("Error in ioctl");
|
||||
return 1;
|
||||
}
|
||||
printf("Reset successful\n");
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
# Enter passsword via terminal, instead of using a graphical window
|
||||
pinentry-mode loopback
|
||||
# Specify my default key that will be used for signing
|
||||
default-key 7583ABA897FC6728DCAF823FB014E761034AF742
|
||||
# Specify my preferred default keyserver
|
||||
keyserver keys.openpgp.org
|
Loading…
Add table
Add a link
Reference in a new issue