Work on incoming calls
Unlike SXMO, I have opted to use rofi to prompt for an incoming call. This allows me to have accept and decline buttons easily rather than multiple notifications.
This commit is contained in:
		
							parent
							
								
									972977e0cb
								
							
						
					
					
						commit
						0b4566affc
					
				
					 2 changed files with 150 additions and 22 deletions
				
			
		|  | @ -30,11 +30,13 @@ lookupcontact(){ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| answer-call(){ | answer-call(){ | ||||||
|  | 	export DISPLAY=:0.0 | ||||||
|  | 	echo "answer call $1" > /dev/tty | ||||||
| 	mmcli -m "$modem" -o "$1" --accept | 	mmcli -m "$modem" -o "$1" --accept | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| reject-call(){ | reject-call(){ | ||||||
| 	notify-send "Reject" | 	mmcli -m "$modem" -o "$1" --hangup | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| prompt-incoming(){ | prompt-incoming(){ | ||||||
|  | @ -45,22 +47,20 @@ prompt-incoming(){ | ||||||
| 
 | 
 | ||||||
| 	local choice='' | 	local choice='' | ||||||
| 	# Used for testing | 	# Used for testing | ||||||
| 	local number="${1:-01234 567890}" | 	local contact="${1:-01234 567890}" | ||||||
| 
 | 
 | ||||||
| 	local prompt="$(echo -en "Incoming Call\n$number")" | 	local prompt="$(echo -en "Incoming Call\n$contact")" | ||||||
| 
 | 
 | ||||||
| 	while [ -z "$choice" ]; do | 	choice="$(echo -e "$answer\n$reject" | rofi -dmenu -i \ | ||||||
|  | 		-theme themes/incoming-call.rasi -a 0 -u 1 \ | ||||||
|  | 		-p "$prompt" \ | ||||||
|  | 		-window-title "call-from-$contact" \ | ||||||
|  | 		-me-select-entry '' -me-accept-entry MousePrimary)" | ||||||
| 
 | 
 | ||||||
| 		choice="$(echo -e "$answer\n$reject" | rofi -dmenu -i \ | 	case "$choice" in | ||||||
| 			-theme themes/incoming-call.rasi -a 0 -u 1 \ | 		"$answer") echo "accept" ;; | ||||||
| 			-p "$prompt" \ | 		"$reject") echo "reject" ;; | ||||||
| 			-me-select-entry '' -me-accept-entry MousePrimary)" | 	esac | ||||||
| 
 |  | ||||||
| 		case "$choice" in |  | ||||||
| 			"$answer") echo "answer" ;; |  | ||||||
| 			"$reject") echo "reject" ;; |  | ||||||
| 		esac |  | ||||||
| 	done |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| mkdir -p "$CALL_DIR" | mkdir -p "$CALL_DIR" | ||||||
|  | @ -87,6 +87,7 @@ done | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| checkIncoming(){ | checkIncoming(){ | ||||||
|  | 	export DISPLAY=:0.0 | ||||||
| 	local id="$( mmcli -m "$modem" --voice-list-calls | | 	local id="$( mmcli -m "$modem" --voice-list-calls | | ||||||
| 		grep -Eo '[0-9]+ incoming \(ringing-in\)' | grep -Eo '[0-9]+' )" | 		grep -Eo '[0-9]+ incoming \(ringing-in\)' | grep -Eo '[0-9]+' )" | ||||||
| 
 | 
 | ||||||
|  | @ -97,12 +98,15 @@ checkIncoming(){ | ||||||
| 	local number="$(lookupnumberfromcallid "$id")" | 	local number="$(lookupnumberfromcallid "$id")" | ||||||
| 	local contact="$(lookupcontact "$number")" | 	local contact="$(lookupcontact "$number")" | ||||||
| 
 | 
 | ||||||
| 	local action="$(prompt-incoming "$contact")" | 	local action="" | ||||||
| 
 | 	while mmcli -m "$modem" --voice-list-calls | grep -Eoq "$id"' incoming \(ringing-in\)' && [ -z "$action" ]; do | ||||||
| 	case action in | 		action="$(prompt-incoming "$contact")" | ||||||
| 		accept) answer-call "$id" ;; | 	done | ||||||
| 		reject) reject-call "$id" ;; | 	case "$action" in | ||||||
|  | 		"accept") answer-call "$id"; break ;; | ||||||
|  | 		"reject") reject-call "$id"; break ;; | ||||||
| 	esac | 	esac | ||||||
|  | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| checkFinished(){ | checkFinished(){ | ||||||
|  | @ -113,14 +117,24 @@ checkFinished(){ | ||||||
| 
 | 
 | ||||||
| 	[ "$count" -eq 0 ] && return | 	[ "$count" -eq 0 ] && return | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| 	echo "$ids" | while read -r id; do | 	echo "$ids" | while read -r id; do | ||||||
| 		# Delete from the modem | 		# Delete from the modem | ||||||
| 		local number="$(lookupnumberfromcallid "$id")" | 		local number="$(lookupnumberfromcallid "$id")" | ||||||
| 		local contact="$(lookupcontact "$number")" | 		local contact="$(lookupcontact "$number")" | ||||||
| 
 | 
 | ||||||
| 		echo "Missed call from $contact" >> "$CALL_DIR/missed-calls" | 		# If there is a rofi process with the title of "call-from-number", then | ||||||
| 		mmcli -m "$modem" --voice-delete-call "$id" | 		# it hasn't been answerd yet. | ||||||
| 		 | 		# Treat as a missed call | ||||||
|  | 		if ps aux | grep -E '\Wrofi' | grep -q "call-from-$number"; then | ||||||
|  | 			echo "Missed call from $contact" >> "$CALL_DIR/missed-calls" | ||||||
|  | 			mmcli -m "$modem" --voice-delete-call "$id" | ||||||
|  | 			ps aux | grep -E '\Wrofi' | grep "call-from-$number" |  | ||||||
|  | 				awk '{print $2}' | xargs kill | ||||||
|  | 		fi | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 			 | ||||||
| 	done | 	done | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										114
									
								
								rofi/.config/rofi/themes/incoming-call.rasi
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								rofi/.config/rofi/themes/incoming-call.rasi
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,114 @@ | ||||||
|  | /* | ||||||
|  |  * Adapted from code from: | ||||||
|  |  * | ||||||
|  |  * Author  : Aditya Shakya | ||||||
|  |  * Mail    : adi1090x@gmail.com | ||||||
|  |  * Github  : @adi1090x | ||||||
|  |  * Twitter : @adi1090x | ||||||
|  |  * | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | configuration { | ||||||
|  | 	font:							"iosevka 45"; | ||||||
|  |     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:                  0px; | ||||||
|  |     location:                       north; | ||||||
|  | 	width:							500px; | ||||||
|  |     y-offset:                       45px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | prompt { | ||||||
|  |     enabled: 						true; | ||||||
|  |     padding:                        1px; | ||||||
|  | 	background-color: 				@background-light; | ||||||
|  | 	text-color: 					@accent; | ||||||
|  |     border:                  		0px; | ||||||
|  |     border-radius:                  0px; | ||||||
|  |     border-color:                  	@accent; | ||||||
|  | 	left:							2px; | ||||||
|  | 	text-align:						center; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | inputbar { | ||||||
|  | 	children: 						[ prompt ]; | ||||||
|  |     spacing:                        0px; | ||||||
|  |     background-color:               @background; | ||||||
|  |     text-color:                     @foreground; | ||||||
|  |     expand:                         false; | ||||||
|  |     border:                  		0px; | ||||||
|  |     border-radius:                  0px; | ||||||
|  |     border-color:                  	@accent; | ||||||
|  |     margin:                         0px 0px 0px 0px; | ||||||
|  |     padding:                        0px; | ||||||
|  |     position:                       west; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | listview { | ||||||
|  |     columns:						6; | ||||||
|  |     lines:							1; | ||||||
|  |     spacing:                        12px; | ||||||
|  |     cycle:                          true; | ||||||
|  |     dynamic:                        true; | ||||||
|  |     layout:                         vertical; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | mainbox { | ||||||
|  |     background-color:               @background; | ||||||
|  |     children:                       [ inputbar, listview ]; | ||||||
|  |     spacing:                        12px; | ||||||
|  |     margin:                         12px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | element { | ||||||
|  |     background-color:               @background-light; | ||||||
|  |     text-color:                     @foreground; | ||||||
|  |     orientation:                    vertical; | ||||||
|  |     border-radius:                  0px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | element-text { | ||||||
|  | 	font:							"iosevka 45"; | ||||||
|  |     expand:                         true; | ||||||
|  |     horizontal-align:               0.5; | ||||||
|  |     vertical-align:                 0; | ||||||
|  |     margin:                         5px 10px 30px 10px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | element normal.urgent, | ||||||
|  | element alternate.urgent, | ||||||
|  | element selected.urgent { | ||||||
|  | 	background-color:               @gruvbox-dark-red; | ||||||
|  |     text-color:                     @background; | ||||||
|  |     border-radius:                  0px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | element normal.active, | ||||||
|  | element alternate.active, | ||||||
|  | element selected.active { | ||||||
|  |     background-color:               @gruvbox-dark-green; | ||||||
|  |     text-color:                     @background; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | element selected { | ||||||
|  |     background-color:               @accent; | ||||||
|  |     text-color:                     @background; | ||||||
|  |     border:                  		0px; | ||||||
|  |     border-radius:                  0px; | ||||||
|  |     border-color:                  	@border; | ||||||
|  | } | ||||||
|  | 
 | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue