···11-#!/bin/sh
22-# Some applications (namely java apps) get the home directory from /etc/passwd meaning that
33-# we can't easily prevent these apps from writing in the home directory by changing the HOME env
44-# var. Use bubblewrap to bind a random directory to /home/$USER instead.
55-66-# Make sure we have a command to execute
77-[ "$*" ] || {
88- printf '%s\n' "Missing command to execute" 1>&2
99- exit 1
1010-}
1111-1212-# If HOMEWRAP_HOME isn't set, make our own and ensure that it exists
1313-: "${HOMEWRAP_HOME:=${XDG_STATE_HOME:-$HOME/.local/state}/homewrap/default}"
1414-mkdir -p "$HOMEWRAP_HOME"
1515-1616-# Create sandbox with temporary home
1717-# This breaks if there is a broken symlink in the directory
1818-args="--dev-bind / / --dev-bind $HOMEWRAP_HOME $HOME "
1919-2020-# Recreate the home directory
2121-for i in "$HOME/"* "$HOME/".*
2222-do
2323- case $i in
2424- "$HOME/." ) continue ;;
2525- "$HOME/.." ) continue ;;
2626- esac
2727- args="${args}--dev-bind $i $i "
2828-done
2929-3030-# shellcheck disable=SC2086
3131-exec bwrap $args "$@"
-67
data/shellscripts/info-fetch
···11-#!/bin/sh
22-# Print some information about the system. This script was written with gentoo systems in mind.
33-44-# Used Environment Variables
55-# $SHELL
66-# $USER
77-88-# Used Files
99-# /etc/os-release
1010-# /proc/sys/kernel/hostname
1111-# /proc/uptime
1212-# /proc/version
1313-1414-# Get the hostname of the computer
1515-read -r hostname < /proc/sys/kernel/hostname
1616-1717-# Source /etc/os-release if it exist
1818-# shellcheck source=/dev/null
1919-[ -f /etc/os-release ] && . /etc/os-release
2020-[ "$PRETTY_NAME" ] || PRETTY_NAME="Linux"
2121-2222-# Get the kernel version
2323-read -r _ _ kernel_version _ < /proc/version
2424-2525-# Read uptime
2626-read -r uptime _ < /proc/uptime
2727-2828-# Remove extra percision
2929-up=${uptime%.*}
3030-3131-# Calculate days, hours, minutes and seconds from the given output
3232-days=$((up / 86400))
3333-hours=$(((up % 86400) / 3600))
3434-min=$((((up % 86400) % 3600) / 60))
3535-sec=$((((up % 86400) % 3600) % 60))
3636-3737-# Only display the value if it is not zero
3838-[ $days = 0 ] || dout="${days}d "
3939-[ $hours = 0 ] || hout="${hours}h "
4040-[ $min = 0 ] || mout="${min}m "
4141-[ $sec = 0 ] || sout="${sec}s"
4242-pretty_uptime="$dout$hout$mout$sout"
4343-4444-# Calculate package count (Gentoo)
4545-set -- /var/db/pkg/*/*
4646-pkg_count=$#
4747-4848-# Color Showcase
4949-for i in 0 1 2 3 4 5 6 7
5050-do
5151- normal_colors="$normal_colors\033[4${i}m\033[3${i}m "
5252- bright_colors="$bright_colors\033[10${i}m\033[9${i}m "
5353-done
5454-5555-# Colors and Formatting
5656-color="\033[35;1m"
5757-nocolor="\033[m"
5858-underline="\033[4m"
5959-6060-printf '%b\n' "\n$color$underline$USER$nocolor@$underline$color$hostname$nocolor" \
6161- "${color}os$nocolor $PRETTY_NAME" \
6262- "${color}ke$nocolor $kernel_version" \
6363- "${color}up$nocolor $pretty_uptime" \
6464- "${color}sh$nocolor ${SHELL##*/}" \
6565- "${color}pk$nocolor $pkg_count\n" \
6666- "$normal_colors$nocolor" \
6767- "$bright_colors$nocolor\n"
-61
data/shellscripts/moulog
···11-#!/bin/sh
22-# A much better way to handle my logging
33-44-#- Settings -#
55-# Place to store log files
66-: "${MOULOG_DIR:=${XDG_CACHE_HOME:-$HOME/.cache}/moulog}"
77-# Max number of old dirs to keep
88-: "${MOULOG_MAX:=5}"
99-1010-# TODO: Add option to name the log file.
1111-# As of right now, my wayfire logs aren't named anything related to wayfire.
1212-# This also extends to other logs.
1313-1414-usage() {
1515- while read -r line
1616- do printf '%b\n' "$line"
1717- done <<-EOF
1818- ${0##*/} [options] [command]
1919- example: moulog -n
2020- example: moulog wlsunset -l 0 -L 0
2121-2222- options:
2323- -h | --help - display this message
2424- -n | --new - create a new logging directory
2525- - useful if being run multiple times in the background
2626-2727- environment vars:
2828- MOULOG_DIR - place to store logs (default: $XDG_CACHE_HOME/moulog)
2929- MOULOG_MAX - max number of old dirs to keep (default: 5)
3030- EOF
3131-3232- exit "${1:-1}"
3333-}
3434-3535-new_dir() {
3636- touch /tmp/moulog
3737- [ -d "$MOULOG_DIR.$MOULOG_MAX" ] && rm -r "$MOULOG_DIR.$MOULOG_MAX"
3838-3939- i=$((MOULOG_MAX))
4040- until [ $i = 1 ]
4141- do
4242- [ -d "$MOULOG_DIR.$((i-1))" ] && mv "$MOULOG_DIR.$((i-1))" "$MOULOG_DIR.$i"
4343- i=$((i-1))
4444- done
4545-4646- [ -d "$MOULOG_DIR" ] && mv "$MOULOG_DIR" "$MOULOG_DIR.1"
4747- mkdir -p "$MOULOG_DIR"
4848-}
4949-5050-case $1 in
5151- -h|--help ) usage 0 ;;
5252- -n|--new ) new_dir; exit 0 ;;
5353- -N|--name ) program_name=$2; shift 2 ;;
5454-esac
5555-5656-# Using this file to decide if a new directory should be made
5757-[ -f /tmp/moulog ] || new_dir
5858-5959-6060-printf '%s\n' "#### moulog start time: $(date +%s) ####" >> "$MOULOG_DIR/${program_name:=$1}.log"
6161-exec "$@" >> "$MOULOG_DIR/${program_name:=$1}.log" 2>&1