mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-05 21:28:48 +00:00
Merge pull request #163 from jeevithakannan2/utilities
Fixes for utilities
This commit is contained in:
commit
d62f9ef613
|
@ -1,4 +1,33 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh -e
|
||||
|
||||
. ../common-script.sh
|
||||
|
||||
# Function to check bluetoothctl is installed
|
||||
setupBluetooth() {
|
||||
echo "Install bluetoothctl if not already installed..."
|
||||
if ! command_exists bluetoothctl; then
|
||||
case ${PACKAGER} in
|
||||
pacman)
|
||||
$ESCALATION_TOOL "${PACKAGER}" -S --noconfirm bluez-utils
|
||||
;;
|
||||
*)
|
||||
$ESCALATION_TOOL "${PACKAGER}" install -y bluez
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "Bluetoothctl is already installed."
|
||||
fi
|
||||
|
||||
# Check if bluetooth service is running
|
||||
if ! systemctl is-active --quiet bluetooth; then
|
||||
echo "Bluetooth service is not running. Starting it now..."
|
||||
$ESCALATION_TOOL systemctl start bluetooth
|
||||
|
||||
if systemctl is-active --quiet bluetooth; then
|
||||
echo "bluetooth service started successfully."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to display colored text
|
||||
colored_echo() {
|
||||
|
@ -128,4 +157,6 @@ remove_device() {
|
|||
}
|
||||
|
||||
# Initialize
|
||||
checkEnv
|
||||
setupBluetooth
|
||||
main_menu
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
# Function to auto-detect displays and set common resolution
|
||||
auto_detect_displays() {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
# Function to change monitor orientation
|
||||
change_orientation() {
|
||||
monitor_list=$(detect_connected_monitors)
|
||||
IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list"
|
||||
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
|
||||
|
||||
clear
|
||||
echo -e "${BLUE}=========================================${RESET}"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
RESET='\033[0m'
|
||||
BOLD='\033[1m'
|
||||
|
@ -12,7 +13,7 @@ CYAN='\033[36m'
|
|||
# Function to disable a monitor
|
||||
disable_monitor() {
|
||||
monitor_list=$(detect_connected_monitors)
|
||||
IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list"
|
||||
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
|
||||
|
||||
clear
|
||||
echo -e "${BLUE}=========================================${RESET}"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
# Function to duplicate displays
|
||||
duplicate_displays() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
RESET='\033[0m'
|
||||
BOLD='\033[1m'
|
||||
|
@ -12,7 +13,7 @@ CYAN='\033[36m'
|
|||
# Function to enable a monitor
|
||||
enable_monitor() {
|
||||
monitor_list=$(detect_connected_monitors)
|
||||
IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list"
|
||||
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
|
||||
|
||||
clear
|
||||
echo -e "${BLUE}=========================================${RESET}"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
# Function to extend displays
|
||||
extend_displays() {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
# Function to manage monitor arrangement
|
||||
manage_arrangement() {
|
||||
monitor_list=$(detect_connected_monitors)
|
||||
IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list"
|
||||
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
|
||||
|
||||
clear
|
||||
echo -e "${BLUE}=========================================${RESET}"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
# Function to reset scaling back to 1 (native resolution) for all monitors
|
||||
reset_scaling() {
|
||||
|
@ -8,7 +9,7 @@ reset_scaling() {
|
|||
echo -e "${BLUE}=========================================${RESET}"
|
||||
|
||||
monitor_list=$(detect_connected_monitors)
|
||||
IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list"
|
||||
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
|
||||
|
||||
for monitor in "${monitor_array[@]}"; do
|
||||
echo -e "${CYAN}Resetting scaling for $monitor to 1x1 (native resolution)${RESET}"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
# Function to scale smaller monitors to the highest resolution of a bigger monitor
|
||||
scale_monitors() {
|
||||
|
@ -8,7 +9,7 @@ scale_monitors() {
|
|||
echo -e "${BLUE}=========================================${RESET}"
|
||||
|
||||
monitor_list=$(detect_connected_monitors)
|
||||
IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list"
|
||||
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
|
||||
|
||||
# Get the highest resolution among all monitors
|
||||
max_width=0
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
# Function to set a monitor as primary
|
||||
set_primary_monitor() {
|
||||
monitor_list=$(detect_connected_monitors)
|
||||
IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list"
|
||||
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
|
||||
|
||||
clear
|
||||
echo -e "${BLUE}=========================================${RESET}"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
source ./utility_functions.sh
|
||||
#!/bin/sh -e
|
||||
|
||||
. ./utility_functions.sh
|
||||
|
||||
RESET='\033[0m'
|
||||
BOLD='\033[1m'
|
||||
|
@ -12,7 +13,7 @@ CYAN='\033[36m'
|
|||
# Function to set resolutions
|
||||
set_resolutions() {
|
||||
monitor_list=$(detect_connected_monitors)
|
||||
IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list"
|
||||
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
|
||||
|
||||
while true; do
|
||||
clear
|
||||
|
|
|
@ -1,4 +1,39 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh -e
|
||||
|
||||
. ../../common-script.sh
|
||||
|
||||
# Function to check bluetoothctl is installed
|
||||
setup_xrandr() {
|
||||
echo "Install xrandr if not already installed..."
|
||||
if ! command_exists xrandr; then
|
||||
case ${PACKAGER} in
|
||||
pacman)
|
||||
$ESCALATION_TOOL "${PACKAGER}" -S --noconfirm xorg-xrandr
|
||||
;;
|
||||
apt-get)
|
||||
$ESCALATION_TOOL "${PACKAGER}" install -y x11-xserver-utils
|
||||
;;
|
||||
*)
|
||||
$ESCALATION_TOOL "${PACKAGER}" install -y xorg-x11-server-utils
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "xrandr is already installed."
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to display colored text
|
||||
colored_echo() {
|
||||
local color=$1
|
||||
local text=$2
|
||||
case $color in
|
||||
red) echo -e "\033[31m$text\033[0m" ;;
|
||||
green) echo -e "\033[32m$text\033[0m" ;;
|
||||
yellow) echo -e "\033[33m$text\033[0m" ;;
|
||||
blue) echo -e "\033[34m$text\033[0m" ;;
|
||||
*) echo "$text" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to execute xrandr commands and handle errors
|
||||
execute_command() {
|
||||
|
@ -47,3 +82,6 @@ confirm_action() {
|
|||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkEnv
|
||||
setup_xrandr
|
|
@ -25,10 +25,6 @@ matches = true
|
|||
data = { environment = "DISPLAY" }
|
||||
values = [":0", ":1", ":2", ":3", ":4", ":5", ":6", ":7", ":8", ":9"]
|
||||
|
||||
[[data.entries]]
|
||||
name = "Set Resolution"
|
||||
script = "monitor-control/set_resolutions.sh"
|
||||
|
||||
[[data.entries]]
|
||||
name = "Duplicate Displays"
|
||||
script = "monitor-control/duplicate_displays.sh"
|
||||
|
|
|
@ -1,5 +1,36 @@
|
|||
@@ -0,0 +1,168 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh -e
|
||||
|
||||
. ../common-script.sh
|
||||
|
||||
# Function to check if NetworkManager is installed
|
||||
setupNetworkManager() {
|
||||
echo "Install NetworkManger if not already installed..."
|
||||
if ! command_exists nmcli; then
|
||||
case ${PACKAGER} in
|
||||
pacman)
|
||||
$ESCALATION_TOOL "${PACKAGER}" -S --noconfirm networkmanager
|
||||
;;
|
||||
dnf)
|
||||
$ESCALATION_TOOL "${PACKAGER}" install -y NetworkManager-1
|
||||
;;
|
||||
*)
|
||||
$ESCALATION_TOOL "${PACKAGER}" install -y network-manager
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "NetworkManager is already installed."
|
||||
fi
|
||||
|
||||
# Check if NetworkManager service is running
|
||||
if ! systemctl is-active --quiet NetworkManager; then
|
||||
echo "NetworkManager service is not running. Starting it now..."
|
||||
$ESCALATION_TOOL systemctl start NetworkManager
|
||||
|
||||
if systemctl is-active --quiet NetworkManager; then
|
||||
echo "NetworkManager service started successfully."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to display colored text
|
||||
colored_echo() {
|
||||
|
@ -166,4 +197,6 @@ remove_network() {
|
|||
}
|
||||
|
||||
# Initialize
|
||||
checkEnv
|
||||
setupNetworkManager
|
||||
main_menu
|
||||
|
|
Loading…
Reference in New Issue
Block a user