Browse Source

Edited several scripts and dwm

main
Yigit Colakoglu 3 years ago
parent
commit
34841dbbfd
8 changed files with 63 additions and 62 deletions
  1. +26
    -24
      .local/bin/dmenu-books
  2. +27
    -30
      .local/bin/dmenu-mconnect
  3. +3
    -4
      .local/bin/status-bar/mconnect
  4. +3
    -1
      .local/bin/status-bar/todo
  5. +0
    -2
      .local/src/dwm/config.h
  6. +2
    -0
      .local/src/dwm/config.mk
  7. +0
    -1
      .local/src/dwm/keybinds.h
  8. +2
    -0
      .local/src/dwm/rules.h

+ 26
- 24
.local/bin/dmenu-books View File

@ -3,35 +3,37 @@
# This is a small script to open a book from your calibre library
# Using dmenu.
LIBRARY="$HOME/Library"
USERNAME="yigitcolakoglu"
PASSWORD="$(pass show Server/calibre.yigitcolakoglu.com/yigitcolakoglu)"
HOST="https://calibre.fr1nge.xyz"
if [ "$(date -r "$XDG_CACHE_HOME/calibrelib" "+%d-%m-%Y")" = "$(date '+%d-%m-%Y')" ]; then
books_raw=$(cat "$XDG_CACHE_HOME/calibrelib")
else
books_raw=$(calibredb --with-library "$LIBRARY" list --for-machine --fields="title,authors,formats")
echo "$books_raw" > "$XDG_CACHE_HOME/calibrelib"
fi
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
id="$(echo "$books_raw" |\
jq -r '.[]|(.id | tostring) + " | " + .title + " | " + .authors' |\
dmenu -i -l 12 -p "Search Book: " |\
cut -d "|" -f 1)"
query=$(printf "" | dmenu -p "Please enter the book's name")
[ -z $query ] && exit
entry="$(echo "$books_raw" | jq -a ".[]|select(.id | contains($id))")"
XML=$(curl -s -u "$USERNAME:$PASSWORD" "$HOST/opds/search?query=$query")
formats="$(echo "$entry" | \
jq -r ".formats|.[]" |\
sed -r "s/.*\.([^\.]*)$/\1/g")"
menu=$(echo $XML | xpath -q -e '//entry/title | //entry/author/name | //entry/link[@type="application/pdf"]/@href')
if [ "$(echo "$formats" | wc -l)" -lt 2 ]; then
xdg-open "$(echo "$entry" | \
jq -r ".formats|.[0]")"
exit
fi
book=$(echo "$menu" | \
sed 's/<title>\(.*\)<\/title>/\1|/;N;s/<name>\(.*\)<\/name>/\1|/;N;s/href="\(.*\)"/\1/;s/\n/ /g' | \
column -s '|' -t | dmenu -p "Please select the book" -l 5)
index=$(( $(echo "$formats" | grep -n -F $(echo "$formats" | \
dmenu -p "Select format:" ) | cut -d ":" -f 1) - 1))
[ -z "$book" ] && exit
xdg-open "$(echo "$entry" | \
jq -r ".formats|.[$line]")"
name=$(echo "$book" | sed 's/\s\{2,\}/\n/g' | head -n 1)
author=$(echo "$book" | sed 's/\s\{2,\}/\n/g' | head -n 2 | tail -n 1)
path=$(echo "$book" | sed 's/\s\{2,\}/\n/g' | tail -n 1)
mkdir -p "$XDG_RUNTIME_DIR/books"
notify-send -a " Downloading" "$(printf "%s\n%s" "$name" "$author")"
wget -nc -P "$XDG_RUNTIME_DIR/books" -q --content-disposition \
--user "$USERNAME" --password "$PASSWORD" "$HOST$path"
filename=$(curl -s --head -u "$USERNAME:$PASSWORD" "$HOST$path" | \
grep "Content-Disposition" |\
sed -E 's/Content-Disposition:.*filename=([^;]*);.*/\1/g')
xdg-open "$XDG_RUNTIME_DIR/books/$(urldecode $filename)"

+ 27
- 30
.local/bin/dmenu-mconnect View File

