Merge branch 'master' of ssh://git.jonathanh.co.uk:2222/jab2870/Dotfiles
This commit is contained in:
commit
bf51584525
9 changed files with 380 additions and 63 deletions
|
@ -1,6 +1,19 @@
|
|||
#!/usr/bin/sh
|
||||
|
||||
isPhone(){
|
||||
case "$(hostname)" in
|
||||
*-phone) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
if type -p rofi 2> /dev/null; then
|
||||
alias selectcommand="rofi -dmenu -i -theme themes/power.rasi -me-select-entry '' -me-accept-entry MousePrimary"
|
||||
if isPhone; then
|
||||
theme="themes/power-phone.rasi"
|
||||
else
|
||||
theme="themes/power.rasi"
|
||||
fi
|
||||
alias selectcommand="rofi -dmenu -i -theme $theme -me-select-entry '' -me-accept-entry MousePrimary"
|
||||
shutdown=""
|
||||
reboot=""
|
||||
lock=""
|
||||
|
@ -15,24 +28,33 @@ else
|
|||
logout="Logout"
|
||||
fi
|
||||
|
||||
hostname="$(hostname)"
|
||||
|
||||
selection=$( \
|
||||
echo -e "$shutdown\n$reboot\n$lock\n$logout\n$suspend" | selectcommand
|
||||
);
|
||||
echo $selection;
|
||||
if isPhone; then
|
||||
selection="$(echo -e "$shutdown\n$reboot\n$lock\n$logout" | selectcommand)"
|
||||
else
|
||||
notify-send "Not phone"
|
||||
selection="$(echo -e "$shutdown\n$reboot\n$lock\n$logout\n$suspend" | selectcommand)"
|
||||
fi
|
||||
|
||||
sleep .2
|
||||
|
||||
case $selection in
|
||||
$lock)
|
||||
#i3exit lock
|
||||
if isPhone; then
|
||||
screenlock --suspend
|
||||
else
|
||||
i3exit lock
|
||||
fi
|
||||
;;
|
||||
$logout)
|
||||
pkill dwm
|
||||
;;
|
||||
$suspend)
|
||||
systemctl suspend
|
||||
#i3exit lock
|
||||
if !isPhone; then
|
||||
i3exit lock
|
||||
fi
|
||||
;;
|
||||
$reboot)
|
||||
systemctl reboot
|
||||
|
|
128
bin/.bin/modem/checkCall
Executable file
128
bin/.bin/modem/checkCall
Executable file
|
@ -0,0 +1,128 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/common"
|
||||
|
||||
usage(){
|
||||
echo "checkCall [options] [message|-]"
|
||||
echo "Options:"
|
||||
echo " -h|--help Display this help text"
|
||||
echo " -m|--modem Specify a modem"
|
||||
echo " --dry-run Don't actually send the message"
|
||||
}
|
||||
|
||||
|
||||
# Stolen from sxmo
|
||||
lookupnumberfromcallid() {
|
||||
local id=$1
|
||||
mmcli -m "$modem" --voice-list-calls -o "$id" -K |
|
||||
grep call.properties.number |
|
||||
cut -d ':' -f 2 |
|
||||
tr -d ' '
|
||||
}
|
||||
|
||||
lookupcontact(){
|
||||
echo "$1" |
|
||||
# Remove the +44 and replace with 0
|
||||
sed 's/^\+44/0/'
|
||||
# This will eventually work with abook but for now just return the number
|
||||
}
|
||||
|
||||
answer-call(){
|
||||
mmcli -m "$modem" -o "$1" --accept
|
||||
}
|
||||
|
||||
reject-call(){
|
||||
notify-send "Reject"
|
||||
}
|
||||
|
||||
prompt-incoming(){
|
||||
export DISPLAY=:0.0
|
||||
|
||||
local answer=""
|
||||
local reject=""
|
||||
|
||||
local choice=''
|
||||
# Used for testing
|
||||
local number="${1:-01234 567890}"
|
||||
|
||||
local prompt="$(echo -en "Incoming Call\n$number")"
|
||||
|
||||
while [ -z "$choice" ]; do
|
||||
|
||||
choice="$(echo -e "$answer\n$reject" | rofi -dmenu -i \
|
||||
-theme themes/incoming-call.rasi -a 0 -u 1 \
|
||||
-p "$prompt" \
|
||||
-me-select-entry '' -me-accept-entry MousePrimary)"
|
||||
|
||||
case "$choice" in
|
||||
"$answer") echo "answer" ;;
|
||||
"$reject") echo "reject" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
mkdir -p "$CALL_DIR"
|
||||
|
||||
dryrun="false"
|
||||
|
||||
# Assume we want the first modem
|
||||
# can be overwritten by the -m option
|
||||
modem="$(mmcli -L | grep -oE 'Modem\/[0-9]+' | head -n 1 | cut -d'/' -f2)"
|
||||
|
||||
|
||||
|
||||
# Read the options and set stuff
|
||||
while [[ $1 = -?* ]]; do
|
||||
case $1 in
|
||||
-h|--help) usage; exit;;
|
||||
-m|--modem) modem="$2"; shift ;;
|
||||
--dry-run) dryrun="true" ;;
|
||||
--) shift; break ;;
|
||||
*) die "invalid option: '$1'." ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
checkIncoming(){
|
||||
local id="$( mmcli -m "$modem" --voice-list-calls |
|
||||
grep -Eo '[0-9]+ incoming \(ringing-in\)' | grep -Eo '[0-9]+' )"
|
||||
|
||||
local count="$(echo "$id" | deleteEmptyLines | wc -l)"
|
||||
|
||||
[ "$count" -eq 0 ] && return
|
||||
|
||||
local number="$(lookupnumberfromcallid "$id")"
|
||||
local contact="$(lookupcontact "$number")"
|
||||
|
||||
local action="$(prompt-incoming "$contact")"
|
||||
|
||||
case action in
|
||||
accept) answer-call "$id" ;;
|
||||
reject) reject-call "$id" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkFinished(){
|
||||
local ids="$( mmcli -m "$modem" --voice-list-calls |
|
||||
grep -Eo '[0-9]+ incoming \(terminated\)' | grep -Eo '[0-9]+' )"
|
||||
|
||||
local count="$(echo "$ids" | deleteEmptyLines | wc -l)"
|
||||
|
||||
[ "$count" -eq 0 ] && return
|
||||
|
||||
echo "$ids" | while read -r id; do
|
||||
# Delete from the modem
|
||||
local number="$(lookupnumberfromcallid "$id")"
|
||||
local contact="$(lookupcontact "$number")"
|
||||
|
||||
echo "Missed call from $contact" >> "$CALL_DIR/missed-calls"
|
||||
mmcli -m "$modem" --voice-delete-call "$id"
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
checkIncoming &
|
||||
checkFinished &
|
|
@ -1,19 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/common"
|
||||
|
||||
# This is largely borrowed from:
|
||||
# https://git.sr.ht/~mil/sxmo-utils/tree/master/item/scripts/modem/sxmo_modemmonitor.sh
|
||||
|
||||
# This is where sms messages will be stored
|
||||
SMS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/SMS/"
|
||||
|
||||
die(){
|
||||
echo "$@" > /dev/stderr
|
||||
rm "$FILE"
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage(){
|
||||
echo "checkSMS [options] [message|-]"
|
||||
echo "checkSMS [options]"
|
||||
echo "Options:"
|
||||
echo " -h|--help Display this help text"
|
||||
echo " -m|--modem Specify a modem"
|
||||
|
@ -21,57 +17,15 @@ usage(){
|
|||
}
|
||||
|
||||
|
||||
trimWhitespace(){
|
||||
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
|
||||
}
|
||||
|
||||
mkdir -p "$SMS_DIR"
|
||||
|
||||
dryrun="false"
|
||||
edit="false"
|
||||
|
||||
# Assume we want the first modem
|
||||
# can be overwritten by the -m option
|
||||
modem="$(mmcli -L | grep -oE 'Modem\/[0-9]+' | head -n 1 | cut -d'/' -f2)"
|
||||
|
||||
|
||||
# Iterate over options breaking -ab into -a -b when needed and --foo=bar into
|
||||
# --foo bar
|
||||
optstring=h
|
||||
unset options
|
||||
while (($#)); do
|
||||
case $1 in
|
||||
# If option is of type -ab
|
||||
-[!-]?*)
|
||||
# Loop over each character starting with the second
|
||||
for ((i=1; i < ${#1}; i++)); do
|
||||
c=${1:i:1}
|
||||
|
||||
# Add current char to options
|
||||
options+=("-$c")
|
||||
|
||||
# If option takes a required argument, and it's not the last char make
|
||||
# the rest of the string its argument
|
||||
if [[ $optstring = *"$c:"* && ${1:i+1} ]]; then
|
||||
options+=("${1:i+1}")
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
# If option is of type --foo=bar
|
||||
--?*=*) options+=("${1%%=*}" "${1#*=}") ;;
|
||||
# add --endopts for --
|
||||
--) options+=(--endopts) ;;
|
||||
# Otherwise, nothing special
|
||||
*) options+=("$1") ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
set -- "${options[@]}"
|
||||
unset options
|
||||
|
||||
|
||||
# Read the options and set stuff
|
||||
while [[ $1 = -?* ]]; do
|
||||
case $1 in
|
||||
|
@ -88,9 +42,9 @@ done
|
|||
ids="$( mmcli -m "$modem" --messaging-list-sms |
|
||||
grep -Eo '/SMS/[0-9]+ \(received\)' | grep -Eo '[0-9]+' )"
|
||||
|
||||
count="$(echo "$ids" | wc -l)"
|
||||
count="$(echo "$ids" | deleteEmptyLines | wc -l)"
|
||||
|
||||
[ "$count" -eq 0 ] && return
|
||||
[ "$count" -eq 0 ] && exit
|
||||
|
||||
echo "$ids" | while read -r id; do
|
||||
# Get the details of the message
|
||||
|
|
54
bin/.bin/modem/common
Normal file
54
bin/.bin/modem/common
Normal file
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/Calls/"
|
||||
SMS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/SMS/"
|
||||
|
||||
die(){
|
||||
echo "$@" > /dev/stderr
|
||||
rm "$FILE"
|
||||
exit 1
|
||||
}
|
||||
|
||||
trimWhitespace(){
|
||||
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
|
||||
}
|
||||
|
||||
deleteEmptyLines(){
|
||||
sed '/^$/ d'
|
||||
}
|
||||
|
||||
# Iterate over options breaking -ab into -a -b when needed and --foo=bar into
|
||||
# --foo bar
|
||||
optstring=h
|
||||
unset options
|
||||
while (($#)); do
|
||||
case $1 in
|
||||
# If option is of type -ab
|
||||
-[!-]?*)
|
||||
# Loop over each character starting with the second
|
||||
for ((i=1; i < ${#1}; i++)); do
|
||||
c=${1:i:1}
|
||||
|
||||
# Add current char to options
|
||||
options+=("-$c")
|
||||
|
||||
# If option takes a required argument, and it's not the last char make
|
||||
# the rest of the string its argument
|
||||
if [[ $optstring = *"$c:"* && ${1:i+1} ]]; then
|
||||
options+=("${1:i+1}")
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
# If option is of type --foo=bar
|
||||
--?*=*) options+=("${1%%=*}" "${1#*=}") ;;
|
||||
# add --endopts for --
|
||||
--) options+=(--endopts) ;;
|
||||
# Otherwise, nothing special
|
||||
*) options+=("$1") ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
set -- "${options[@]}"
|
||||
unset options
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
export DISPLAY=:0.0
|
||||
|
||||
prompt=""
|
||||
|
||||
|
@ -19,14 +20,14 @@ $answer
|
|||
6
|
||||
9
|
||||
#
|
||||
# "
|
||||
X"
|
||||
|
||||
while true; do
|
||||
notify-send "$prompt"
|
||||
#notify-send "$prompt"
|
||||
input="$(echo "$options" |
|
||||
rofi -dmenu -p "$prompt" -theme themes/dialer.rasi \
|
||||
-me-select-entry '' -me-accept-entry MousePrimary)"
|
||||
[ "$input" = "#" ] && exit
|
||||
[ "$input" = "X" ] && exit
|
||||
#exit
|
||||
prompt+="$input"
|
||||
done
|
||||
|
|
38
bin/.bin/modem/missedCalls
Executable file
38
bin/.bin/modem/missedCalls
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/common"
|
||||
|
||||
usage(){
|
||||
echo "missedCalls"
|
||||
echo "-a --all Print all (default)"
|
||||
echo "-c --count Print count"
|
||||
echo "-l --list Print list"
|
||||
}
|
||||
|
||||
toprint="all"
|
||||
# Read the options and set stuff
|
||||
while [[ $1 = -?* ]]; do
|
||||
case $1 in
|
||||
-a|--all) toprint="all" ;;
|
||||
-c|--count) toprint="count" ;;
|
||||
-l|--list) toprint="list" ;;
|
||||
-h|--help) usage; exit;;
|
||||
--) shift; break ;;
|
||||
*) die "invalid option: '$1'." ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ -f "$CALL_DIR/missed-calls" ] || exit
|
||||
|
||||
if [ "$toprint" = "count" ] || [ "$toprint" = "all" ]; then
|
||||
count="$(cat "$CALL_DIR/missed-calls" | deleteEmptyLines | wc -l )"
|
||||
echo "$count missed calls"
|
||||
fi
|
||||
|
||||
if [ "$toprint" = "list" ] || [ "$toprint" = "all" ]; then
|
||||
cat "$CALL_DIR/missed-calls"
|
||||
fi
|
||||
|
29
bin/.bin/modem/monitorModem
Executable file
29
bin/.bin/modem/monitorModem
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This was mostly taken from sxmo:
|
||||
# https://git.sr.ht/~mil/sxmo-utils/tree/1.3.2/item/scripts/modem/sxmo_modemmonitor.sh#L181-205
|
||||
#
|
||||
# Although the proccess for managing calls etc is a bit simpler IMO
|
||||
|
||||
# Monitor for incoming calls
|
||||
dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Voice',type='signal',member='CallAdded'" | \
|
||||
while read -r line; do
|
||||
echo "$line" | grep -E "^signal" && checkCall
|
||||
done &
|
||||
|
||||
# Monitor for incoming texts
|
||||
dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Messaging',type='signal',member='Added'" | \
|
||||
while read -r line; do
|
||||
echo "$line" | grep -E "^signal" && checkSMS
|
||||
done &
|
||||
|
||||
# Monitor for finished calls
|
||||
dbus-monitor --system "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Call'" | \
|
||||
while read -r line; do
|
||||
echo "$line" | grep -E "^signal" && checkCall
|
||||
done &
|
||||
|
||||
wait
|
||||
wait
|
||||
wait
|
||||
|
91
rofi/.config/rofi/themes/power-phone.rasi
Normal file
91
rofi/.config/rofi/themes/power-phone.rasi
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
*
|
||||
* Author : Aditya Shakya
|
||||
* Mail : adi1090x@gmail.com
|
||||
* Github : @adi1090x
|
||||
* Twitter : @adi1090x
|
||||
*
|
||||
*/
|
||||
|
||||
configuration {
|
||||
disable-history: false;
|
||||
fullscreen: false;
|
||||
hide-scrollbar: true;
|
||||
sidebar-mode: false;
|
||||
}
|
||||
|
||||
@import "gruvbox-dark.rasi"
|
||||
|
||||
* {
|
||||
background-color: @background;
|
||||
text-color: @foreground;
|
||||
}
|
||||
|
||||
window {
|
||||
transparency: "real";
|
||||
border-radius: 12px;
|
||||
width: 100px;
|
||||
location: east;
|
||||
x-offset: -15px;
|
||||
y-offset: -200px;
|
||||
}
|
||||
|
||||
listview {
|
||||
lines: 4;
|
||||
margin: 8px;
|
||||
spacing: 8px;
|
||||
cycle: true;
|
||||
dynamic: true;
|
||||
layout: vertical;
|
||||
}
|
||||
|
||||
mainbox {
|
||||
background-color: @background;
|
||||
children: [ listview ];
|
||||
}
|
||||
|
||||
element {
|
||||
background-color: @background-light;
|
||||
text-color: @foreground;
|
||||
orientation: vertical;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
element-text {
|
||||
font: "iosevka 45";
|
||||
expand: true;
|
||||
horizontal-align: 0.5;
|
||||
vertical-align: 0;
|
||||
margin: 0px 10px 63px 10px;
|
||||
}
|
||||
|
||||
element normal.urgent,
|
||||
element alternate.urgent {
|
||||
background-color: @urgent;
|
||||
text-color: @foreground;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
element normal.active,
|
||||
element alternate.active {
|
||||
background-color: @background-alt;
|
||||
text-color: @foreground;
|
||||
}
|
||||
|
||||
element selected {
|
||||
background-color: @accent;
|
||||
text-color: @background;
|
||||
border: 0px;
|
||||
border-radius: 10px;
|
||||
border-color: @border;
|
||||
}
|
||||
|
||||
element selected.urgent {
|
||||
background-color: @urgent;
|
||||
text-color: @foreground;
|
||||
}
|
||||
|
||||
element selected.active {
|
||||
background-color: @background-alt;
|
||||
color: @foreground;
|
||||
}
|
|
@ -31,7 +31,7 @@ window {
|
|||
}
|
||||
|
||||
listview {
|
||||
lines: 4;
|
||||
lines: 5;
|
||||
margin: 8px;
|
||||
spacing: 8px;
|
||||
cycle: true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue