добавлены конфиги: Hyprland, Hyprpaper, Hyprlock, Waybar, Rofi

This commit is contained in:
retrilzzy committed 2024-10-24 23:25:09 +05:00
1 parent 315746dbd1
commit fc9c715351
26 files changed
+1984 -2

No files matched your search

+92
View File
@@ -0,0 +1,92 @@
#!/bin/bash
# Print error message for invalid arguments
print_error() {
cat <<"EOF"
Usage: ./brightnesscontrol.sh <action>
Valid actions are:
i -- <i>ncrease brightness [+5%]
d -- <d>ecrease brightness [-5%]
EOF
}
# Send a notification with brightness info
send_notification() {
brightness=$(brightnessctl info | grep -oP "(?<=\()\d+(?=%)")
notify-send -r 91190 "Brightness: ${brightness}%"
}
# Get the current brightness percentage and device name
get_brightness() {
brightness=$(brightnessctl -m | grep -o '[0-9]\+%' | head -c-2)
device=$(brightnessctl -m | head -n 1 | awk -F',' '{print $1}' | sed 's/_/ /g; s/\<./\U&/g') # Get device name
current_brightness=$(brightnessctl -m | head -n 1 | awk -F',' '{print $3}') # Get current brightness
max_brightness=$(brightnessctl -m | head -n 1 | awk -F',' '{print $5}') # Get max brightness
}
get_brightness
# Handle options
while getopts o: opt; do
case "${opt}" in
o)
case $OPTARG in
i) # Increase brightness
if [[ $brightness -lt 10 ]]; then
brightnessctl set +1%
else
brightnessctl set +5%
fi
send_notification
;;
d) # Decrease brightness
if [[ $brightness -le 1 ]]; then
brightnessctl set 1%
elif [[ $brightness -le 10 ]]; then
brightnessctl set 1%-
else
brightnessctl set 5%-
fi
send_notification
;;
*)
print_error
;;
esac
;;
*)
print_error
;;
esac
done
# Determine the icon based on brightness level
get_icon() {
if ((brightness <= 5)); then
icon=""
elif ((brightness <= 15)); then
icon=""
elif ((brightness <= 30)); then
icon=""
elif ((brightness <= 45)); then
icon=""
elif ((brightness <= 55)); then
icon=""
elif ((brightness <= 65)); then
icon=""
elif ((brightness <= 80)); then
icon=""
elif ((brightness <= 95)); then
icon=""
else
icon=""
fi
}
# Backlight module and tooltip
get_icon
module="${icon} ${brightness}%"
tooltip="Device Name: ${device}"
tooltip+="\nBrightness: ${current_brightness} / ${max_brightness}"
echo "{\"text\": \"${module}\", \"tooltip\": \"${tooltip}\"}"
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
# Get CPU clock speeds
freqlist=$(awk '/cpu MHz/ {print $4}' /proc/cpuinfo) # Extract clock speed in MHz
maxfreq=$(sed 's/...$//' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq) # Max CPU frequency
frequency=$(echo "$freqlist" | tr ' ' '\n' | awk "{sum+=\$1} END {printf \"%.0f/$maxfreq MHz\", sum/NR}") # Average frequency
# Get CPU temperature in Celsius
temp=$(sensors | awk '/Package id 0/ {print $4}' | awk -F '[+.]' '{print $2}') # Package temperature
if [[ -z "$temp" ]]; then
temp=$(sensors | awk '/Tctl/ {print $2}' | tr -d '+°C') # Fallback to Tctl if Package id 0 is empty
fi
if [[ -z "$temp" ]]; then
temp="N/A" # If no temp found, set to N/A
fi
# Map icons based on temperature and utilization
set_ico="{\"thermo\":{\"0\":\"󱃃\",\"45\":\"󰔏\",\"65\":\"󱃂\",\"85\":\"󰸁\"},\"util\":{\"0\":\"󰾆\",\"30\":\"󰾅\",\"60\":\"󰓅\",\"90\":\"󰀪\"}}"
eval_ico() {
local key="$1"
local value="$2"
map_ico=$(echo "$set_ico" | jq -r --arg aky "$key" --argjson avl "$value" '.[$aky] | keys_unsorted | map(tonumber) | map(select(. <= $avl)) | max')
echo "$set_ico" | jq -r --arg aky "$key" --arg avl "$map_ico" '.[$aky] | .[$avl]' # Get the corresponding icon
}
thermo=$(eval_ico thermo "$temp") # Get temperature icon
tooltip="Clock Speed: ${frequency}"
# Module and tooltip
echo "{\"text\": \"${thermo} ${temp}°C\", \"tooltip\": \"$tooltip\"}"
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
# Get CPU model (removed "(R)", "(TM)", and clock speed)
model=$(awk -F ': ' '/model name/{print $2}' /proc/cpuinfo | head -n 1 | sed 's/@.*//; s/ *\((R)\|(TM)\)//g; s/^[ \t]*//; s/[ \t]*$//')
# Get CPU usage percentage
load=$(vmstat 1 2 | tail -1 | awk '{print 100 - $15}')
# Determine CPU state based on usage
if [ "$load" -le 25 ]; then
state="Low"
elif [ "$load" -le 50 ]; then
state="Medium"
else
state="High"
fi
tooltip="${model}"
tooltip+="\nCPU Usage: ${state}"
# Module and tooltip
echo "{\"text\": \"󰻠 ${load}%\", \"tooltip\": \"${tooltip}\"}"
Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

