Initial commit: Moonarch reproduzierbares Arch-Linux-Setup

Niri-basierter Wayland-Desktop mit greetd/regreet, Catppuccin Mocha
Theming, Rofi-Menus, Waybar und vollstaendiger Post-Install-Automatisierung.

Archinstall-Config klont das Repo automatisch via custom-commands,
danach genuegt ein einzelner Befehl fuer die komplette Einrichtung.
This commit is contained in:
2026-03-23 17:42:26 +01:00
commit 5d2ce00455
69 changed files with 10527 additions and 0 deletions
+142
View File
@@ -0,0 +1,142 @@
#!/usr/bin/env bash
# ABOUTME: Rofi-based tool launcher that provides a searchable menu of system utilities.
# ABOUTME: Includes VPN, sound, bluetooth, shortcuts, and other system management tools.
declare -A LABELS
declare -A COMMANDS
###
# List of defined 'bangs'
# launch programs
# COMMANDS["apps"]="rofi -combi-modi window,drun -show combi"
# LABELS["apps"]=""
# open bookmarks
# COMMANDS["bookmarks"]="~/.scripts/rofi-scripts-collection/rofi-surfraw-bookmarks.sh"
# LABELS["bookmarks"]=""
# search local files
COMMANDS[""]="moonarch-locate"
LABELS[""]="Locate"
COMMANDS[""]="wlogout -P 1 -s -r 10 -c 10"
LABELS[""]="Session Menu"
# open custom web searches
# COMMANDS["websearch"]="~/.scripts/rofi-scripts-collection/rofi-surfraw-websearch.sh"
# LABELS["websearch"]=""
# show clipboard history
# source: https://bitbucket.org/pandozer/rofi-clipboard-manager/overview
# COMMANDS["clipboard"]='rofi -modi "clipboard:~/.bin/rofi-clipboard-manager/mclip.py menu" -show clipboard && ~/.bin/rofi-clipboard-manager/mclip.py paste'
# LABELS["clipboard"]=""
# references --------------------------
# COMMANDS[";sr2"]="chromium 'wikipedia.org/search-redirect.php?search=\" \${input}\""
# LABELS[";sr2"]=""
# COMMANDS[";piratebay"]="chromium --disk-cache-dir=/tmp/cache http://thepiratebay.org/search/\" \${input}\""
# LABELS[";piratebay"]=""
# COMMANDS[".bin"]="spacefm -r '/home/dka/bin'"
# LABELS[".bin"]=".bin"
# COMMANDS["#screenshot"]='/home/dka/bin/screenshot-scripts/myscreenshot.sh'
# LABELS["#screenshot"]="screenshot"
# greenclip clipboard history
# source: https://github.com/erebe/greenclip
COMMANDS[""]='rofi -modi "clipboard:greenclip print" -show Clipboard'
LABELS[""]="Clipboard"
COMMANDS["󰖂"]='moonarch-vpn'
LABELS["󰖂"]='VPN Connection Manager'
COMMANDS["󰗅"]='moonarch-volume'
LABELS["󰗅"]='Sound Manager'
#COMMANDS[""]='shortcuts module was removed'
#LABELS[""]='Hotkey List'
COMMANDS["󰍹"]='wdisplays'
LABELS["󰍹"]='Display Setup'
COMMANDS[""]='nwg-look'
LABELS[""]='Appearance Settings'
COMMANDS["󱘆"]='noisetorch'
LABELS["󱘆"]='Audio Noise Reduction'
COMMANDS["󰋋"]='$HOME/.local/share/headset-charge-indicator/headset-charge-indicator.py &'
LABELS["󰋋"]='Headset Control'
COMMANDS[""]='moonarch-bluetooth'
LABELS[""]='Bluetooth Control'
COMMANDS["󰛳"]='nm-applet --indicator &'
LABELS["󰛳"]='Networker Manager'
COMMANDS["󰴱"]='wl-color-picker'
LABELS["󰴱"]='Color Picker'
COMMANDS["󰚞"]='font-manager'
LABELS["󰚞"]='Font Manager'
COMMANDS["󱨑"]='gufw'
LABELS["󱨑"]='Firewall Settings'
COMMANDS[""]='stacer'
LABELS[" "]='System Maintenance'
################################################################################
# do not edit below
################################################################################
##
# Generate menu
##
function print_menu()
{
for key in ${!LABELS[@]}
do
# echo "$key ${LABELS}"
echo "$key ${LABELS[$key]}"
# my top version just shows the first field in labels row, not two words side by side
done
}
##
# Show rofi.
##
function start()
{
# print_menu | rofi -dmenu -p "?=>"
print_menu | sort | rofi -show "Tools" -dmenu -mesg " Tools" -i -p "rofi-bangs: "
}
# Run it
value="$(start)"
# Split input.
# grab upto first space.
choice=${value%%\ *}
# graph remainder, minus space.
input=${value:$((${#choice}+1))}
##
# Cancelled? bail out
##
if test -z ${choice}
then
exit
fi
# check if choice exists
if test ${COMMANDS[$choice]+isset}
then
# Execute the choice
${COMMANDS[$choice]}
else
echo "Unknown command: ${choice}" | rofi -dmenu -p "error"
fi
+314
View File
@@ -0,0 +1,314 @@
#!/usr/bin/env bash
# ABOUTME: Rofi-based Bluetooth device manager using bluetoothctl.
# ABOUTME: Supports connecting, pairing, trusting devices, and toggling power/scan/discoverable.
# Author: Nick Clyde (clydedroid)
#
# A script that generates a rofi menu that uses bluetoothctl to
# connect to bluetooth devices and display status info.
#
# Inspired by networkmanager-dmenu (https://github.com/firecat53/networkmanager-dmenu)
# Thanks to x70b1 (https://github.com/polybar/polybar-scripts/tree/master/polybar-scripts/system-bluetooth-bluetoothctl)
#
# Depends on:
# Arch repositories: rofi, bluez-utils (contains bluetoothctl)
# Constants
divider="---------"
goback="Back"
# Checks if bluetooth controller is powered on
power_on() {
if bluetoothctl show | grep -q "Powered: yes"; then
return 0
else
return 1
fi
}
# Toggles power state
toggle_power() {
if power_on; then
bluetoothctl power off
show_menu
else
if rfkill list bluetooth | grep -q 'blocked: yes'; then
rfkill unblock bluetooth && sleep 3
fi
bluetoothctl power on
show_menu
fi
}
# Checks if controller is scanning for new devices
scan_on() {
if bluetoothctl show | grep -q "Discovering: yes"; then
echo "Scan: on"
return 0
else
echo "Scan: off"
return 1
fi
}
# Toggles scanning state
toggle_scan() {
if scan_on; then
kill $(pgrep -f "bluetoothctl scan on")
bluetoothctl scan off
show_menu
else
bluetoothctl scan on &
echo "Scanning..."
sleep 5
show_menu
fi
}
# Checks if controller is able to pair to devices
pairable_on() {
if bluetoothctl show | grep -q "Pairable: yes"; then
echo "Pairable: on"
return 0
else
echo "Pairable: off"
return 1
fi
}
# Toggles pairable state
toggle_pairable() {
if pairable_on; then
bluetoothctl pairable off
show_menu
else
bluetoothctl pairable on
show_menu
fi
}
# Checks if controller is discoverable by other devices
discoverable_on() {
if bluetoothctl show | grep -q "Discoverable: yes"; then
echo "Discoverable: on"
return 0
else
echo "Discoverable: off"
return 1
fi
}
# Toggles discoverable state
toggle_discoverable() {
if discoverable_on; then
bluetoothctl discoverable off
show_menu
else
bluetoothctl discoverable on
show_menu
fi
}
# Checks if a device is connected
device_connected() {
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Connected: yes"; then
return 0
else
return 1
fi
}
# Toggles device connection
toggle_connection() {
if device_connected "$1"; then
bluetoothctl disconnect "$1"
device_menu "$device"
else
bluetoothctl connect "$1"
device_menu "$device"
fi
}
# Checks if a device is paired
device_paired() {
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Paired: yes"; then
echo "Paired: yes"
return 0
else
echo "Paired: no"
return 1
fi
}
# Toggles device paired state
toggle_paired() {
if device_paired "$1"; then
bluetoothctl remove "$1"
device_menu "$device"
else
bluetoothctl pair "$1"
device_menu "$device"
fi
}
# Checks if a device is trusted
device_trusted() {
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Trusted: yes"; then
echo "Trusted: yes"
return 0
else
echo "Trusted: no"
return 1
fi
}
# Toggles device connection
toggle_trust() {
if device_trusted "$1"; then
bluetoothctl untrust "$1"
device_menu "$device"
else
bluetoothctl trust "$1"
device_menu "$device"
fi
}
# Prints a short string with the current bluetooth status
# Useful for status bars like polybar, etc.
print_status() {
if power_on; then
printf ''
paired_devices_cmd="devices Paired"
# Check if an outdated version of bluetoothctl is used to preserve backwards compatibility
if (( $(echo "$(bluetoothctl version | cut -d ' ' -f 2) < 5.65" | bc -l) )); then
paired_devices_cmd="paired-devices"
fi
mapfile -t paired_devices < <(bluetoothctl $paired_devices_cmd | grep Device | cut -d ' ' -f 2)
counter=0
for device in "${paired_devices[@]}"; do
if device_connected "$device"; then
device_alias=$(bluetoothctl info "$device" | grep "Alias" | cut -d ' ' -f 2-)
if [ $counter -gt 0 ]; then
printf ", %s" "$device_alias"
else
printf " %s" "$device_alias"
fi
((counter++))
fi
done
printf "\n"
else
echo ""
fi
}
# A submenu for a specific device that allows connecting, pairing, and trusting
device_menu() {
device=$1
# Get device name and mac address
device_name=$(echo "$device" | cut -d ' ' -f 3-)
mac=$(echo "$device" | cut -d ' ' -f 2)
# Build options
if device_connected "$mac"; then
connected="Connected: yes"
else
connected="Connected: no"
fi
paired=$(device_paired "$mac")
trusted=$(device_trusted "$mac")
options="$connected\n$paired\n$trusted\n$divider\n$goback\nExit"
# Open rofi menu, read chosen option
chosen="$(echo -e "$options" | $rofi_command "$device_name")"
# Match chosen option to command
case "$chosen" in
"" | "$divider")
echo "No option chosen."
;;
"$connected")
toggle_connection "$mac"
;;
"$paired")
toggle_paired "$mac"
;;
"$trusted")
toggle_trust "$mac"
;;
"$goback")
show_menu
;;
esac
}
# Opens a rofi menu with current bluetooth status and options to connect
show_menu() {
# Get menu options
if power_on; then
power="Power: on"
# Human-readable names of devices, one per line
# If scan is off, will only list paired devices
devices=$(bluetoothctl devices | grep Device | cut -d ' ' -f 3-)
# Get controller flags
scan=$(scan_on)
pairable=$(pairable_on)
discoverable=$(discoverable_on)
# Options passed to rofi
options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nExit"
else
power="Power: off"
options="$power\nExit"
fi
# Open rofi menu, read chosen option
chosen="$(echo -e "$options" | $rofi_command "Bluetooth")"
# Match chosen option to command
case "$chosen" in
"" | "$divider")
echo "No option chosen."
;;
"$power")
toggle_power
;;
"$scan")
toggle_scan
;;
"$discoverable")
toggle_discoverable
;;
"$pairable")
toggle_pairable
;;
*)
device=$(bluetoothctl devices | grep "$chosen")
# Open a submenu if a device is selected
if [[ $device ]]; then device_menu "$device"; fi
;;
esac
}
# Rofi command to pipe into, can add any options here
rofi_command="rofi -dmenu $* -p -theme /etc/xdg/rofi/bluetooth/bluetooth.rasi -mesg -Bluetooth-Control"
case "$1" in
--status)
print_status
;;
*)
show_menu
;;
esac
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
# ABOUTME: Prüft Bluetooth-Geräte auf niedrigen Akkustand und sendet Notification.
# ABOUTME: Kann per Timer oder Cron regelmäßig ausgeführt werden.
NOTIFY_AT_PERCENTAGE=70
ICON="/usr/share/icons/Newaita-reborn/status/symbolic/battery-empty-symbolic.svg"
for d in $(upower -e); do
DEVICE_DATA=$(upower -i "$d")
PERCENTAGE=$(echo $DEVICE_DATA | grep -Po '(?<=(percentage: )).*(?= icon)')
PER_INT=$(echo "${PERCENTAGE//%}")
DEVICE_NAME=$(echo $DEVICE_DATA | grep -Po '(?<=(model: )).*(?= serial)')
if [ ! -z "$DEVICE_NAME" ] && [ "$PER_INT" -lt "$NOTIFY_AT_PERCENTAGE" ]; then
notify-send -t 5000 -e "Low battery $DEVICE_NAME $PER_INT%" -i "$ICON" \
-h string:x-canonical-private-synchronous:battery \
-h int:value:"$PER_INT" -u critical
fi
done
+98
View File
@@ -0,0 +1,98 @@
#!/usr/bin/env bash
# ABOUTME: Rofi-based calendar widget with month navigation.
# ABOUTME: Displays a calendar grid and highlights the current day.
DIR=$(dirname $PWD)
current_day=$(date +"%e")
current_month=$(date +"%m")
current_year=$(date +"%Y")
month=$(date +"%-m")
year=$(date +"%Y")
previous_month="◀"
next_month="▶"
last_selected_option=""
format_calendar () {
echo "$1" \
| sed -E 's/([[:alpha:]])__/\1\n/g' \
| sed -E 's/___([[:digit:]])/.\n\1/g' \
| sed -e 's/___/\n./g' \
| sed -e 's/__/\n/g' \
| sed -e 's/_/\n/g'
}
print_month() {
calendar="$(cal -v -- $1 $2 | tail -n +2 | sed -e 's/ /_/g')"
echo "$(format_calendar "$calendar")"
}
find_day_index() {
index=0
while IFS=' ' read -ra arr; do
for i in "${arr[@]}"; do
if [[ "$i" == "$2" ]]; then
echo "$index"
break
fi
((index++))
done
done <<< "$1"
}
calendar_menu() {
calendar_header=$(cal -v -- $month $year | head -n 1)
month_page="$(print_month $month $year)"
calendar_body="\n\n\n$previous_month\n\n\n\n$month_page\n\n\n\n$next_month\n\n\n"
previous_month_index="3"
next_month_index="59"
calendar_body_column="7"
urgent="-u $previous_month_index,$next_month_index"
active=""
selected_row=""
if [[ "$(echo $current_month | bc) $current_year" == "$(echo $month | bc) $year" ]]; then
current_day_index=$(($(find_day_index "$month_page" $current_day) + $calendar_body_column))
active="-a $current_day_index"
selected_row="-selected-row $current_day_index"
fi
if [[ $last_selected_option == $previous_month ]]; then
selected_row="-selected-row $previous_month_index"
fi
if [[ $last_selected_option == $next_month ]]; then
selected_row="-selected-row $next_month_index"
fi
echo -e "$calendar_body" | rofi -dmenu \
-theme /etc/xdg/rofi/calendar/rofi-calendar.rasi \
-p "$calendar_header" $urgent $active $selected_row
}
while [[ true ]]; do
selected=$(calendar_menu)
last_selected_option="$selected"
case $selected in
$previous_month)
((month--))
if [[ $month -lt 1 ]]; then
month=12
((year--))
fi
;;
$next_month)
((month++))
if [[ $month -gt 12 ]]; then
month=1
((year++))
fi
;;
*)
break
;;
esac
done
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# ABOUTME: Zeigt eine Notification beim Umschalten von Caps Lock an.
# ABOUTME: Gedacht für Keybinding oder Input-Event-Trigger.
sleep 0.2
value=($(cat /sys/class/leds/input*::capslock/brightness | cut -f1 -d,))
if [ ${value[2]} == 1 ]; then
icon_name="capslock-enabled-symbolic"
output="caps lock on"
else
icon_name="capslock-disabled-symbolic"
output="caps lock off"
fi
notify-send -e "$output" -i "$icon_name" \
-h string:x-canonical-private-synchronous:state \
-h boolean:value:"${value[2]}" -r 555
+72
View File
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
# ABOUTME: Rofi-based CPU governor switcher using auto-cpufreq.
# ABOUTME: Allows switching between performance, powersave, and reset modes.
declare -A LABELS
declare -A COMMANDS
###
# List of defined 'bangs'
COMMANDS["󰓅"]="pkexec auto-cpufreq --force=performance"
LABELS["󰓅"]="Performance"
COMMANDS["󰌪"]='pkexec auto-cpufreq --force=powersave'
LABELS["󰌪"]="Powersave"
COMMANDS[""]='pkexec auto-cpufreq --force=reset'
LABELS[""]="Reset"
################################################################################
# do not edit below
################################################################################
##
# Generate menu
##
function print_menu()
{
for key in ${!LABELS[@]}
do
# echo "$key ${LABELS}"
echo "$key ${LABELS[$key]}"
# my top version just shows the first field in labels row, not two words side by side
done
}
##
# Show rofi.
##
function start()
{
# print_menu | rofi -dmenu -p "?=>"
print_menu | sort | rofi -theme /etc/xdg/rofi/cpugov/rofi-cpugov.rasi -show "CPU Modes" -dmenu -mesg "󰓅 CPU Modes" -i -p "rofi-bangs: "
}
# Run it
value="$(start)"
# Split input.
# grab upto first space.
choice=${value%%\ *}
# graph remainder, minus space.
input=${value:$((${#choice}+1))}
##
# Cancelled? bail out
##
if test -z ${choice}
then
exit
fi
# check if choice exists
if test ${COMMANDS[$choice]+isset}
then
# Execute the choice
${COMMANDS[$choice]}
dunstify --replace 553 -i "/usr/share/icons/zafiro-dark/devices/48/cpu.svg" "CPU Mode" "Set to $choice ${LABELS[$choice]}"
else
echo "Unknown command: ${choice}" | rofi -dmenu -p "error"
fi
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# ABOUTME: Waybar-Modul das den DND-Status von dunst als JSON ausgibt.
# ABOUTME: Wird von der Waybar custom/dnd Config referenziert.
set -euo pipefail
readonly ENABLED=''
readonly DISABLED=''
dbus-monitor path='/org/freedesktop/Notifications',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged' --profile |
while read -r _; do
PAUSED="$(dunstctl is-paused)"
if [ "$PAUSED" == 'false' ]; then
CLASS="enabled"
TEXT="$ENABLED"
TOOLTIP="Notifications are on"
else
CLASS="disabled"
TEXT="$DISABLED"
TOOLTIP="Notifications are off"
COUNT="$(dunstctl count waiting)"
if [ "$COUNT" != '0' ]; then
TEXT="$DISABLED ($COUNT)"
fi
fi
printf '{"text": "%s", "class": "%s", "tooltip": "%s"}\n' "$TEXT" "$CLASS" "$TOOLTIP"
done
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
# ABOUTME: Rofi emoji picker that copies selected emoji to clipboard.
# ABOUTME: Reads emoji list from /etc/xdg/rofi/emojis/emojis.txt.
FILE="/etc/xdg/rofi/emojis/emojis.txt"
if [ "$@" ]
then
smiley=$(echo $@ | cut -d' ' -f1)
echo -n "$smiley" | xsel -bi
exit 0
fi
cat $FILE
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env python3
# ABOUTME: Converts GTK theme colors to rofi-compatible CSS color values.
# ABOUTME: Reads a template file and replaces {@theme_*_color} placeholders with hex values.
# https://github.com/Git-Fal7/gtk-rofi/
# Taken from MATE-HUD github.com/ubuntu-mate/mate-hud
# Used for rofi css
# Usage
# ./moonarch-gtk-style [input file] > [output file]
# examples
# background-color: {@theme_bg_color}
# see the array below for list of style context to use
import sys
if len(sys.argv)<2:
sys.exit(1)
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gio, GLib, Gtk
#Converts from rgba <GTK R, G, B> to hex #RRGGBB
def rgba_to_hex(color):
return "#{0:02x}{1:02x}{2:02x}".format( int(color.red * 255), int(color.green * 255), int(color.blue * 255))
window = Gtk.Window()
style_context = window.get_style_context()
#List of style contexts
lists = [
#Foreground
'theme_fg_color', 'theme_selected_fg_color', 'theme_fg_color',
'warning_fg_color', 'info_fg_color',
#Background
'theme_bg_color', 'theme_selected_bg_color', 'error_bg_color',
'warning_bg_color', 'info_bg_color',
#Others
'theme_unfocused_fg_color', 'theme_text_color',
'theme_unfocused_text_color',
'theme_base_color',
'theme_unfocused_fg_color',
'theme_unfocused_text_color',
'theme_unfocused_bg_color',
'theme_unfocused_base_color',
'theme_unfocused_selected_bg_color',
'theme_unfocused_selected_fg_color',
'unfocused_insensitive_color',
'borders',
'unfocused_borders',
'warning_color',
'error_color',
'success_color'
]
with open(sys.argv[1]) as f:
file=f.read()
for style in lists:
file=file.replace("{@" + style + "}", rgba_to_hex(style_context.lookup_color(style)[1]))
print(file)
+52
View File
@@ -0,0 +1,52 @@
#!/bin/bash
# ABOUTME: Rofi helper that reads a JSON config file to build a dynamic menu.
# ABOUTME: Parses name/command/icon fields from JSON and launches selected entries.
#https://github.com/luiscrjunior/rofi-json
user_file="${1/#\~/$HOME}"
if [[ "$user_file" = /* ]]
then
config_file="$user_file"
else
cwd=$(dirname $0)
config_file="${cwd}/${user_file}"
fi
json=$(cat ${config_file})
if [ $# -eq 1 ]; then
echo $json | jq -cr '.[] | "\(.name)|\(.command)|\(.icon)"' |
while IFS="|" read -r name command icon
do
if [[ $name == "null" ]]; then
continue
fi
if [[ $icon == "null" ]]; then
icon="system-run"
fi
echo -en "${name}\0icon\x1f${icon}\n"
done
exit 1
fi
if [ $# -eq 2 ]; then
selected=$2
task=$(echo $json | jq ".[] | select(.name == \"$selected\")")
if [[ $task == "" ]]; then
exit 1
fi
command=$(echo $task | jq -j ".command")
if [[ $command == "null" ]]; then
command=$(echo $task | jq -j ".name")
fi
coproc bash -c "$command"
exit
fi
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# ABOUTME: Application launcher using rofi with GTK theme integration.
# ABOUTME: Supports window, files, run, and drun modes.
SETTINGS=/etc/xdg/rofi/gtk-theme.ini
#Gets the current gtk using gsettings and removes the quotes
CURRENT_GTK_THEME=$(gsettings get org.gnome.desktop.interface gtk-theme)
CURRENT_GTK_THEME="${CURRENT_GTK_THEME#?}"
CURRENT_GTK_THEME="${CURRENT_GTK_THEME%?}"
#Gets the gtk theme that is in the settings.ini file
SETTINGS_GTK_THEME=$(grep "GTK_THEME" "${SETTINGS}" | cut -b 11-)
#create new colors.rasi from template
if [ "${SETTINGS_GTK_THEME}" != "${CURRENT_GTK_THEME}" ]; then
sed -i "s:GTK_THEME=${SETTINGS_GTK_THEME}:GTK_THEME=${CURRENT_GTK_THEME}:g" "${SETTINGS}"
python3 moonarch-gtk-style /etc/xdg/rofi/_template/colors.rasi > /etc/xdg/rofi/colors.rasi
fi
case $1 in
window)
showmode="window"
;;
files)
showmode="filebrowser"
;;
run)
showmode="run"
;;
*)
showmode="drun"
;;
esac
## Run
rofi \
-show $showmode \
-click-to-exit \
-theme /etc/xdg/rofi/launcher/launcher.rasi
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
# ABOUTME: Rofi-based file search using the locate/mlocate database.
# ABOUTME: Opens selected files with xdg-open.
# info: rofi-locate is a script to search local files and folders on your computer using the locate command and the updatedb database
# requirements: rofi mlocate
# playlist: rofi https://www.youtube.com/playlist?list=PLqv94xWU9zZ0LVP1SEFQsLEYjZC_SUB3m
xdg-open "$(locate home media | rofi -threads 0 -width 100 -dmenu -i -p "locate:")"
+84
View File
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
# ABOUTME: Rofi-basiertes Power-Menü für Moonarch (Niri).
# ABOUTME: Bietet Shutdown, Reboot, Lock, Suspend und Logout.
# CMDs
uptime="`uptime -p | sed -e 's/up //g'`"
host="$USER@"`hostname`
# Options
shutdown='󰤆'
reboot=''
lock=''
suspend=''
logout='󰗽'
yes=''
no='󰆢'
# Rofi CMD
rofi_cmd() {
rofi -dmenu \
-p "$host uptime: $uptime" \
-mesg "$host uptime: $uptime" \
-theme /etc/xdg/rofi/powermenu/powermenu.rasi
}
# Confirmation CMD
confirm_cmd() {
rofi -dmenu \
-p 'Confirmation' \
-normal-window \
-mesg 'Confirm '${chosen} \
-theme /etc/xdg/rofi/powermenu/confirm.rasi
}
# Ask for confirmation
confirm_exit() {
echo -e "$yes\n$no" | confirm_cmd ${chosen}
}
# Pass variables to rofi dmenu
run_rofi() {
echo -e "$lock\n$suspend\n$logout\n$reboot\n$shutdown" | rofi_cmd
}
# Execute Command
run_cmd() {
selected="$(confirm_exit)"
if [[ "$selected" == "$yes" ]]; then
if [[ $1 == '--shutdown' ]]; then
systemctl poweroff
elif [[ $1 == '--reboot' ]]; then
systemctl reboot
elif [[ $1 == '--suspend' ]]; then
mpc -q pause
amixer set Master mute
systemctl suspend
elif [[ $1 == '--logout' ]]; then
niri msg action quit
fi
else
exit 0
fi
}
# Actions
chosen="$(run_rofi)"
case ${chosen} in
$shutdown)
run_cmd --shutdown
;;
$reboot)
run_cmd --reboot
;;
$lock)
killall rofi
wlogout -P 1 -s -r 10 -c 10
;;
$suspend)
run_cmd --suspend
;;
$logout)
run_cmd --logout
;;
esac
+66
View File
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# ABOUTME: Rofi script mode that lists desktop files from /usr/share/settings-menu/.
# ABOUTME: Used with rofi -show fb -modes "fb:moonarch-setmen" for a settings launcher.
####
# @author moonarch.de (nevaforget)
# script used with rofi to list desktop files of specific dir
# dir: /usr/share/settings-menu/
# @example rofi -show fb -modes "fb:moonarch-setmen" -theme /etc/xdg/rofi/settings-menu/settings-menu.rasi
# @dependencies glib >= 2.67.2
####
function get_name {
local lang=$(locale | grep LANG | cut -d= -f2 | cut -d_ -f1)
local find="Name\[$lang\]="
local name=$(grep "^$find" $1 | tail -1 | sed "s/^$find//" | sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g')
if [ "${name}" = "" ]
then
find="Name="
name=$(grep "^$find" $1 | tail -1 | sed "s/^$find//" | sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g')
fi
echo "$name"
}
if [ "$ROFI_RETV" = "1" ]
then
for deskfile in /usr/share/settings-menu/*
do
match=$(grep "^Name" $deskfile | grep "$@" )
if [ -n "$match" ]
then
#gio launch $deskfile
# old way
app=$(grep '^Exec' $deskfile | tail -1 | sed 's/^Exec=//' | sed 's/%.//' | sed 's/^"//g' | sed 's/" *$//g')
coproc ( $app > /dev/null 2>&1 )
break
fi
done
exit 0
fi
function init {
for file in /usr/share/settings-menu/*
do
local name=$(get_name "$file")
local iconline=$(sed -n -e '/^Icon=/p' "$file")
local icon=${iconline/Icon=/""}
if [ -n "$name" ]
then
echo -en "$name\0icon\x1f$icon\n"
fi
done
}
init
+135
View File
@@ -0,0 +1,135 @@
#!/usr/bin/env bash
# ABOUTME: Rofi-based settings menu that launches various system tools and scripts.
# ABOUTME: Provides a searchable list of system utilities like VPN, sound, bluetooth, etc.
declare -A LABELS
declare -A COMMANDS
###
# List of defined 'bangs'
# launch programs
# COMMANDS["apps"]="rofi -combi-modi window,drun -show combi"
# LABELS["apps"]=""
# open bookmarks
# COMMANDS["bookmarks"]="~/.scripts/rofi-scripts-collection/rofi-surfraw-bookmarks.sh"
# LABELS["bookmarks"]=""
# search local files
# COMMANDS[""]="moonarch-locate"
# LABELS[""]="Locate"
COMMANDS[""]="wlogout -P 1 -s -r 10 -c 10"
LABELS[""]="Session Menu"
# greenclip clipboard history
# source: https://github.com/erebe/greenclip
COMMANDS[""]='cliphist -db-path /run/user/1000/cliphist/db list | rofi -dmenu | cliphist -db-path /run/user/1000/cliphist/db decode | wl-copy'
LABELS[""]="Clipboard"
COMMANDS["󰖂"]='moonarch-vpn'
LABELS["󰖂"]='VPN Connection Manager'
COMMANDS[""]='waypaper'
LABELS[""]='Wallpaper Settings'
COMMANDS["󰗅"]='moonarch-volume'
LABELS["󰗅"]='Sound Manager'
#COMMANDS[""]='shortcuts module was removed'
#LABELS[""]='Hotkey List'
COMMANDS["󰍹"]='wdisplays'
LABELS["󰍹"]='Display Setup'
COMMANDS[""]='nwg-look'
LABELS[""]='Appearance Settings'
COMMANDS["󱘆"]='noisetorch'
LABELS["󱘆"]='Audio Noise Reduction'
COMMANDS["󰋋"]='$HOME/.local/share/headset-charge-indicator/headset-charge-indicator.py &'
LABELS["󰋋"]='Headset Control'
COMMANDS[""]='moonarch-bluetooth'
LABELS[""]='Bluetooth Control'
COMMANDS["󰛳"]='nm-applet --indicator &'
LABELS["󰛳"]='Networker Manager'
COMMANDS["󰴱"]='wl-color-picker'
LABELS["󰴱"]='Color Picker'
COMMANDS["󰚞"]='font-manager'
LABELS["󰚞"]='Font Manager'
COMMANDS["󱨑"]='gufw'
LABELS["󱨑"]='Firewall Settings'
COMMANDS[""]='env GTK_THEME=Adwaita:dark resources'
LABELS[""]='System Resources'
COMMANDS["󰓅"]='moonarch-cpugov'
LABELS["󰓅"]='CPU Modes'
COMMANDS["󰓅"]='hardinfo'
LABELS["󰓅"]='System Profiler and Benchmark'
COMMANDS["󰀠"]='alarm-clock-applet'
LABELS["󰀠"]='Alarm & Timer'
COMMANDS["󱓞"]='moonarch-launcher'
LABELS["󱓞"]='App Launcher'
################################################################################
# do not edit below
################################################################################
##
# Generate menu
##
function print_menu()
{
for key in ${!LABELS[@]}
do
# echo "$key ${LABELS}"
echo "$key ${LABELS[$key]}"
# my top version just shows the first field in labels row, not two words side by side
done
}
##
# Show rofi.
##
function start()
{
# print_menu | rofi -dmenu -p "?=>"
title="MoonArch \ $USER \ $(date +"%H:%M") \ $(uptime -p | sed 's/up //')"
print_menu | sort | rofi -theme /etc/xdg/rofi/settings-menu/settings-menu.rasi -show $title -dmenu -markup-rows -mesg "󰣇 $title" -i -p "rofi-bangs: "
}
# Run it
value="$(start)"
# Split input.
# grab upto first space.
choice=${value%%\ *}
# graph remainder, minus space.
input=${value:$((${#choice}+1))}
##
# Cancelled? bail out
##
if test -z ${choice}
then
exit
fi
# check if choice exists
if test ${COMMANDS[$choice]+isset}
then
# Execute the choice
${COMMANDS[$choice]}
else
echo "Unknown command: ${choice}" | rofi -dmenu -p "error"
fi
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/bash
# ABOUTME: Rofi-based PulseAudio sink switcher using ponymix.
# ABOUTME: Changes the default sink and moves all active streams to it.
# choose pulseaudio sink via rofi or dmenu
# changes default sink and moves all streams to that sink
#https://gist.github.com/Nervengift/844a597104631c36513c?permalink_comment_id=1826282
sink=$(ponymix -t sink list|awk '/^sink/ {s=$1" "$2;getline;gsub(/^ +/,"",$0);print s" "$0}'|rofi -dmenu -theme '/etc/xdg/rofi/volume/volume.rasi' -mesg '󱡫 Sink Switcher' -p 'pulseaudio sink:' -location 6 -width 100|grep -Po '[0-9]+(?=:)') &&
ponymix set-default -d $sink &&
for input in $(ponymix list -t sink-input|grep -Po '[0-9]+(?=:)');do
echo "$input -> $sink"
ponymix -t sink-input -d $input move $sink
done
+142
View File
@@ -0,0 +1,142 @@
#!/usr/bin/env bash
# ABOUTME: Rofi-based tool launcher with SSH and system utility shortcuts.
# ABOUTME: Provides a searchable menu of tools including VPN, sound, bluetooth, etc.
declare -A LABELS
declare -A COMMANDS
###
# List of defined 'bangs'
# launch programs
# COMMANDS["apps"]="rofi -combi-modi window,drun -show combi"
# LABELS["apps"]=""
# open bookmarks
# COMMANDS["bookmarks"]="~/.scripts/rofi-scripts-collection/rofi-surfraw-bookmarks.sh"
# LABELS["bookmarks"]=""
# search local files
COMMANDS[""]="moonarch-locate"
LABELS[""]="Locate"
# open custom web searches
# COMMANDS["websearch"]="~/.scripts/rofi-scripts-collection/rofi-surfraw-websearch.sh"
# LABELS["websearch"]=""
# show clipboard history
# source: https://bitbucket.org/pandozer/rofi-clipboard-manager/overview
# COMMANDS["clipboard"]='rofi -modi "clipboard:~/.bin/rofi-clipboard-manager/mclip.py menu" -show clipboard && ~/.bin/rofi-clipboard-manager/mclip.py paste'
# LABELS["clipboard"]=""
# references --------------------------
# COMMANDS[";sr2"]="chromium 'wikipedia.org/search-redirect.php?search=\" \${input}\""
# LABELS[";sr2"]=""
# COMMANDS[";piratebay"]="chromium --disk-cache-dir=/tmp/cache http://thepiratebay.org/search/\" \${input}\""
# LABELS[";piratebay"]=""
# COMMANDS[".bin"]="spacefm -r '/home/dka/bin'"
# LABELS[".bin"]=".bin"
# COMMANDS["#screenshot"]='/home/dka/bin/screenshot-scripts/myscreenshot.sh'
# LABELS["#screenshot"]="screenshot"
# greenclip clipboard history
# source: https://github.com/erebe/greenclip
COMMANDS[""]='rofi -modi "clipboard:greenclip print" -show Clipboard'
LABELS[""]="Clipboard"
COMMANDS["󰖂"]='moonarch-vpn'
LABELS["󰖂"]='VPN Connection Manager'
COMMANDS["󰗅"]='moonarch-volume'
LABELS["󰗅"]='Sound Manager'
#COMMANDS[""]='shortcuts module was removed'
#LABELS[""]='Hotkey List'
COMMANDS[""]='wlogout'
LABELS[""]='Session Menu'
COMMANDS["󰍹"]='wdisplays'
LABELS["󰍹"]='Display Setup'
COMMANDS[""]='nwg-look'
LABELS[""]='Appearance Settings'
COMMANDS["󱘆"]='noisetorch'
LABELS["󱘆"]='Audio Noise Reduction'
COMMANDS["󰋋"]='$HOME/.local/share/headset-charge-indicator/headset-charge-indicator.py &'
LABELS["󰋋"]='Headset Control'
COMMANDS[""]='moonarch-bluetooth'
LABELS[""]='Bluetooth Control'
COMMANDS["󰛳"]='nm-applet --indicator &'
LABELS["󰛳"]='Networker Manager'
COMMANDS["󰴱"]='wl-color-picker'
LABELS["󰴱"]='Color Picker'
COMMANDS["󰚞"]='font-manager'
LABELS["󰚞"]='Font Manager'
COMMANDS["󱨑"]='gufw'
LABELS["󱨑"]='Firewall Settings'
COMMANDS[""]='stacer'
LABELS[" "]='System Maintenance'
################################################################################
# do not edit below
################################################################################
##
# Generate menu
##
function print_menu()
{
for key in ${!LABELS[@]}
do
# echo "$key ${LABELS}"
echo "$key ${LABELS[$key]}"
# my top version just shows the first field in labels row, not two words side by side
done
}
##
# Show rofi.
##
function start()
{
# print_menu | rofi -dmenu -p "?=>"
print_menu | sort | rofi -show "Tools" -dmenu -mesg " Tools" -i -p "rofi-bangs: "
}
# Run it
value="$(start)"
# Split input.
# grab upto first space.
choice=${value%%\ *}
# graph remainder, minus space.
input=${value:$((${#choice}+1))}
##
# Cancelled? bail out
##
if test -z ${choice}
then
exit
fi
# check if choice exists
if test ${COMMANDS[$choice]+isset}
then
# Execute the choice
${COMMANDS[$choice]}
else
echo "Unknown command: ${choice}" | rofi -dmenu -p "error"
fi
+122
View File
@@ -0,0 +1,122 @@
#!/usr/bin/env bash
# ABOUTME: Rofi-based volume control applet for managing speakers and microphone.
# ABOUTME: Provides mute toggles, sink switching, mixer access, and NoiseTorch.
## Author : Aditya Shakya (adi1090x)
## Github : @adi1090x
#
## Applets : Volume
theme="/etc/xdg/rofi/volume/volume.rasi"
# Volume Info
mixer="`amixer info Master | grep 'Mixer name' | cut -d':' -f2 | tr -d \',' '`"
speaker="`amixer get Master | tail -n1 | awk -F ' ' '{print $5}' | tr -d '[]'`"
mic="`amixer get Capture | tail -n1 | awk -F ' ' '{print $5}' | tr -d '[]'`"
active=""
urgent=""
# Speaker Info
amixer get Master | grep '\[on\]' &>/dev/null
if [[ "$?" == 0 ]]; then
active="-a 1"
stext='Mute Speaker'
sicon='󰓃'
else
urgent="-u 1"
stext='Unmute Speaker'
sicon='󰓄'
fi
# Microphone Info
amixer get Capture | grep '\[on\]' &>/dev/null
if [[ "$?" == 0 ]]; then
[ -n "$active" ] && active+=",3" || active="-a 3"
mtext='Mute Mic'
micon=''
else
[ -n "$urgent" ] && urgent+=",3" || urgent="-u 3"
mtext='Unmute Mic'
micon=''
fi
currentsink=$(ponymix defaults|awk '/^sink/ {s=$1" "$2;getline;gsub(/^ +/,"",$0);print s" "$0}' | cut -d':' -f2)
currentsource=$(ponymix defaults|awk '/^source/ {s=$1" "$2;getline;gsub(/^ +/,"",$0);print s" "$0}' | cut -d':' -f2)
# Theme Elements
prompt="Speaker: $sicon Mic: $micon "
mesg="$mixer Speaker: $speaker Mic: $mic"
list_col='6'
list_row='3'
win_width='670px'
# Options
option_1="$micon $mtext $currentsource"
option_2="$sicon $stext $currentsink"
option_3="󱡫 Sink Switcher"
option_4=""
option_5=" Mixer"
option_6="󰍯 Noise Torch"
# Rofi CMD
#-theme-str "listview {columns: $list_col; lines: $list_row;}" \
rofi_cmd() {
rofi -theme-str "window {width: $win_width;}" \
-dmenu \
-p "$prompt" \
-mesg "$mesg" \
${active} ${urgent} \
-markup-rows \
-theme ${theme}
}
# Pass variables to rofi dmenu
run_rofi() {
echo -e "$option_1\n$option_2\n$option_3\n$option_4\n$option_5\n$option_6" | rofi_cmd
}
# Execute Command
run_cmd() {
if [[ "$1" == '--opt3' ]]; then
#amixer -Mq set Master,0 5%+ unmute
moonarch-sink-switcher
elif [[ "$1" == '--opt2' ]]; then
amixer set Master toggle
elif [[ "$1" == '--opt4' ]]; then
amixer -Mq set Master,0 5%- unmute
elif [[ "$1" == '--opt1' ]]; then
amixer set Capture toggle
elif [[ "$1" == '--opt5' ]]; then
pavucontrol
elif [[ "$1" == '--opt6' ]]; then
noisetorch
fi
}
# Actions
chosen="$(run_rofi)"
case ${chosen} in
$option_1)
run_cmd --opt1
;;
$option_2)
run_cmd --opt2
;;
$option_3)
run_cmd --opt3
;;
$option_4)
run_cmd --opt4
;;
$option_5)
run_cmd --opt5
;;
$option_6)
run_cmd --opt6
;;
esac
+101
View File
@@ -0,0 +1,101 @@
#!/usr/bin/env bash
# ABOUTME: Rofi-based VPN connection manager using NetworkManager (nmcli).
# ABOUTME: Lists VPN connections and toggles them on/off.
# Copyright (C) 2021 Damien Cassou
# Author: Damien Cassou <damien@cassou.me>
# Url: https://gitlab.com/DamienCassou/rofi-vpn
# Version: 0.2.0
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Commentary:
# This program uses rofi and nmcli to let the user enable/disable VPN
# connections.
# Code:
# What to show in front of an active VPN connection:
ACTIVE_PREFIX="󰌘 "
# What to show in front of an inactive VPN connection:
INACTIVE_PREFIX="󰌙 "
# Display on standard output all VPN connections, one per line. An
# active VPN connection is prefixed with `ACTIVE_PREFIX` and an inactive
# one is prefixed with `INACTIVE_PREFIX`.
function list_vpn_connections() {
nmcli --get-values ACTIVE,NAME,TYPE connection show \
| grep ':vpn$' \
| sed \
-e "s/^no:/${INACTIVE_PREFIX}/" \
-e "s/^yes:/${ACTIVE_PREFIX}/" \
-e 's/:vpn$//'
}
# Take a line as displayed by `list_vpn_connections()` as argument and
# use nmcli to toggle the corresponding connection.
function toggle_vpn_connection() {
local result="$1"
local connection
connection=$(extract_connection_name_from_result "${result}")
if [[ $result = ${ACTIVE_PREFIX}* ]]; then
feedback=$(nmcli connection down "$connection")
notify-send "VPN Status '$connection'" "$feedback"
else
foot -a="vpn-prompt" -T="VPN Connection" nmcli connection --ask up "$connection"
#feedback=$(nmcli connection up "$connection")
notify-send "VPN Status '$connection'" "Trying to connect"
fi
}
# Take a line as displayed by `list_vpn_connections()` as argument and
# remove `ACTIVE_PREFIX` or `INACTIVE_PREFIX` to only display the
# connection name.
function extract_connection_name_from_result() {
local result="$1"
# I don't know how to use plain bash to remove the prefix so I'm
# using sed:
# shellcheck disable=SC2001
sed -e 's/^.* \([^ ]\+\)$/\1/' <<< "$result"
}
# Execute the `rofi` command. The first argument of the function is
# used as lines to select from.
function start_rofi() {
local content="$1"
echo -e "$content" | rofi -dmenu -theme /etc/xdg/rofi/nm-vpn/nm-vpn.rasi -mesg "󰖂 VPN Connection Manager" -icon "󰖂"
}
# List the VPN connections and let the user toggle one using rofi.
function main() {
local connections
local result
connections=$(list_vpn_connections)
result=$(start_rofi "$connections")
if [ -n "$result" ]; then
toggle_vpn_connection "$result"
else
exit 1
fi
}
main
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/bash
# ABOUTME: Waybar-Modul das den CPU-Governor als JSON ausgibt.
# ABOUTME: Wird von der Waybar custom/cpugov Config referenziert.
while :
do
CPU_GOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
case $CPU_GOV in
performance)
CPU_GOV_SHORT=󰓅
;;
balanced)
CPU_GOV_SHORT=󰾅
;;
powersave)
CPU_GOV_SHORT=󰌪
;;
userspace)
CPU_GOV_SHORT=uspace
;;
ondemand)
CPU_GOV_SHORT=ondmnd
;;
conservative)
CPU_GOV_SHORT=cons
;;
schedutil)
CPU_GOV_SHORT=sutil
;;
*)
CPU_GOV_SHORT="?"
;;
esac
CPU_GOV_FULL="${CPU_GOV^}"
s="text|alt|tooltip|class
$CPU_GOV_SHORT|$CPU_GOV_FULL|CPU Mode: $CPU_GOV_FULL|cpugov"
jq --unbuffered --compact-output -Rn '
( input | split("|") ) as $keys |
( inputs | split("|") ) as $vals |
[[$keys, $vals] | transpose[] | {key:.[0],value:.[1]}] | from_entries
' <<<"$s"
sleep 5
done
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/bash
# ABOUTME: Waybar-Modul das die GPU-Auslastung als JSON ausgibt.
# ABOUTME: Wird von der Waybar custom/gpu-usage Config referenziert.
while :
do
GPU_STAT=$(cat /sys/class/hwmon/hwmon5/device/gpu_busy_percent 2>/dev/null || echo "0")
ICON="<span color='#69ff94' size='8pt' rise='1.5pt'>▁</span>"
if [ "$GPU_STAT" -lt 10 ]; then
ICON="<span color='#69ff94' size='8pt' rise='1.5pt'>▁</span>"
elif [ "$GPU_STAT" -lt 20 ]; then
ICON="<span color='#2aa9ff' size='8pt' rise='1.5pt'>▂</span>"
elif [ "$GPU_STAT" -lt 40 ]; then
ICON="<span color='#f8f8f2' size='8pt' rise='1.5pt'>▃</span>"
elif [ "$GPU_STAT" -lt 50 ]; then
ICON="<span color='#f8f8f2' size='8pt' rise='1.5pt'>▄</span>"
elif [ "$GPU_STAT" -lt 60 ]; then
ICON="<span color='#ffffa5' size='8pt' rise='1.5pt'>▅</span>"
elif [ "$GPU_STAT" -lt 70 ]; then
ICON="<span color='#ffffa5' size='8pt' rise='1.5pt'>▆</span>"
elif [ "$GPU_STAT" -lt 80 ]; then
ICON="<span color='#ff9977' size='8pt' rise='1.5pt'>▇</span>"
elif [ "$GPU_STAT" -lt 100 ]; then
ICON="<span color='#dd532e' size='8pt' rise='1.5pt'>█</span>"
fi
s="text|alt|tooltip|class|percentage
GPU $ICON|GPU $ICON $GPU_STAT%|GPU $ICON $GPU_STAT%|gpustat|$GPU_STAT"
jq --unbuffered --compact-output -Rn '
( input | split("|") ) as $keys |
( inputs | split("|") ) as $vals |
[[$keys, $vals] | transpose[] | {key:.[0],value:.[1]}] | from_entries
' <<<"$s"
sleep 5
done