#!/usr/bin/env fish # Select folders in current semester function open_semester set options (ls -a $argv[1]) set input (menu $options || exit) if test "$input" = "." alacritty msg create-window --working-directory $argv[1] else if test -d $argv[1]/$input open_semester $argv[1]/$input # else if test (xdg-mime query filetype $argv[1]/$input) = "application/pdf" && test (menu "PDF" "Ipe") = "Ipe" # ipe $argv[1]/$input else xdg-open $argv[1]/$input end end # Find files in home directory function find_file set file (find ~/Desktop ~/Documents ~/Downloads ~/Pictures ~/Videos -printf "%p\t%f\n" | fuzzel --with-nth 2 --accept-nth 1 --dmenu --match-mode=fuzzy) if test (xdg-mime query filetype $file) = "application/pdf" && test (menu "PDF" "Ipe") = "Ipe" ipe $file else xdg-open $file end end # Open WueCampus Courses function open_course set options "Algorithmische Graphentheorie" "Theoretische Informatik" "Energy-Aware Engineering" "Nachhaltigkeitskonzepte" "Softwareengineering" set input (menu $options) switch $input case $options[1] xdg-open "https://wuecampus.uni-wuerzburg.de/moodle/course/view.php?id=78644" case $options[2] xdg-open "https://wuecampus.uni-wuerzburg.de/moodle/course/view.php?id=79649" case $options[3] xdg-open "https://wuecampus.uni-wuerzburg.de/moodle/course/view.php?id=78361" case $options[4] xdg-open "https://wuecampus.uni-wuerzburg.de/moodle/course/view.php?id=79204" case $options[5] xdg-open "https://wuecampus.uni-wuerzburg.de/moodle/course/view.php?id=79247" end end function select_song set state "artist" set song while true if test $state = "title" set song[3] (echo -e ".\n..\n$(mpc search --format "%track%\t%title%" album $song[2])" | fuzzel --dmenu --accept-nth 2 || exit) if test $song[3] = "." set state "" mpc find album $song[2] | mpc add else if test $song[3] = ".." set state "album" else set state "" mpc find album $song[2] | mpc insert mpc play (math (mpc current --format "%position%") + (mpc search --format "%track%" title $song[3])) break end else if test $state = "album" set song[2] (echo -e ".\n..\n$(mpc search --format "%date%\t%album%" albumartist $song[1] | uniq | sort)" | fuzzel --dmenu --accept-nth 2 || exit) if test $song[2] = "." set state "" mpc find albumartist $song[1] | mpc add else if test $song[2] = ".." set state "artist" else set state "title" end else if test $state = "artist" set song[1] (mpc list albumartist | fuzzel --dmenu || exit) set state "album" else break end end end function select_song_from_queue set title (mpc playlist --format "%artist%\t%album%\t%title%" | column --table --separator \t --output-separator \t | fuzzel --dmenu --index --width 80 --lines 24 --select-index=(math (mpc current --format "%position%") - 1) --accept-nth 3 || exit) mpc play (math $title + 1) end # Select the default audio source function audio_source set dump (string trim -c '"' (pw-dump | jq '.[] | select(.info.props."media.class" == "Audio/Source")' | jq '.id, .info.props."node.description"')) set ids set names for i in (seq (count $dump)) if test (math $i % 2) -eq 0 set -a names $dump[$i] else set -a ids $dump[$i] end end set input (math (menu --index $names) + 1) wpctl set-default $ids[$input] end # Select the default audio sink function audio_sink set dump (string trim -c '"' (pw-dump | jq '.[] | select(.info.props."media.class" == "Audio/Sink")' | jq '.id, .info.props."node.description"')) set ids set names for i in (seq (count $dump)) if test (math $i % 2) -eq 0 set -a names $dump[$i] else set -a ids $dump[$i] end end set input (math (menu --index $names) + 1) wpctl set-default $ids[$input] end # Select the network connection profile function network_connection set options (nmcli --terse --fields name connection show) set input (menu $options || exit) notify-send "Connect to network $input" (nmcli connection up $input) end # Select a paired bluetooth connection function bluetooth_connection set dump (bluetoothctl devices | string replace "Device " "" | string split -m 1 " ") set ids set names for i in (seq (count $dump)) if test (math $i % 2) -eq 0 set -a names $dump[$i] else set -a ids $dump[$i] end end set input (math (menu --index $names || exit) + 1) notify-send "Connect to bluetooth device $names[$input]" (bluetoothctl connect $ids[$input] | string collect) end # Select the system color scheme preference function color_scheme set options "Light" "Dark" set input (menu $options) switch $input case $options[1] niri msg action do-screen-transition dconf write /org/gnome/desktop/interface/color-scheme \'prefer-light\' command alacritty msg config -w -1 (cat /home/never/.config/alacritty/gruvbox-light.toml) case $options[2] niri msg action do-screen-transition dconf write /org/gnome/desktop/interface/color-scheme \'prefer-dark\' command alacritty msg config -w -1 (cat /home/never/.config/alacritty/gruvbox-dark.toml) end end function restore_notifications for i in (seq (count (string match -r 'Notification [0-9]' (makoctl history)))) makoctl restore end end function set_keyboard_backlight brightnessctl --device=white:kbd_backlight set (menu --index "0" "1" "2" "3" "4") end function mirror_screen wl-mirror eDP-1 end # Select sub menu set options "󰑴 Open Semester" "󰑴 Open WueCampus Course" "󰈞 Find Files" "󰝚 Add Album" "󰲸 Select Song from Queue" "󰦚 MPD Settings" "󰕾 Select Audio Sink" "󰍬 Select Audio Source" "󰂯 Select Bluetooth" "󰛳 Select Network" "󰔎 Select Color Scheme" "󰂚 Restore Notifications" "󰌌 Set Keyboard Backlight" "󰍺 Mirror Screen" set input (menu $options) switch $input case $options[1] open_semester "/home/never/Documents/InNa/26_SoSe/" case $options[2] open_course case $options[3] find_file case $options[4] select_song case $options[5] select_song_from_queue case $options[6] mpdmenu.fish case $options[7] wpsinkmenu.fish # audio_sink case $options[8] wpsourcemenu.fish # audio_source case $options[9] bluetoothmenu.fish # bluetooth_connection case $options[10] networkmenu.fish # network_connection case $options[11] color_scheme case $options[12] restore_notifications case $options[13] set_keyboard_backlight case $options[14] mirror_screen end