Merge branch 'master' of ssh://git.jonathanh.co.uk:2222/jab2870/Dotfiles

master
Jonathan Hodgson 4 years ago
commit ed0817f6b5
  1. 1
      .gitignore
  2. 14
      bin/.bin/contact-numbers
  3. 21
      bin/.bin/dmenu/menu-phone
  4. 21
      bin/.bin/dmenu/menu-st
  5. 37
      bin/.bin/dmenu/menu-system
  6. 58
      bin/.bin/dmenu/rofi-volume
  7. 27
      bin/.bin/dmenu/spawn-phone-menu
  8. 12
      bin/.bin/dmenu/trofi
  9. 152
      bin/.bin/modem/checkCall
  10. 2
      bin/.bin/modem/checkSMS
  11. 1
      bin/.bin/modem/common
  12. 92
      bin/.bin/modem/dialer
  13. 41
      bin/.bin/modem/makeCall
  14. 3
      bin/.bin/modem/monitorModem
  15. 10
      bin/.bin/notifications/phoneStatus
  16. 7
      bin/.bin/toggleKeyboard
  17. 1
      bin/.bin/volume
  18. 2
      rofi/.config/rofi/themes/launchpad.rasi
  19. 18
      rofi/.config/rofi/themes/touch-dmenu.rasi
  20. 107
      rofi/.config/rofi/themes/volume.rasi
  21. 9
      systemd/.config/systemd/user/monitorModem.service
  22. 9
      systemd/ROOT/etc/systemd/system/pinephone-hardware-access.service
  23. 3
      x/.xinitrc

1
.gitignore vendored