@ -44,35 +44,32 @@ SEPERATOR='|'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source ~/.config/config.env
show_devices (){
IFS=$','
devices=""
# for all the devices avalable
for device in $(dbus-send --print-reply --session --dest=org.mconnect /org/mconnect/manager org.mconnect.DeviceManager.ListDevices | cut -f1 -d"[" | cut -f1 -d "]" | tail -2); do
#get the device info
deviceobj=$(echo "$device" | cut -f2 -d"\"" | tr -d '\n' | xargs)
devicename=$(dbus-send --print-reply --session --dest=org.mconnect "$deviceobj" org.freedesktop.DBus.Properties.Get string:org.mconnect.Device string:Name | grep -E string | cut -f2 -d"\"")
isreach="$(dbus-send --print-reply --session --dest=org.mconnect "$deviceobj" org.freedesktop.DBus.Properties.Get string:org.mconnect.Device string:IsConnected | grep -E boolean | cut -b 26-)"
devicetype=$(dbus-send --print-reply --session --dest=org.mconnect "$deviceobj" org.freedesktop.DBus.Properties.Get string:org.mconnect.Device string:DeviceType | grep -E string | cut -f2 -d"\"")
istrust="$(dbus-send --print-reply --session --dest=org.mconnect "$deviceobj" org.freedesktop.DBus.Properties.Get string:org.mconnect.Device string:Allowed | grep -E boolean | cut -b 26-)"
if [ "$isreach" = "true" ] && [ "$istrust" = "true" ];then
#is connected
battery="$(dbus-send --print-reply --session --dest=org.mconnect $deviceobj org.freedesktop.DBus.Properties.Get string:org.mconnect.Device.Battery string:Level | grep -e uint32 | cut -b 25-)%"
icon=$(get_icon $battery $devicetype)
# colors="$(get_colors $battery)"
# echo "$colors"
show_menu "$devicename | $battery $icon" $deviceobj $battery
devices+="$devicename $battery $icon $SEPERATOR"
elif [ "$isreach" = "false" ] && [ "$istrust" = "true" ];then
#nothing is found
devices+="$(get_icon -1 $devicetype)$SEPERATOR"
else
#found but not yet paired
icon=$(get_icon -2 $devicetype)
show_pmenu $devicename $deviceobj
devices+="$devicename $icon $SEPERATOR"
fi
done
device=$(mconnectctl | grep $MCONNECT_DEVICE | sed 's/\s\{2,\}/\n/g; s/ - /\n/g;s/^\n//g' | head -n 1)
deviceobj=$(echo "$device" | cut -f2 -d"\"" | tr -d '\n' | xargs)
devicename=$(dbus-send --print-reply --session --dest=org.mconnect "$deviceobj" org.freedesktop.DBus.Properties.Get string:org.mconnect.Device string:Name | grep -E string | cut -f2 -d"\"")
isreach="$(dbus-send --print-reply --session --dest=org.mconnect "$deviceobj" org.freedesktop.DBus.Properties.Get string:org.mconnect.Device string:IsConnected | grep -E boolean | cut -b 26-)"
devicetype=$(dbus-send --print-reply --session --dest=org.mconnect "$deviceobj" org.freedesktop.DBus.Properties.Get string:org.mconnect.Device string:DeviceType | grep -E string | cut -f2 -d"\"")
istrust="$(dbus-send --print-reply --session --dest=org.mconnect "$deviceobj" org.freedesktop.DBus.Properties.Get string:org.mconnect.Device string:Allowed | grep -E boolean | cut -b 26-)"
if [ "$isreach" = "true" ] && [ "$istrust" = "true" ];then
#is connected
battery="$(dbus-send --print-reply --session --dest=org.mconnect $deviceobj org.freedesktop.DBus.Properties.Get string:org.mconnect.Device.Battery string:Level | grep -e uint32 | cut -b 25-)%"
icon=$(get_icon $battery $devicetype)
# colors="$(get_colors $battery)"
# echo "$colors"
show_menu "$devicename | $battery $icon" $deviceobj $battery
devices+="$devicename $battery $icon $SEPERATOR"
elif [ "$isreach" = "false" ] && [ "$istrust" = "true" ];then
#nothing is found
devices+="$(get_icon -1 $devicetype)$SEPERATOR"
else
#found but not yet paired
icon=$(get_icon -2 $devicetype)
show_pmenu $devicename $deviceobj
devices+="$devicename $icon $SEPERATOR"
fi
}
SendKeys(){
@ -89,8 +86,8 @@ SendKeys(){
#displays a menu for the connected device
show_menu () {
optionNum=5
options=$(printf "Send SMS\\nSend File\\nSend Text\\nSend URL\\nDisconnect\\n")
menu=$(echo $options | dmenu -i -p $1 -l $optionNum )
options="Send SMS\nSend File\nSend Text\nSend URL\nDisconnect\n"
menu=$(printf "$options" | dmenu -i -p "$1" -l $optionNum )
case "$menu" in
*'Send File')
mkdir -p $XDG_RUNTIME_DIR/lf/


+ 3
- 4
.local/bin/status-bar/mconnect View File

@ -4,11 +4,11 @@ if ! xdpyinfo | grep -q VNC ; then
source ~/.config/config.env
if [ ! "$MCONNECT" = true ] ; then
echo "^c#EBCB8B^ ^d^"
exit 0
fi
device_status=$(mconnectctl show-device $MCONNECT_DEVICE)
device=$(mconnectctl | grep $MCONNECT_DEVICE | sed 's/\s\{2,\}/\n/g; s/ - /\n/g;s/^\n//g' | head -n 1)
device_status=$(mconnectctl show-device $device)
IFS=$'\n'
@ -18,11 +18,10 @@ if ! xdpyinfo | grep -q VNC ; then
connected=${connected[1]}
if [ ! "$connected" = true ] ; then
echo "^c#EBCB8B^ ^d^"
exit 0
fi
battery_status=$(mconnectctl show-battery $MCONNECT_DEVICE)
battery_status=$(mconnectctl show-battery $device)
IFS=$'\n'


+ 3
- 1
.local/bin/status-bar/todo View File

@ -2,5 +2,7 @@
todos=$(calcurse -t | tail -n +2 | wc -l)
echo -n "^c#81a1c1^ ^d^ $todos"
if [ ! "$todos" = "0" ]; do
echo -n "^c#81a1c1^ ^d^ $todos"
done

+ 0
- 2
.local/src/dwm/config.h View File

@ -48,7 +48,6 @@ const char *spcmd3[] = {"st", "-c", "scratchpad", "-n", "spmutt", "-g", "180x51"
static const char *spcmd4[] = { "/usr/local/bin/st", "-g", "150x35", "-c", "spfile", "-n", "spfile", "-e", "/home/yigit/.local/bin/lf-ueberzug", NULL };
static const char *spcmd5[] = { "/usr/local/bin/st", "-g", "150x35", "-c", "spmusic", "-n", "spmusic", "-e", "ncmpcpp", NULL };
static const char *spcmd6[] = { "/usr/local/bin/st", "-g", "150x35", "-c", "spcal", "-n", "spcal", "-e", "calcurse", NULL };
static const char *spcmd7[] = { "obsidian" };
static Sp scratchpads[] = {
{"spterm", spcmd1},
@ -57,7 +56,6 @@ static Sp scratchpads[] = {
{"spfile", spcmd4},
{"spmusic", spcmd5},
{"spcal", spcmd6},
{"obsidian", spcmd7},
};
/* key definitions */


+ 2
- 0
.local/src/dwm/config.mk View File

@ -1,3 +1,5 @@
VPS ?= 0
# dwm version
VERSION = 6.2


+ 0
- 1
.local/src/dwm/keybinds.h View File

@ -171,7 +171,6 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_f, togglescratch, {.ui = 3} },
{ MODKEY, XK_n, togglescratch, {.ui = 4} },
{ MODKEY|ShiftMask, XK_c, togglescratch, {.ui = 5} },
{ MODKEY, XK_o, togglescratch, {.ui = 6} },
/* FloatPos Patch Keybinds */
{ Mod3Mask, XK_u, floatpos, {.v = "-26x -26y" } }, //
{ Mod3Mask, XK_i, floatpos, {.v = " 0x -26y" } }, //


+ 2
- 0
.local/src/dwm/rules.h View File

@ -46,6 +46,8 @@ static const Rule rules[] = {
{ "Zathura" , NULL , NULL , 0 , 0 , NULL , 0 , 1 , -1 },
{ "Qemu-system-x86_64", NULL , NULL , 0 , 1 , NULL , 0 , 1 , -1 },
{ "spfeh" , NULL , NULL , SPTAG(1) , 1 , NULL , 0 , 0 , -1 },
{ "obsidian" , NULL , NULL , 1 << 4 , 0 , NULL , 0 , 1 , -1 },
{ "spfeh" , NULL , NULL , SPTAG(1) , 1 , NULL , 0 , 0 , -1 },
{ NULL , "spterm" , NULL , SPTAG(0) , 1 , NULL , 0 , 0 , -1 },
{ NULL , "spmutt" , NULL , SPTAG(2) , 1 , NULL , 0 , 0 , -1 },
{ NULL , "spfile" , NULL , SPTAG(3) , 1 , NULL , 0 , 0 , -1 },


Loading…
Cancel
Save