+60
View File
@@ -0,0 +1,60 @@
#!/bin/bash
# Check if wlogout is already running
if pgrep -x "wlogout" > /dev/null; then
pkill -x "wlogout"
exit 0
fi
# Define configuration directories
confDir="${XDG_CONFIG_HOME:-$HOME/.config}"
# Style selection
[ -z "${1}" ] || wlogoutStyle="${1}"
wLayout="${confDir}/wlogout/layout_${wlogoutStyle}"
wlTmplt="${confDir}/wlogout/style_${wlogoutStyle}.css"
if [ ! -f "${wLayout}" ] || [ ! -f "${wlTmplt}" ]; then
echo "ERROR: Config ${wlogoutStyle} not found..."
wlogoutStyle=1
wLayout="${confDir}/wlogout/layout_${wlogoutStyle}"
wlTmplt="${confDir}/wlogout/style_${wlogoutStyle}.css"
fi
# Detect monitor resolution
x_mon=$(hyprctl -j monitors | jq '.[] | select(.focused==true) | .width')
y_mon=$(hyprctl -j monitors | jq '.[] | select(.focused==true) | .height')
hypr_scale=$(hyprctl -j monitors | jq '.[] | select(.focused == true) | .scale' | sed 's/\.//')
# Scale config layout and style
case "${wlogoutStyle}" in
1)
wlColms=6
export mgn=$(( y_mon * 38 / hypr_scale ))
export hvr=$(( y_mon * 33 / hypr_scale ))
;;
2)
wlColms=2
export x_mgn=$(( x_mon * 38 / hypr_scale ))
export y_mgn=$(( y_mon * 28 / hypr_scale ))
export x_hvr=$(( x_mon * 35 / hypr_scale ))
export y_hvr=$(( y_mon * 23 / hypr_scale ))
;;
esac
# Scale font size
export fntSize=$(( y_mon * 2 / 100 ))
export BtnCol="white" # Default button color
# Evaluate hypr border radius
hypr_border="$(hyprctl -j getoption decoration:rounding | jq '.int')"
export hypr_border
export active_rad=$(( hypr_border * 5 ))
export button_rad=$(( hypr_border * 8 ))
# Evaluate config files
wlStyle=$(envsubst < "$wlTmplt")
# Launch wlogout
wlogout -b "${wlColms}" -c 0 -r 0 -m 0 --layout "${wLayout}" --css <(echo "${wlStyle}") --protocol layer-shell
+111
View File
@@ -0,0 +1,111 @@
#!/bin/bash
# Define functions
print_error() {
cat <<"EOF"
Usage: ./volumecontrol.sh -[device] <actions>
...valid devices are...
i -- input device
o -- output device
p -- player application
...valid actions are...
i -- increase volume [+5]
d -- decrease volume [-5]
m -- mute [x]
EOF
exit 1
}
send_notification() {
vol=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | sed 's/%//')
notify-send -r 91190 "Volume: ${vol}%"
}
notify_mute() {
mute=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}')
if [ "${mute}" = "yes" ]; then
notify-send -r 91190 "Muted"
else
notify-send -r 91190 "Unmuted"
fi
}
action_volume() {
case "${1}" in
i)
# Check current volume and increase only if below 100
current_vol=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | sed 's/%//')
if [ "$current_vol" -lt 100 ]; then
new_vol=$((current_vol + 5))
if [ "$new_vol" -gt 100 ]; then
new_vol=100
fi
pactl set-sink-volume @DEFAULT_SINK@ "${new_vol}%"
fi
;;
d)
# Decrease volume, ensuring it doesn't drop below 0%
current_vol=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | sed 's/%//')
new_vol=$((current_vol - 5))
if [ "$new_vol" -lt 0 ]; then
new_vol=0
fi
pactl set-sink-volume @DEFAULT_SINK@ "${new_vol}%"
;;
esac
}
select_output() {
if [ "$@" ]; then
desc="$*"
device=$(pactl list sinks | grep -C2 -F "Description: $desc" | grep Name | cut -d: -f2 | xargs)
if pactl set-default-sink "$device"; then
notify-send -r 91190 "Activated: $desc"
else
notify-send -r 91190 "Error activating $desc"
fi
else
pactl list sinks | grep -ie "Description:" | awk -F ': ' '{print $2}' | sort
fi
}
# Evaluate device option
while getopts iops: DeviceOpt; do
case "${DeviceOpt}" in
i)
nsink=$(pactl list sources short | awk '{print $2}')
[ -z "${nsink}" ] && echo "ERROR: Input device not found..." && exit 0
srce="--default-source"
;;
o)
nsink=$(pactl list sinks short | awk '{print $2}')
[ -z "${nsink}" ] && echo "ERROR: Output device not found..." && exit 0
srce=""
;;
p)
nsink=$(playerctl --list-all | grep -w "${OPTARG}")
[ -z "${nsink}" ] && echo "ERROR: Player ${OPTARG} not active..." && exit 0
# shellcheck disable=SC2034
srce="${nsink}"
;;
s)
# Select an output device
select_output "$@"
exit
;;
*) print_error ;;
esac
done
# Set default variables
shift $((OPTIND - 1))
# Execute action
case "${1}" in
i) action_volume i ;;
d) action_volume d ;;
m) pactl set-sink-mute @DEFAULT_SINK@ toggle && notify_mute && exit 0 ;;
*) print_error ;;
esac
send_notification
+178
View File
@@ -0,0 +1,178 @@
#!/bin/bash
# This script gathers detailed Wi-Fi connection information.
# It collects the following fields:
#
# - SSID (Service Set Identifier): The name of the Wi-Fi network you
# are currently connected to. Example: "My_Network"
#
# - IP Address: The IP address assigned to the device by the router.
# This is typically a private IP within the local network. Example:
# "192.168.1.29/24" (with subnet mask)
#
# - Router (Gateway): The IP address of the router (default gateway)
# that your device uses to communicate outside the local network.
# Example: "192.168.1.1"
#
# - MAC Address: The unique Media Access Control address of the local
# device's Wi-Fi adapter. Example: "F8:34:41:07:1B:65"
#
# - Security: The encryption protocol being used to secure your Wi-Fi
# connection. Common security protocols include:
# - WPA2 (Wi-Fi Protected Access 2): The most commonly used security
# standard, offering strong encryption (AES).
# - WPA3: The latest version, providing even stronger security,
# especially in public or open networks.
# - WEP (Wired Equivalent Privacy): An outdated and insecure protocol
# that should not be used.
# Example: "WPA2" indicates that the connection is secured using WPA2
# with AES encryption.
#
# - BSSID (Basic Service Set Identifier): The MAC address of the Wi-Fi
# access point you are connected to. Example: "A4:22:49:DA:91:A0"
#
# - Channel: The wireless channel your Wi-Fi network is using. This is
# associated with the frequency band. Example: "100 (5500 MHz)"
# indicates the channel number (100) and the frequency (5500 MHz),
# which is within the 5 GHz band.
#
# - RSSI (Received Signal Strength Indicator): The strength of the
# Wi-Fi signal, typically in dBm (decibels relative to 1 milliwatt).
# Closer to 0 means stronger signal, with values like -40 dBm being
# very good. Example: "-40 dBm"
#
# - Signal: The signal quality, which is represented as a percentage,
# where higher numbers mean better signal. Example: "100"
# indicates perfect signal strength.
#
# - Rx Rate (Receive Rate): The maximum data rate (in Mbit/s) at which
# the device can receive data from the Wi-Fi access point. Example:
# "866.7 MBit/s" indicates a high-speed connection on a modern
# standard.
#
# - Tx Rate (Transmit Rate): The maximum data rate (in Mbit/s) at
# which the device can send data to the Wi-Fi access point. Example:
# "866.7 MBit/s"
#
# - PHY Mode (Physical Layer Mode): The Wi-Fi protocol or standard in
# use. Common modes include 802.11n, 802.11ac, and 802.11ax (Wi-Fi
# 6). Example: "802.11ac" indicates you're using the 5 GHz band with
# a modern high-speed standard.
if ! command -v nmcli &>/dev/null; then
echo "{\"text\": \"󰤮 Wi-Fi\", \"tooltip\": \"nmcli utility is missing\"}"
exit 1
fi
# Check if Wi-Fi is enabled
wifi_status=$(nmcli radio wifi)
if [ "$wifi_status" = "disabled" ]; then
tooltip="Wi-Fi Disabled"
icon="󰤮" # Icon for no connection or disabled
echo "{\"text\": \"${icon} Wi-Fi\", \"tooltip\": \"${tooltip}\"}"
exit 0
fi
wifi_info=$(nmcli -t -f active,ssid,signal,security dev wifi | grep "^yes")
# If no ESSID is found, set a default value
if [ -z "$wifi_info" ]; then
essid="No Connection"
signal=0
tooltip="No Connection"
else
# Some defaults
ip_address="127.0.0.1"
# gateway="127.0.0.1"
# mac_address="N/A"
security=$(echo "$wifi_info" | awk -F: '{print $4}')
# bssid="N/A"
chan="N/A"
# rssi="N/A"
rx_bitrate=""
tx_bitrate=""
phy_mode=""
signal=$(echo "$wifi_info" | awk -F: '{print $3}')
active_device=$(nmcli -t -f DEVICE,STATE device status |
grep -w "connected" |
grep -v -E "^(dummy|lo:)" |
awk -F: '{print $1}')
if [ -n "$active_device" ]; then
output=$(nmcli -e no -g ip4.address,ip4.gateway,general.hwaddr device show "$active_device")
ip_address=$(echo "$output" | sed -n '1p')
# gateway=$(echo "$output" | sed -n '2p')
# mac_address=$(echo "$output" | sed -n '3p')
line=$(nmcli -e no -t -f active,bssid,chan,freq device wifi | grep "^yes")
# bssid=$(echo "$line" | awk -F':' '{print $2":"$3":"$4":"$5":"$6":"$7}')
chan=$(echo "$line" | awk -F':' '{print $8}')
freq=$(echo "$line" | awk -F':' '{print $9}')
chan="$chan ($freq)"
if command -v iw &>/dev/null; then
iw_output=$(iw dev "$active_device" station dump)
# rssi=$(echo "$iw_output" | grep "signal:" | awk '{print $2 " dBm"}')
# Upload speed
rx_bitrate=$(echo "$iw_output" | grep "rx bitrate:" | awk '{print $3 " " $4}')
# Download speed
tx_bitrate=$(echo "$iw_output" | grep "tx bitrate:" | awk '{print $3 " " $4}')
# Physical Layer Mode
if echo "$iw_output" | grep -E -q "rx bitrate:.* VHT"; then
phy_mode="802.11ac" # Wi-Fi 5
elif echo "$iw_output" | grep -E -q "rx bitrate:.* HT"; then
phy_mode="802.11n" # Wi-Fi 4
elif echo "$iw_output" | grep -E -q "rx bitrate:.* HE"; then
phy_mode="802.11ax" # Wi-Fi 6
fi
fi
# Get the current Wi-Fi ESSID
essid=$(echo "$wifi_info" | awk -F: '{print $2}')
tooltip="${essid}\n"
tooltip+="\nIP Address: ${ip_address}"
# tooltip+="\nRouter: ${gateway}"
# tooltip+="\nMAC Address: ${mac_address}"
tooltip+="\nSecurity: ${security}"
# tooltip+="\nBSSID: ${bssid}"
tooltip+="\nChannel: ${chan}"
# tooltip+="\nRSSI: ${rssi}"
tooltip+="\nStrength: ${signal} / 100"
if [ -n "$rx_bitrate" ]; then
tooltip+="\nRx Rate: ${rx_bitrate}"
fi
if [ -n "$tx_bitrate" ]; then
tooltip+="\nTx Rate: ${tx_bitrate}"
fi
if [ -n "$phy_mode" ]; then
tooltip+="\nPHY Mode: ${phy_mode}"
fi
fi
fi
# Determine Wi-Fi icon based on signal strength
if [ "$signal" -ge 80 ]; then
icon="󰤨" # Strong signal
elif [ "$signal" -ge 60 ]; then
icon="󰤥" # Good signal
elif [ "$signal" -ge 40 ]; then
icon="󰤢" # Weak signal
elif [ "$signal" -ge 20 ]; then
icon="󰤟" # Very weak signal
else
icon="󰤮" # No signal
fi
# Change "Wi-Fi" to "${essid}" to display network name
echo "{\"text\": \"${icon} Wi-Fi\", \"tooltip\": \"${tooltip}\"}"
+84
View File
@@ -0,0 +1,84 @@
#!/bin/bash
hypr_border=1
roconf="$HOME/.config/rofi/wifi.rasi"
# Set rofi scaling
[[ "${rofiScale}" =~ ^[0-9]+$ ]] || rofiScale=10
r_scale="configuration { font: \"JetBrainsMono Nerd Font ${rofiScale}\"; }"
wind_border=$((hypr_border * 3 / 2))
elem_border=$([ "$hypr_border" -eq 0 ] && echo "5" || echo "$hypr_border")
# Ensure that hypr_width, wind_border, and elem_border have valid numeric values
[[ "${hypr_width}" =~ ^[0-9]+$ ]] || hypr_width=2
[[ "${wind_border}" =~ ^[0-9]+$ ]] || wind_border=0
[[ "${elem_border}" =~ ^[0-9]+$ ]] || elem_border=0
# Get monitor resolution and calculate center position
readarray -t monRes < <(hyprctl -j monitors | jq '.[] | select(.focused==true) | .width,.height,.scale')
monRes[2]="${monRes[2]//./}"
monRes[0]=$((monRes[0] * 100 / monRes[2]))
monRes[1]=$((monRes[1] * 100 / monRes[2]))
x_pos_center=$((monRes[0] / 2))
y_pos_center=$((monRes[1] / 2))
# Rofi override to center window on screen
r_override="window { anchor: center; x-offset: -${x_pos_center}px; y-offset: -${y_pos_center}px; border: ${hypr_width}px; border-radius: 15px; } wallbox { border-radius: 10px; } element { border-radius: 10px; }"
# Notify the user about fetching Wi-Fi networks
notify-send "Searching for available Wi-Fi networks..."
# Get a list of available Wi-Fi connections and format it
wifi_list=$(nmcli --fields "SECURITY,SSID" device wifi list | sed 1d | sed 's/ */ /g' | sed -E "s/WPA*.?\S/  /g" | sed "s/^--/  /g" | sed "s/  / /g" | sed "/--/d")
# Check Wi-Fi status
connected=$(nmcli -fields WIFI g)
if [[ "$connected" =~ "enabled" ]]; then
toggle=" 󰤭 Disable Wi-Fi"
elif [[ "$connected" =~ "disabled" ]]; then
toggle=" 󰤨 Enable Wi-Fi"
fi
# Use rofi to select Wi-Fi network
chosen_network=$(echo -e "  Manual Entry\n$toggle\n$wifi_list" | uniq -u | rofi -dmenu -i -selected-row 1 -theme-str "entry { placeholder: \"Search\"; }" -theme-str "${r_scale}" -theme-str "${r_override}" -config "${roconf}" -p "Wi-Fi SSID")
# Get the name of the connection
read -r chosen_id <<< "${chosen_network:3}"
# Perform actions based on the selected option
if [ "$chosen_network" = "" ]; then
exit
elif [ "$chosen_network" = " 󰤨 Enable Wi-Fi" ]; then
nmcli radio wifi on
elif [ "$chosen_network" = " 󰤭 Disable Wi-Fi" ]; then
nmcli radio wifi off
elif [ "$chosen_network" = "  Manual Entry" ]; then
# Prompt for manual SSID and password
manual_ssid=$(rofi -dmenu -theme-str "entry { placeholder: \"SSID\"; }" -theme-str "${r_scale}" -theme-str "${r_override}" -config "${roconf}" -p "Enter SSID:")
if [ -z "$manual_ssid" ]; then
exit
fi
manual_password=$(rofi -dmenu -theme-str "entry { placeholder: \"Password\"; }" -theme-str "${r_scale}" -theme-str "${r_override}" -config "${roconf}" -p "Enter Password (optional):")
if [ -z "$manual_password" ]; then
nmcli device wifi connect "$manual_ssid"
else
nmcli device wifi connect "$manual_ssid" password "$manual_password"
fi
else
# Message to show when connection is activated successfully
success_message="You are now connected to \"$chosen_id\"."
# Get saved connections
saved_connections=$(nmcli -g NAME connection)
if [[ $(echo "$saved_connections" | grep -w "$chosen_id") = "$chosen_id" ]]; then
nmcli connection up id "$chosen_id" | grep "successfully" && notify-send "Connection Established" "$success_message"
else
if [[ "$chosen_network" =~ " " ]]; then
wifi_password=$(rofi -dmenu -theme-str "entry { placeholder: \"Password: \"; }" -theme-str "${r_scale}" -theme-str "${r_override}" -config "${roconf}" -p "Password: ")
fi
nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && notify-send "Connection Established" "$success_message"
fi
fi