feat: refactor and add recording function on waybar
This commit is contained in:
parent
47b5336149
commit
f3475c7d02
15 changed files with 656 additions and 586 deletions
17
home/scripts/mkWall.nix
Normal file
17
home/scripts/mkWall.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{ config, pkgs }:
|
||||
let
|
||||
mkWall = pkgs.writeShellScriptBin "setWall" ''
|
||||
url="$1"
|
||||
filepath="/tmp/wall_cache/$(echo -n "$url" | base64 | tr -d '\n')"
|
||||
|
||||
if [[ ! -f "$filepath" ]]; then
|
||||
curl -sL "$url" -o "$filepath"
|
||||
fi
|
||||
|
||||
${config.services.swww.package}/bin/swww img "$filepath" \
|
||||
--transition-fps 45 \
|
||||
--transition-duration 1 \
|
||||
--transition-type random
|
||||
'';
|
||||
in
|
||||
mkWall
|
||||
17
home/scripts/rbwSelector.nix
Normal file
17
home/scripts/rbwSelector.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Rofi selecter for bitwarden cli
|
||||
{
|
||||
pkgs,
|
||||
}:
|
||||
let
|
||||
selector = pkgs.writeShellScript "rbw-selector" ''
|
||||
selection=$(rbw list | rofi -dmenu -p "Search" )
|
||||
|
||||
if [[ -z "$selection" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rbw get "$selection" | tr -d '\n' | wl-copy
|
||||
notify-send " Bitwarden" "Password for $selection: Copied"
|
||||
'';
|
||||
in
|
||||
selector
|
||||
47
home/scripts/record.nix
Normal file
47
home/scripts/record.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
record = pkgs.writeShellScript "toggle-wf-record" ''
|
||||
PID_FILE="/tmp/wf-recorder.pid"
|
||||
OUTPUT_DIR="$HOME/Videos/recordings"
|
||||
FILENAME="$OUTPUT_DIR/recording_$(date +%Y%m%d_%H%M%S).mp4"
|
||||
SINK_DEV="$(${pkgs.pulseaudio.out}/bin/pactl get-default-sink).monitor"
|
||||
|
||||
declare -A recordOptions=(
|
||||
[Monitor]="${pkgs.slurp}/bin/slurp -o"
|
||||
[Area]="${pkgs.slurp}/bin/slurp"
|
||||
)
|
||||
|
||||
if [[ -f "$PID_FILE" ]]; then
|
||||
pid=$(cat "$PID_FILE")
|
||||
|
||||
if kill "$pid" 2>/dev/null; then
|
||||
rm "$PID_FILE"
|
||||
echo "Stopped recording"
|
||||
notify-send " RECORD" "Recording saved to $FILENAME"
|
||||
else
|
||||
echo "No process found, cleaning up"
|
||||
notify-send " RECORD" "Failed: No process found, cleaning up"
|
||||
rm "$PID_FILE"
|
||||
fi
|
||||
else
|
||||
choice=$(printf "%s\n" "''\${!recordOptions[@]}" | rofi -i -dmenu -config ~/.config/rofi/config.rasi -p "Which mode")
|
||||
|
||||
if [[ -z "$choice" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
${pkgs.wf-recorder}/bin/wf-recorder -y \
|
||||
-g "$(''\${recordOptions[$choice]})" \
|
||||
--audio="$SINK_DEV" \
|
||||
-f "$FILENAME" &
|
||||
echo $! > "$PID_FILE"
|
||||
echo "Started recording: $FILENAME"
|
||||
fi
|
||||
'';
|
||||
in
|
||||
record
|
||||
9
home/scripts/rofiwall.nix
Normal file
9
home/scripts/rofiwall.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{ pkgs, config }:
|
||||
let
|
||||
mkWall = import ./mkWall.nix { inherit pkgs config; };
|
||||
rofiWall = pkgs.writeShellScript "rofiWall" ''
|
||||
url=$(rofi -i -dmenu -config ~/.config/rofi/config.rasi -p "URL")
|
||||
${mkWall}/bin/setWall "$url"
|
||||
'';
|
||||
in
|
||||
rofiWall
|
||||
Loading…
Add table
Add a link
Reference in a new issue