summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-09-06 10:34:05 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-09-06 10:34:05 +0800
commit01abbff07781d55101f5a347634de49631709579 (patch)
tree6069e2ea6e007ff932cdfa917d922b9b1c186230
parent582c7ad0569e4bc52a86b38e9a51f07f41842e15 (diff)
more hyprland scripts
-rwxr-xr-xhyprhide30
-rwxr-xr-xhyprindicator44
-rwxr-xr-xhyprshot4
-rwxr-xr-xhyprvol82
-rwxr-xr-xhyprworkspaceswitch14
-rwxr-xr-xsysutil.sh6
-rwxr-xr-xwf-record25
7 files changed, 201 insertions, 4 deletions
diff --git a/hyprhide b/hyprhide
new file mode 100755
index 0000000..93ddaf2
--- /dev/null
+++ b/hyprhide
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+stack_file="/tmp/hidden_pid_stack"
+
+
+function hide_window(){
+ pid=$(hyprctl activewindow -j | jq '.pid')
+ hyprctl dispatch movetoworkspacesilent 88,pid:$pid
+ echo $pid >> $stack_file
+}
+
+function show_window(){
+ current_workspace=$(hyprctl activeworkspace -j | jq '.id')
+ for i in $(cat $stack_file)
+ do
+ hyprctl dispatch movetoworkspacesilent $current_workspace,pid:$i
+ done
+ rm $stack_file
+}
+
+
+if [ ! -z $1 ]
+then
+ if [ "$1" == "h" ]
+ then
+ hide_window
+ else
+ show_window
+ fi
+fi
diff --git a/hyprindicator b/hyprindicator
new file mode 100755
index 0000000..46f4753
--- /dev/null
+++ b/hyprindicator
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+function Mic {
+ # inotifywait -e modify /proc/asound/card0/pcm0c/sub0/status # doesnt work :(
+ rawMicStatus=$(cat /proc/asound/card0/pcm0c/sub0/status)
+ if [[ $rawMicStatus == *"closed"* ]]; then
+ # echo "Mic is closed"
+ unset micpid
+ return 1
+ else
+ micpid=$(printf "%s" "$rawMicStatus" | grep 'owner_pid' | awk -F ': ' '{print $2}')
+ fi
+}
+
+function Camera {
+ campid=$(fuser "/dev/video0" 2>/dev/null) || unset campid
+ # icampid=$(fuser "/dev/video2" 2>/dev/null) # IR camera
+ if [ $campid ]; then
+ unset campid
+ else
+ return 1
+ fi
+}
+
+function subscribe {
+ while true; do
+ Mic
+ Camera
+ if [ ! $micpid ] && [ ! $campid ]; then
+ echo '{"text": " ", "tooltip": " ", "class": "no"}'
+ elif [ $micpid ] && [ ! $campid ]; then
+ echo '{"text": "", "tooltip": "Mic: '$micpid'", "class": "mic"}'
+ elif [ ! $micpid ] && [ $campid ]; then
+ echo '{"text": "", "tooltip": "Camera: '$campid'", "class": "cam"}'
+ else
+ echo '{"text": " ", "tooltip": "Mic: '$micpid' Camera: '$campid'", "class": "miccam}'
+ fi
+ sleep 1
+ done
+}
+
+if [ "$1" ]; then
+ $@
+fi
diff --git a/hyprshot b/hyprshot
index 90dac61..6aa5368 100755
--- a/hyprshot
+++ b/hyprshot
@@ -16,9 +16,7 @@ notify_view () {
pngcheck ${dir}/"$file" > /dev/null
if [[ $? -eq 0 ]]; then
#${notify_cmd_shot} "Copied to clipboard."
- if $($HOME/scripts/sysutil.sh getSound screenshot); then
- $HOME/scripts/sysutil.sh playsound screen-capture.oga &
- fi
+ if $($HOME/scripts/sysutil.sh getSound screenshot); then $HOME/scripts/sysutil.sh playSound screen-capture.oga & fi
viewnior ${dir}/"$file"
else
# the notifcation too annoying
diff --git a/hyprvol b/hyprvol
new file mode 100755
index 0000000..326bce7
--- /dev/null
+++ b/hyprvol
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+# Icons
+iDIR='/usr/share/archcraft/icons/dunst'
+notify_cmd='notify-send -u low'
+
+# Get Volume
+get_volume() {
+ echo "`pulsemixer --get-volume | cut -d' ' -f1`"
+}
+
+# Notify
+notify_user() {
+ current="$(get_volume)"
+ if [[ "$current" -eq "0" ]]; then
+ icon="$iDIR/volume-mute.png"
+ elif [[ ("$current" -ge "0") && ("$current" -le "40") ]]; then
+ icon="$iDIR/volume-low.png"
+ elif [[ ("$current" -ge "40") && ("$current" -le "60") ]]; then
+ icon="$iDIR/volume-mid.png"
+ elif [[ ("$current" -ge "60") ]]; then
+ icon="$iDIR/volume-high.png"
+ fi
+ if $($HOME/scripts/sysutil.sh getSound screenshot); then $HOME/scripts/sysutil.sh playSound audio-volume-change.oga & fi
+ ${notify_cmd} -i "$icon" "Volume : $current%"
+}
+
+# Increase Volume
+inc_volume() {
+ [[ `pulsemixer --get-mute` == 1 ]] && pulsemixer --unmute
+ wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ && notify_user
+}
+
+# Decrease Volume
+dec_volume() {
+ [[ `pulsemixer --get-mute` == 1 ]] && pulsemixer --unmute
+ wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- && notify_user
+}
+
+# Toggle Mute
+toggle_mute() {
+ if [[ `pulsemixer --get-mute` == 0 ]]; then
+ wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle & ${notify_cmd} -i "$iDIR/volume-mute.png" "Mute"
+ else
+ current="$(get_volume)"
+ if [[ "$current" -eq "0" ]]; then
+ icon="$iDIR/volume-mute.png"
+ elif [[ ("$current" -ge "0") && ("$current" -le "40") ]]; then
+ icon="$iDIR/volume-low.png"
+ elif [[ ("$current" -ge "40") && ("$current" -le "60") ]]; then
+ icon="$iDIR/volume-mid.png"
+ elif [[ ("$current" -ge "60") ]]; then
+ icon="$iDIR/volume-high.png"
+ fi
+ pulsemixer --toggle-mute & ${notify_cmd} -i "$icon" "Unmute"
+ fi
+}
+
+# Toggle Mic
+toggle_mic() {
+ ID="`pulsemixer --list-sources | grep 'Default' | cut -d',' -f1 | cut -d' ' -f3`"
+ if [[ `pulsemixer --id $ID --get-mute` == 0 ]]; then
+ pulsemixer --id ${ID} --toggle-mute && ${notify_cmd} -i "$iDIR/microphone-mute.png" "Microphone Switched OFF"
+ else
+ pulsemixer --id ${ID} --toggle-mute && ${notify_cmd} -i "$iDIR/microphone.png" "Microphone Switched ON"
+ fi
+}
+
+# Execute accordingly
+if [[ "$1" == "--get" ]]; then
+ get_volume
+elif [[ "$1" == "--inc" ]]; then
+ inc_volume
+elif [[ "$1" == "--dec" ]]; then
+ dec_volume
+elif [[ "$1" == "--toggle" ]]; then
+ toggle_mute
+elif [[ "$1" == "--toggle-mic" ]]; then
+ toggle_mic
+else
+ echo $(get_volume)%
+fi
diff --git a/hyprworkspaceswitch b/hyprworkspaceswitch
new file mode 100755
index 0000000..6d5a014
--- /dev/null
+++ b/hyprworkspaceswitch
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+cworkspace=$(hyprctl activeworkspace -j | jq '.id')
+
+echo $cworkspace
+echo $1
+if [ $cworkspace -eq $1 ]; then
+ exit 1
+elif [ $cworkspace -gt $1 ]; then
+ for ((i=$cworkspace; i>=$1+1; i--)); do hyprctl dispatch workspace -1; done
+elif [ $cworkspace -lt $1 ]; then
+ for ((i=$cworkspace; i<=$1-1; i++)); do hyprctl dispatch workspace +1; done
+fi
+
diff --git a/sysutil.sh b/sysutil.sh
index 3bf6946..8dba1bd 100755
--- a/sysutil.sh
+++ b/sysutil.sh
@@ -11,7 +11,7 @@ function prepsound() {
sDIR=/usr/share/sounds/freedesktop/stereo
}
-function playsound() {
+function playSound() {
if [ ! $sDIR ]; then
echo Warning: Sound directory not set, setting to default
prepsound
@@ -51,6 +51,10 @@ function screenshot() {
$HOME/scripts/hyprshot $@
}
+function volume() {
+ $HOME/scripts/hyprvol $@
+}
+
if [ "$1" ]; then
$@
fi
diff --git a/wf-record b/wf-record
new file mode 100755
index 0000000..a271a80
--- /dev/null
+++ b/wf-record
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
+
+if pgrep wf-recorder; then
+ filename=$(cat $XDG_CACHE_HOME/recorded_filename)
+ killall -s SIGINT wf-recorder
+ notify-send "Recording Complete"
+ while [ ! -z $(pgrep -x wf-recorder) ]; do wait; done
+ pkill -RTMIN+8 waybar
+ ffmpeg -i "$HOME/Videos/$filename.mkv" -c:v libx264rgb -c:a aac "$HOME/Videos/$filename.mp4" &
+else
+ filename=$(date +%F_%T)
+ echo $filename > $XDG_CACHE_HOME/recorded_filename
+ notify-send "Recording Started"
+ if [ "$1" == "-s" ]
+ then wf-recorder --codec libx264rgb -f "$HOME/Videos/$filename.mkv" --audio=alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -g "$(slurp || notify-send "Recording Canceled"; exit 1)" >/dev/null &
+ sleep 2
+ while [ ! -z $(pgrep -x slurp) ]; do wait; done
+ pkill -RTMIN+8 waybar
+ else
+ wf-recorder --codec libx264rgb -f "$HOME/Videos/$filename.mkv" -a --audio=alsa_output.pci-0000_00_1f.3.analog-stereo.monitor &
+ pkill -RTMIN+8 waybar
+ fi
+fi