Refactor ts-control with bashly
This commit is contained in:
		
							parent
							
								
									93ebbbd5d2
								
							
						
					
					
						commit
						7694bf365c
					
				
					 21 changed files with 217 additions and 175 deletions
				
			
		
							
								
								
									
										0
									
								
								control_src/lib/ntfy.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								control_src/lib/ntfy.sh
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										46
									
								
								control_src/lib/simple.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								control_src/lib/simple.sh
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,46 @@ | |||
| _ts_control_get_entity() { | ||||
| 	entity=$(_ts_control_single_or_dmenu "$(teamspeak-query-lib "$1s")" "$2") | ||||
| 	if [ -z "$entity" ]; then | ||||
| 		exit 1 | ||||
| 	fi | ||||
| 	echo "$entity" | ||||
| } | ||||
| 
 | ||||
| _ts_control_get_message() { | ||||
| 	if [ -n "$1" ]; | ||||
| 	then | ||||
| 		message="$1" | ||||
| 	else | ||||
| 		message=$(printf "\n" | $DMENU -p "message") | ||||
| 	fi | ||||
| 
 | ||||
| 	if [ -z "$message" ]; then | ||||
| 		exit 1 | ||||
| 	fi | ||||
| 
 | ||||
| 	echo "$message" | ||||
| } | ||||
| 
 | ||||
| _ts_control_move_self() { | ||||
| 	channel=$(_ts_control_get_entity channel "$1" "$2") | ||||
| 	teamspeak-query-lib move --strict-channel "$channel" | ||||
| } | ||||
| 
 | ||||
| _ts_control_fetch() { | ||||
| 	target=$(_ts_control_get_entity "$1" "$2") | ||||
| 	teamspeak-query-lib fetch "--strict-$1" "--$1" "$target" | ||||
| } | ||||
| 
 | ||||
| _ts_control_single_or_dmenu() { | ||||
| 	filter="$2" | ||||
| 	if [ "$filter" == "^$" ]; then | ||||
| 		filter="" | ||||
| 	fi | ||||
| 	options=$(echo "$1" | grep "$filter") | ||||
| 	count=$(echo "$options" | wc -l) | ||||
| 	if [ "$count" -eq 1 ]; then | ||||
| 		echo "$options" | ||||
| 	else | ||||
| 		echo "$1" | $DMENU | ||||
| 	fi | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue