refactored shell scripts to nix files
This commit is contained in:
parent
a4815aa56b
commit
63874ede17
|
@ -2,6 +2,7 @@
|
|||
{
|
||||
imports = [
|
||||
./feh-wallpaper-changer.nix
|
||||
./scripts/dunstify-volume-notification.nix
|
||||
];
|
||||
|
||||
home.packages = [
|
||||
|
@ -12,7 +13,6 @@
|
|||
pkgs.picom
|
||||
pkgs.xclip
|
||||
|
||||
(pkgs.writeShellScriptBin "dunstify-volume-notification" (builtins.readFile ./scripts/dunstify-volume-notification.sh))
|
||||
];
|
||||
|
||||
home.file.".Xresources" = {
|
|
@ -0,0 +1,30 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
(writeShellScriptBin "dunstify-volume-notification" ''
|
||||
mute_test=$(pamixer --get-mute)
|
||||
mic_mute_test=$(pamixer --default-source --get-mute)
|
||||
|
||||
mute=""
|
||||
if [ "$mute_test" == true ];
|
||||
then
|
||||
mute="(Speakers Muted)"
|
||||
fi
|
||||
|
||||
if [ "$mic_mute_test" == true ];
|
||||
then
|
||||
mute="(Mic Muted)"
|
||||
fi
|
||||
|
||||
if [ "$mute_test" == true ] && [ "$mic_mute_test" == true ];
|
||||
then
|
||||
mute="(Speakers Muted & Mic Muted)"
|
||||
fi
|
||||
|
||||
volume=$(pamixer --get-volume)
|
||||
|
||||
msgTag="volume-notify"
|
||||
dunstify -a "changeVolume" -u low -i audio-volume-high -h string:x-dunst-stack-tag:$msgTag "Volume" "''${volume} ''${mute}" -t 2000
|
||||
'')
|
||||
];
|
||||
}
|
|
@ -3,18 +3,18 @@
|
|||
|
||||
imports = [
|
||||
../common
|
||||
../x11
|
||||
../common/x11
|
||||
|
||||
# Status bar scripts
|
||||
./scripts/sb-cpu-pct.nix
|
||||
./scripts/sb-mem-pct.nix
|
||||
./scripts/sb-volume.nix
|
||||
./scripts/sb-network-status.nix
|
||||
./scripts/sb-updates.nix
|
||||
];
|
||||
|
||||
home.packages = [
|
||||
pkgs.dwmblocks
|
||||
|
||||
# Status bar
|
||||
(pkgs.writeShellScriptBin "sb-cpu-pct" (builtins.readFile ./scripts/sb-cpu-pct.sh))
|
||||
(pkgs.writeShellScriptBin "sb-mem-pct" (builtins.readFile ./scripts/sb-mem-pct.sh))
|
||||
(pkgs.writeShellScriptBin "sb-volume" (builtins.readFile ./scripts/sb-volume.sh))
|
||||
(pkgs.writeShellScriptBin "sb-network-status" (builtins.readFile ./scripts/sb-network-status.sh))
|
||||
(pkgs.writeShellScriptBin "sb-updates" (builtins.readFile ./scripts/sb-updates.sh))
|
||||
];
|
||||
|
||||
# TODO configure x11 to look in .config/x11
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
(writeShellScriptBin "sb-cpu-pct" ''
|
||||
echo $(top -bn 1 |grep "Cpu(s)" | awk '{print $2+$6 "%"}' | sed "s/\..//g")
|
||||
'')
|
||||
];
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
echo $(top -bn 1 |grep "Cpu(s)" | awk '{print $2+$6 "%"}' | sed "s/\..//g")
|
|
@ -0,0 +1,9 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
(writeShellScriptBin "sb-mem-pct" ''
|
||||
# Gets current ram percent utilisation
|
||||
echo $(free | awk '/^Mem/ {print "100*" $3 " / " $2 }' | bc | awk '{print $1"%"}')
|
||||
'')
|
||||
];
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
# Gets current ram percent utilisation
|
||||
|
||||
echo $(free | awk '/^Mem/ {print "100*" $3 " / " $2 }' | bc | awk '{print $1"%"}')
|
|
@ -0,0 +1,52 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
(writeShellScriptBin "sb-network-status" ''
|
||||
# Nerd Font Symbols
|
||||
wifi_symbol=" "
|
||||
lan_symbol=" "
|
||||
disconnected_symbol=" "
|
||||
vpn_symbol=" "
|
||||
internet=" "
|
||||
internet_disconnected=" "
|
||||
|
||||
# Get the network status
|
||||
DEFAULT_INTERFACE=$(ip route | grep '^default' | awk '{print $5}' | uniq)
|
||||
IP_ADDRESS=$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')
|
||||
|
||||
if [ -z "$DEFAULT_INTERFACE" ]; then
|
||||
network_symbol="$disconnected_symbol"
|
||||
else
|
||||
# Check if it is a wireless interface (wlan*)
|
||||
if [[ $DEFAULT_INTERFACE == wl* ]]; then
|
||||
network_symbol="$wifi_symbol"
|
||||
else
|
||||
network_symbol="$lan_symbol"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check internet connectivity
|
||||
if ! ping -c 1 8.8.8.8 &> /dev/null;
|
||||
then
|
||||
network_symbol="$network_symbol $internet_disconnected"
|
||||
else
|
||||
network_symbol="$network_symbol $internet"
|
||||
fi
|
||||
|
||||
if ip addr show tun0 > /dev/null 2>&1; then
|
||||
network_symbol="$network_symbol $vpn_symbol"
|
||||
else
|
||||
network_symbol="$network_symbol"
|
||||
fi
|
||||
|
||||
if [ -z "$IP_ADDRESS" ];
|
||||
then
|
||||
printf "$network_symbol"
|
||||
else
|
||||
printf "$network_symbol|$IP_ADDRESS"
|
||||
fi
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
# Nerd Font Symbols
|
||||
wifi_symbol=" "
|
||||
lan_symbol=" "
|
||||
disconnected_symbol=" "
|
||||
vpn_symbol=" "
|
||||
internet=" "
|
||||
internet_disconnected=" "
|
||||
|
||||
# Get the network status
|
||||
DEFAULT_INTERFACE=$(ip route | grep '^default' | awk '{print $5}' | uniq)
|
||||
IP_ADDRESS=$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')
|
||||
|
||||
if [ -z "$DEFAULT_INTERFACE" ]; then
|
||||
network_symbol="$disconnected_symbol"
|
||||
else
|
||||
# Check if it is a wireless interface (wlan*)
|
||||
if [[ $DEFAULT_INTERFACE == wl* ]]; then
|
||||
network_symbol="$wifi_symbol"
|
||||
else
|
||||
network_symbol="$lan_symbol"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check internet connectivity
|
||||
if ! ping -c 1 8.8.8.8 &> /dev/null;
|
||||
then
|
||||
network_symbol="$network_symbol $internet_disconnected"
|
||||
else
|
||||
network_symbol="$network_symbol $internet"
|
||||
fi
|
||||
|
||||
if ip addr show tun0 > /dev/null 2>&1; then
|
||||
network_symbol="$network_symbol $vpn_symbol"
|
||||
else
|
||||
network_symbol="$network_symbol"
|
||||
fi
|
||||
|
||||
if [ -z "$IP_ADDRESS" ];
|
||||
then
|
||||
printf "$network_symbol"
|
||||
else
|
||||
printf "$network_symbol|$IP_ADDRESS"
|
||||
fi
|
|
@ -0,0 +1,14 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
(writeShellScriptBin "sb-updates" ''
|
||||
# Gets number of flake inputs that are ready for update
|
||||
# Checks every 60 minutes
|
||||
inputs=$(cd /etc/nixos &&
|
||||
nix flake update --output-lock-file <(cat flake.nix) 2> /tmp/update &&
|
||||
cat /tmp/update | grep -c Update)
|
||||
printf " $inputs"
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
# Gets number of flake inputs that are ready for update
|
||||
# Checks every 60 minutes
|
||||
inputs=$(cd /etc/nixos &&
|
||||
nix flake update --output-lock-file <(cat flake.nix) 2> /tmp/update &&
|
||||
cat /tmp/update | grep -c Update)
|
||||
printf " $inputs"
|
|
@ -0,0 +1,49 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
(writeShellScriptBin "sb-volume" ''
|
||||
# Prints the current volume or 婢 if muted.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e pulsemixer ;;
|
||||
2) pamixer -t && pkill -RTMIN+10 dwmblocks && exit 1 ;;
|
||||
4) pamixer --set-limit 150 --allow-boost -i 1 && pkill -RTMIN+10 dwmblocks && exit 1 ;;
|
||||
5) pamixer --set-limit 150 --allow-boost -d 1 && pkill -RTMIN+10 dwmblocks && exit 1 ;;
|
||||
3) notify-send "Volume module" "\- Shows volume , 婢 if muted.
|
||||
- Middle click to mute.
|
||||
- Scroll to change." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
get_mic_status=$(pamixer --default-source --get-mute)
|
||||
vol="$(pamixer --get-volume)"
|
||||
|
||||
if [ $get_mic_status == false ]; then
|
||||
mic_status=""
|
||||
else
|
||||
mic_status=""
|
||||
fi
|
||||
|
||||
if [ "$vol" -gt "90" ]; then
|
||||
icon=""
|
||||
elif [ "$vol" -gt "50" ]; then
|
||||
icon=""
|
||||
elif [ "$vol" -gt "30" ]; then
|
||||
icon=""
|
||||
elif [ "$vol" -gt "0" ]; then
|
||||
icon=""
|
||||
else
|
||||
icon=""
|
||||
fi
|
||||
|
||||
if [ $(pamixer --get-mute) = true ]; then
|
||||
icon=""
|
||||
vol="0"
|
||||
fi
|
||||
|
||||
print_string="$mic_status $icon $vol%"
|
||||
printf '%s' "''${print_string}"
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
# Prints the current volume or 婢 if muted.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid -f "$TERMINAL" -e pulsemixer ;;
|
||||
2) pamixer -t && pkill -RTMIN+10 dwmblocks && exit 1 ;;
|
||||
4) pamixer --set-limit 150 --allow-boost -i 1 && pkill -RTMIN+10 dwmblocks && exit 1 ;;
|
||||
5) pamixer --set-limit 150 --allow-boost -d 1 && pkill -RTMIN+10 dwmblocks && exit 1 ;;
|
||||
3) notify-send "Volume module" "\- Shows volume , 婢 if muted.
|
||||
- Middle click to mute.
|
||||
- Scroll to change." ;;
|
||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||
esac
|
||||
|
||||
get_mic_status=$(pamixer --default-source --get-mute)
|
||||
vol="$(pamixer --get-volume)"
|
||||
|
||||
if [ $get_mic_status == false ]; then
|
||||
mic_status=""
|
||||
else
|
||||
mic_status=""
|
||||
fi
|
||||
|
||||
if [ "$vol" -gt "90" ]; then
|
||||
icon=""
|
||||
elif [ "$vol" -gt "50" ]; then
|
||||
icon=""
|
||||
elif [ "$vol" -gt "30" ]; then
|
||||
icon=""
|
||||
elif [ "$vol" -gt "0" ]; then
|
||||
icon=""
|
||||
else
|
||||
icon=""
|
||||
fi
|
||||
|
||||
if [ $(pamixer --get-mute) = true ]; then
|
||||
icon=""
|
||||
vol="0"
|
||||
fi
|
||||
|
||||
print_string="$mic_status $icon $vol%"
|
||||
printf '%s' "${print_string}"
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
imports = [
|
||||
../common
|
||||
../wayland
|
||||
../common/wayland
|
||||
./pyprland.nix
|
||||
];
|
||||
wayland.windowManager.hyprland = {
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
mute_test=$(pamixer --get-mute)
|
||||
mic_mute_test=$(pamixer --default-source --get-mute)
|
||||
|
||||
mute=""
|
||||
if [ "$mute_test" == true ];
|
||||
then
|
||||
mute="(Speakers Muted)"
|
||||
fi
|
||||
|
||||
if [ "$mic_mute_test" == true ];
|
||||
then
|
||||
mute="(Mic Muted)"
|
||||
fi
|
||||
|
||||
if [ "$mute_test" == true ] && [ "$mic_mute_test" == true ];
|
||||
then
|
||||
mute="(Speakers Muted & Mic Muted)"
|
||||
fi
|
||||
|
||||
volume=$(pamixer --get-volume)
|
||||
|
||||
msgTag="volume-notify"
|
||||
dunstify -a "changeVolume" -u low -i audio-volume-high -h string:x-dunst-stack-tag:$msgTag "Volume" "${volume} ${mute}" -t 2000
|
Loading…
Reference in New Issue