@ -9,5 +9,6 @@ mutt/accounts/*
/qutebrowser/.config/qutebrowser/autoconfig.yml
/bin/.bin/pappy
/systemd/.config/systemd/user/timers.target.wants/
/systemd/.config/systemd/user/default.target.wants/
nvim/.config/nvim/.netrwhist
remind/.local/share/remind/work.rem

@ -2,6 +2,15 @@
addressbook="$HOME/.abook/addressbook"
filter(){
if [ -n "$1" ]; then
local str="$(echo "$1" | tr -d ' ' | sed 's/^0/+44/')"
grep -i "$str"
else
cat -
fi
}
cat "$addressbook" |
grep -E '(\[[0-9]+\]|^$|name|phone|mobile)' |
awk -v RS="\n\n" -v ORS="\n" '{gsub("\n","\t",$0); print $0}' |
@ -9,8 +18,9 @@ cat "$addressbook" |
name="$(echo "$line" | cut -d ' ' -f 2 | cut -d '=' -f 2)"
echo "$line" | tr '\t' '\n' |
grep -E '(phone|mobile)' | while read -r numLine; do
num="$(echo "$numLine" | cut -d '=' -f 2 | tr -d ' ' | sed 's/+44(0)/+44/')"
num="$(echo "$numLine" | cut -d '=' -f 2 | tr -d ' ' |
sed 's/+44(0)/+44/' | sed 's/^0/+44/')"
numType="$(echo "$numLine" | cut -d '=' -f 1)"
echo -e "$name\t$num\t$numType"
done
done
done | filter "$*"

@ -0,0 +1,21 @@
#!/usr/bin/env bash
options="End All Calls
Check for Calls
Check for Texts
Dialer"
while true ; do
choice="$(echo "$options" | trofi)"
case "$choice" in
"End All Calls")
modem="$(mmcli -L | grep -oE 'Modem\/[0-9]+' | head -n 1 | cut -d'/' -f2)"
mmcli -m "$modem" --voice-hangup-all
break ;;
"Check for Calls") checkCall ;;
"Check for Texts") checkSMS ;;
"Dialer") (dialer &); break ;;
"Back") break;;
esac
done

@ -0,0 +1,21 @@
#!/usr/bin/env bash
options="Zoom In
Zoom Out
Paste
System Menu
Exit"
choice=""
while : ; do
choice="$(echo "$options" | trofi)"
case "$choice" in
"Zoom In") sleep 0.3; xdotool key --clearmodifiers "ctrl+shift+j" ;;
"Zoom Out") sleep 0.3; xdotool key --clearmodifiers "ctrl+shift+k" ;;
"Paste") sleep 0.3; xdotool key --clearmodifiers "ctrl+shift+v" ;;
"System Menu") menu-system; break ;;
"Exit") sleep 0.3; xdotool key --clearmodifiers "Super_L+q"; break ;;
"") break ;;
esac
done

@ -0,0 +1,37 @@
#!/usr/bin/env bash
options="Terminal
Browser
Phone
Podcasts
Go To Workspace
Move To Workspace
Power Menu
Exit"
chooseWorkspace(){
seq 1 10 | trofi
}
goToWorkspace(){
xdotool key --clearmodifiers "Super_L+$(chooseWorkspace)"
}
moveToWorkspace(){
xdotool key --clearmodifiers "Super_L+Shift+$(chooseWorkspace)"
}
while true ; do
choice="$(echo "$options" | trofi)"
case "$choice" in
"Terminal") (folder-shell &); break ;;
"Browser") (firefox &); break ;;
"Podcasts") (gnome-podcasts &); break ;;
"Phone") spawn-phone-menu phone ; break ;;
"Go To Workspace") goToWorkspace ; break ;;
"Move To Workspace") moveToWorkspace ; break ;;
"Power Menu") (rofi-shutdown &); break ;;
"Exit") sleep 0.3; xdotool key --clearmodifiers "Super_L+q"; break ;;
"") break;;
esac
done

@ -0,0 +1,58 @@
#!/usr/bin/env bash
up=""
down=""
mute="ﱝ"
while : ; do
active=""
urgent=""
if type -p pulseaudio-ctl 2> /dev/null; then
volume="$(pulseaudio-ctl full-status | cut -d ' ' -f1)"
speakerStatus="$(pulseaudio-ctl full-status | cut -d ' ' -f2 |
sed 's/no/on/g')"
else
volume="$(amixer -D default sget Master | grep -o '\[.*\%' |
head -n 1 | tr -d '[%')"
speakerStatus="$(amixer -D default sget Master | grep -o '\[\(on\|off\)' |
head -n 1 | tr -d '[')"
fi
if [ "$speakerStatus" = "off" ]; then
volume="Muted"
urgent="-u 2"
else
active="-a 2"
fi
choice="$(echo -e "$up\n$down\n$mute" |
rofi -dmenu -theme 'themes/volume.rasi' -p "$volume" $urgent $active)"
case "$choice" in
"$up")
if type -p pulseaudio-ctl 2> /dev/null; then
pulseaudio-ctl up
else
amixer -q -D default sset Master 5%+ unmute
fi
;;
"$down")
if type -p pulseaudio-ctl 2> /dev/null; then
pulseaudio-ctl down
else
amixer -q -D default sset Master 5%- unmute
fi
;;
"$mute")
if type -p pulseaudio-ctl 2> /dev/null; then
pulseaudio-ctl mute
else
amixer -q -D default sset Master toggle
fi
;;
"") break
esac
done

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# This script creates menus for applications running on my phone
error(){
echo "$@" > /dev/stderr
exit 1
}
windowFocus="$(xdotool getwindowfocus)"
if [ -n "$1" ]; then
menu="menu-$1"
else
class="$(xprop -id "$windowFocus" | grep "WM_CLASS" | cut -d '"' -f 2)"
case "$class" in
"xterm-256color") menu="menu-st" ;;
*) menu="menu-$class" ;;
esac
fi
type "$menu" > /dev/null 2>&1 || menu="menu-system"
"$menu"

@ -0,0 +1,12 @@
#!/usr/bin/env bash
# THis is a simple wrapper around rofi which makes it nicer to use with touch screens
input="$(cat -)"
lines="$(echo "$input" | wc -l )"
[ "$lines" -gt 15 ] && lines=15
echo "$input" | rofi -dmenu -me-accept-entry '!MousePrimary' -theme "themes/touch-dmenu.rasi" -lines "$lines"

@ -3,9 +3,10 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$DIR/common"
export DISPLAY=:0.0
usage(){
echo "checkCall [options] [message|-]"
echo "checkCall [options]"
echo "Options:"
echo " -h|--help Display this help text"
echo " -m|--modem Specify a modem"
@ -22,24 +23,122 @@ lookupnumberfromcallid() {
tr -d ' '
}
# Stolen from sxmo
toggleflag() {
TOGGLEFLAG=$1
shift
FLAGS="$*"
echo -- "$FLAGS" | grep -- "$TOGGLEFLAG" >&2 &&
NEWFLAGS="$(echo -- "$FLAGS" | sed "s/$TOGGLEFLAG//g")" ||
NEWFLAGS="$(echo -- "$FLAGS $TOGGLEFLAG")"
NEWFLAGS="$(echo -- "$NEWFLAGS" | sed "s/--//g; s/ / /g")"
# shellcheck disable=SC2086
megiaudioroute $NEWFLAGS
echo -- "$NEWFLAGS"
}
# Stolen from sxmo
toggleflagset() {
FLAGS="$(toggleflag "$1" "$FLAGS")"
}
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
local contact="$(contact-numbers "$1" | cut -d ' ' -f 1)"
if [ -n "$contact" ]; then
echo "$contact"
else
echo "$1" |
# Remove the +44 and replace with 0
sed 's/^\+44/0/'
fi
}
answer-call(){
export DISPLAY=:0.0
dtmf(){
local id="$1"
svkbd-numbers &
local choice="$( (
echo "Exit"
) | rofi -dmenu -i -me-accept-entry '!MousePrimary' -p "Tones" -normal-window -font 'Iosevka 20' )"
if [ "$choice" = "Exit" ]; then
return
fi
echo "$choice" | grep -o '.' | while read -r tone; do
sleep 0.5
mmcli -m "$modem" -o "$id" --send-dtmf="$tone"
done
pkill svkbd-numbers
}
ongoingCall(){
local id="$1"
# Stolen from sxmo
FLAGS=" "
toggleflagset "-e"
toggleflagset "-m"
toggleflagset "-2"
toggleflagset "-2"
toggleflagset "-2"
notify-send "I get here"
while : ; do
choice="$( (
echo "Hang Up"
echo "DTMF Tones"
echo "Volume Up"
echo "Volume Down"
) | trofi)"
case "$choice" in
"Hang Up") rejectCall "$1"; break ;;
"DTMF Tones") dtmf "$1" ;;
"Volume"*) notify-send "Still need to implement" ;;
esac
done
}
answerCall(){
pkill mpv
sleep 0.2
echo "answer call $1" > /dev/tty
mmcli -m "$modem" -o "$1" --accept
ongoingCall "$1"
}
reject-call(){
rejectCall(){
pkill mpv
echo "reject call $1" > /dev/tty
mmcli -m "$modem" -o "$1" --hangup
mmcli -m "$modem" --voice-delete-call="$1"
mmcli -m "$modem" --voice-hangup-all
for CALLID in $( mmcli -m "$modem" --voice-list-calls | grep -oE "Call\/[0-9]+" | cut -d'/' -f2); do
echo mmcli -m "$modem" --voice-delete-call "$CALLID" > ~/.hangup.log
done
# Not sure why but sometimes the modem changes
# To be sure, re-check the modem and delete all calls
local tmpmodem="$(mmcli -L | grep -oE 'Modem\/[0-9]+' | head -n 1 | cut -d'/' -f2)"
mmcli -m "$tmpmodem" --voice-hangup-all
for CALLID in $( mmcli -m "$tmpmodem" --voice-list-calls | grep -oE "Call\/[0-9]+" | cut -d'/' -f2); do
echo mmcli -m "$tmpmodem" --voice-delete-call "$CALLID" > ~/.hangup.log
done
alsactl --file "$ALSA_CONF_DIR/default_alsa_sound.conf" restore
}
prompt-incoming(){
promptIncoming(){
export DISPLAY=:0.0
local answer=""
@ -62,11 +161,21 @@ prompt-incoming(){
esac
}
checkOutgoing(){
export DISPLAY=:0.0
if [ "$dryrun" = "true" ]; then
return
fi
notify-send "outgoing call" "$1"
mmcli -m "$modem" -o "$1" --start
ongoingCall "$1"
}
checkIncoming(){
export DISPLAY=:0.0
if [ "$dryrun" = "true" ]; then
prompt-incoming "+441234567890"
promptIncoming "+441234567890"
return
fi
local id="$( mmcli -m "$modem" --voice-list-calls |
@ -81,11 +190,12 @@ checkIncoming(){
local action=""
while mmcli -m "$modem" --voice-list-calls | grep -Eoq "$id"' incoming \(ringing-in\)' && [ -z "$action" ]; do
action="$(prompt-incoming "$contact")"
mpv "$HOME/.local/share/soundeffects/ringtone" --loop &
action="$(promptIncoming "$contact")"
done
case "$action" in
"accept") answer-call "$id"; break ;;
"reject") reject-call "$id"; break ;;
"accept") answerCall "$id"; ;;
"reject") rejectCall "$id"; ;;
esac
}
@ -95,6 +205,7 @@ checkFinished(){
grep -Eo '[0-9]+ incoming \(terminated\)' | grep -Eo '[0-9]+' )"
local count="$(echo "$ids" | deleteEmptyLines | wc -l)"
echo "Finished Count: $count"
[ "$count" -eq 0 ] && return
@ -103,13 +214,16 @@ checkFinished(){
local number="$(lookupnumberfromcallid "$id")"
local contact="$(lookupcontact "$number")"
echo "I get here"
# If there is a rofi process with the title of "call-from-number", then
# it hasn't been answerd yet.
# Treat as a missed call
if ps aux | grep -E '\Wrofi' | grep -q "call-from-$number"; then
if ps aux | grep -E '\Wrofi' | grep -q "call-from-$contact"; then
echo "Missed call from $contact" >> "$CALL_DIR/missed-calls"
pkill mpv
mmcli -m "$modem" --voice-delete-call "$id"
ps aux | grep -E '\Wrofi' | grep "call-from-$number" |
ps aux | grep -E '\Wrofi' | grep "call-from-$contact" |
awk '{print $2}' | xargs kill
fi
@ -140,8 +254,12 @@ while [[ $1 = -?* ]]; do
shift
done
checkIncoming &
checkFinished &
if [ -n "$1" ]; then
checkOutgoing "$1" &
else
checkIncoming &
checkFinished &
fi

@ -72,4 +72,4 @@ echo "$ids" | while read -r id; do
mmcli -m "$modem" --messaging-delete-sms="$id"
done
notify-send "$count new messages"
echo "$count new messages"

@ -2,6 +2,7 @@
CALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/Calls/"
SMS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/SMS/"
ALSA_CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/alsa/"
die(){
echo "$@" > /dev/stderr

@ -1,33 +1,67 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$DIR/common"
export DISPLAY=:0.0
prompt=""
answer=""
reject=""
options="1
4
7
*
2
5
8
0
$answer
3
6
9
#
X"
while true; do
#notify-send "$prompt"
input="$(echo "$options" |
rofi -dmenu -p "$prompt" -theme themes/dialer.rasi \
-me-select-entry '' -me-accept-entry MousePrimary)"
[ "$input" = "X" ] && exit
#exit
prompt+="$input"
usage(){
echo "dialer"
echo "Options:"
echo " -h|--help Display this help text"
echo " -m|--modem Specify a modem"
echo " -l|--letters Show letter keyboard rather than just numbers"
echo " --dry-run Don't actually call"
}
altKeyboard(){
notify-send "also here"
if [ "$keyboard" = "svkbd-numbers" ]; then
echo "svkbd-colemak"
else
echo "svkbd-numbers"
fi
}
modem="$(mmcli -L | grep -oE 'Modem\/[0-9]+' | head -n 1 | cut -d'/' -f2)"
keyboard="svkbd-numbers"
dryrun=""
# Read the options and set stuff
while [[ $1 = -?* ]]; do
case $1 in
-h|--help) usage; exit;;
-m|--modem) modem="$2"; shift ;;
-l|--letters) keyboard="svkbd-colemak"; shift ;;
--dry-run) dryrun="--dry-run" ;;
--) shift; break ;;
*) die "invalid option: '$1'." ;;
esac
shift
done
while : ; do
# Stop any running keyboards
pkill -9 'svkbd-*'
# Open the keyboard that we are using
"$keyboard" &
choice="$( (
echo "Switch Keyboard"
echo "Exit"
contact-numbers
) | rofi -dmenu -i -me-accept-entry '!MousePrimary' -p "Call" -normal-window -font 'Iosevka 20' )"
case "$choice" in
"Switch Keyboard") keyboard="$(altKeyboard)" ;;
"Exit") break ;;
*)
num="$(echo "$choice" | cut -d ' ' -f 2)"
pkill -9 'svkbd-*'
makeCall -m "$modem" $dryrun "$num"
break ;;
esac
done

@ -0,0 +1,41 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$DIR/common"
export DISPLAY=:0.0
usage(){
echo "makeCall number"
echo "Options:"
echo " -h|--help Display this help text"
echo " -m|--modem Specify a modem"
echo " --dry-run Don't actually call"
}
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="--dry-run" ;;
--) shift; break ;;
*) die "invalid option: '$1'." ;;
esac
shift
done
number="$1"
[ -z "$number" ] && die "No Number Specified"
callID="$(mmcli -m "$modem" --voice-create-call "number=$number" |
grep -Eo 'Call\/[0-9]+' | head -n 1 | cut -d'/' -f2)"
checkCall $dryrun "$callID"

@ -5,6 +5,8 @@
#
# Although the proccess for managing calls etc is a bit simpler IMO
export DISPLAY=:0.0
# Monitor for incoming calls
dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Voice',type='signal',member='CallAdded'" | \
while read -r line; do
@ -14,6 +16,7 @@ dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Voice',typ
# Monitor for incoming texts
dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Messaging',type='signal',member='Added'" | \
while read -r line; do
notify-send "Added (SMS)"
echo "$line" | grep -E "^signal" && checkSMS
done &

@ -0,0 +1,10 @@
#!/usr/bin/env bash
battery="$(cat /sys/class/power_supply/axp20x-battery/capacity)"
batteryStatus="$(cat /sys/class/power_supply/axp20x-battery/status)"
[ "$batteryStatus" = "Charging" ] && batteryIcon="🔌" || batteryIcon="🔋"
time="$(date "+%H:%M")"
notify-send "$(hostname)" "$batteryIcon ${battery}%\nTime $time"

@ -0,0 +1,7 @@
#!/usr/bin/env bash
if pidof svkbd-colemak || pidof svkbd-numbers; then
pkill "svkbd-*"
else
svkbd-colemak & disown
fi

@ -43,6 +43,7 @@ case "$1" in
else
amixer -q -D default sset Master toggle
fi
;;
esac
if type -p pulseaudio-ctl 2> /dev/null; then

@ -69,7 +69,7 @@ inputbar {
listview {
background-color: @background-alt;
columns: 7;
columns: 3;
lines: 4;
spacing: 2%;
cycle: false;

@ -0,0 +1,18 @@
configuration {
font: "iosevka 30";
disable-history: false;
fullscreen: false;
hide-scrollbar: true;
sidebar-mode: false;
}
@import "gruvbox-dark.rasi"
window {
width: 90%;
}
mainbox {
children: [ listview ];
}

@ -0,0 +1,107 @@
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: 500px;
location: east;
x-offset: -15px;
y-offset: 0px;
}
listview {
lines: 3;
margin: 8px;
spacing: 8px;
cycle: true;
dynamic: true;
layout: vertical;
}
mainbox {
background-color: @background;
children: [ inputbar, listview ];
}
prompt{
text-align: center;
background-color: red;
position: center;
horizontal-align: 0.5;
}
inputbar {
children: [ prompt ];
spacing: 0px;
background-color: @background;
text-color: @foreground;
expand: false;
horizontal-align: 0.5;
border: 0px;
border-radius: 0px;
border-color: @accent;
margin: 0px 0px 0px 0px;
padding: 0px;
position: center;
text-align: center;
}
element {
background-color: @background-light;
text-color: @foreground;
orientation: vertical;
border-radius: 12px;
}
element-text {
font: "iosevka 25";
expand: true;
horizontal-align: 0.5;
vertical-align: 0;
margin: 10px 10px 33px 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;
}

@ -0,0 +1,9 @@
[Unit]
Description=Monitor Modem
[Service]
Environment="PATH=/usr/bin:/usr/local/bin:/home/jonathan/.bin:/home/jonathan/.bin/modem:/home/jonathan/.bin/dmenu"
ExecStart=/home/jonathan/.bin/modem/monitorModem
[Install]
WantedBy=default.target

@ -0,0 +1,9 @@
[Unit]
Description=Enable user access to pinephone hardware kernel interface
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'for i in /sys/module/8723cs/parameters/rtw_scan_interval_thr /sys/devices/platform/backlight/backlight/backlight/brightness /sys/power/state /sys/devices/platform/soc/1f00000.rtc/power/wakeup /sys/power/mem_sleep /sys/bus/usb/drivers/usb/unbind /sys/bus/usb/drivers/usb/bind /sys/class/leds/red:indicator/brightness /sys/class/leds/blue:indicator/brightness /sys/class/leds/green:indicator/brightness /sys/class/leds/white:flash/brightness /dev/rtc0 /sys/devices/platform/soc/1f03400.rsb/sunxi-rsb-3a3/axp221-pek/power/wakeup /sys/class/wakeup/*; do [ -e "$i" ] && chmod a+rw "$i" >> /tmp/log 2>&1; done'
[Install]
WantedBy=multi-user.target

@ -33,6 +33,7 @@ xinput --list | grep -Ei 'ErgoDox EZ\s+id' | grep -oE 'id=[0-9]+' |
type -p compton > /dev/null && exec /usr/bin/compton --config "$HOME/.config/picom/picom.conf" &
#setbackground &
#/usr/bin/nitrogen --restore &
[ -e $HOME/Pictures/wallpaper ] && type -p feh > /dev/null && feh --bg-fill $HOME/Pictures/wallpaper
/usr/bin/systemctl --user start background.service
[ -f /usr/lib/kdeconnectd ] && /usr/lib/kdeconnectd &
[ -f /usr/bin/pactl ] && /usr/bin/pactl load-module module-switch-on-connect &
@ -45,6 +46,8 @@ if hostname | grep -q phone; then
xrandr --output DSI-1 --mode 720x1440 --dpi 192
fi
dunst &
#greenclip daemon &
#exec xrdb .Xresources
#xbindkeys

Loading…
Cancel
Save