clean scripts

This commit is contained in:
lelgenio 2019-12-01 19:21:31 -03:00
parent 1820c4729c
commit 5203d799c3
11 changed files with 25 additions and 447 deletions

View File

@ -1,36 +0,0 @@
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
if [ ! -f /usr/bin/metacity ]; then
zenity --warning --text="<b>You do not appear to have Metacity installed.</b>\n\nThe Compiz GTK window decorator uses Metacity libraries to operate. The Metacity theme is what this tool adjusts.\n\nInstall the metacity package if you would like to use the Compiz GTK window decorator."
fi
main_window() {
selection=$(
zenity --height 450 --width 320 --list --ok-label="Apply" --cancel-label="Close" --title="Metacity themes" \
--column="Current theme: $( if [ $(gsettings get org.gnome.desktop.wm.preferences theme) == "''" ]; then
echo Default
else
gsettings get org.gnome.desktop.wm.preferences theme
fi)" \
"Compiz GWD default" \
$(
for d in /usr/share/themes/*/metacity-1; do
echo $d | sed 's:/usr/share/themes/::' | sed 's:/metacity-1::'
done
)
)
}
while [ $? = 0 ]; do
if [ "$selection" == "Compiz GWD default" ]; then
gsettings set org.gnome.desktop.wm.preferences theme ""
elif [ "$selection" != "" ]; then
gsettings set org.gnome.desktop.wm.preferences theme "$selection"
fi
main_window
done
IFS=$SAVEIFS

View File

@ -1,293 +0,0 @@
#!/usr/bin/env bash
# lightson+
# Copyright (c) 2018 spinal.by at gmail com
# Copyright (c) 2014 devkral at web de
# url: https://github.com/devkral/lightsonplus
#based on
# Copyright (c) 2011 iye.cba at gmail com
# url: https://github.com/iye/lightsOn
# This script is licensed under GNU GPL version 2.0 or above
# Description: Bash script that prevents the screensaver and display power
# management (DPMS) from being activated while watching fullscreen videos
# on Firefox, Chrome and Chromium. Media players like mplayer, VLC and minitube
# can also be detected.
# One of {x, k, gnome-}screensaver must be installed.
# HOW TO USE:
# "./lightson+ -d 2 &" will check every 2 minutes if Mplayer, VLC, Firefox or
# Chromium are fullscreen and delay screensaver and Power Management if so.
# If you don't pass an argument, the checks are done every minute.
# Select the programs to be checked
mplayer_detection=1
vlc_detection=1
totem_detection=1
firefox_flash_detection=1
chromium_flash_detection=1
#chrome_app_name="Netflix"
webkit_flash_detection=1
html5_detection=1
steam_detection=0
minitube_detection=0
audio_detection=0
#minload=1.5
delay=1
# realdisp
realdisp=`echo "$DISPLAY" | cut -d. -f1`
inhibitfile="/tmp/lightsoninhibit-$UID-$realdisp"
pidfile="/tmp/lightson-$UID-$realdisp.pid"
# YOU SHOULD NOT NEED TO MODIFY ANYTHING BELOW THIS LINE
die() {
echo "$@" >&2
exit 1
}
pidcreate() {
# just one instance can run simultaneously
if [ ! -e "$pidfile" ]; then
echo "$$" > "$pidfile"
else
if [ -d "/proc/$(cat "$pidfile")" ]; then
die "Another instance is running, abort!"
else
echo "$$" > "$pidfile"
fi
fi
}
pidremove() {
if [ ! -e "$pidfile" ]; then
echo "Error: missing pidfile" >&2
elif [ ! -f "$pidfile" ]; then
echo -e "Error: \"$pidfile\" is not a file\n" >&2
else
if [ "$(cat "$pidfile")" != "$$" ]; then
die "Another instance is running, abort!"
else
rm -f "$pidfile"
fi
fi
exit 0
}
pidcreate
trap "pidremove" EXIT
# Enumerate all the attached screens
displays=""
while read id; do
displays="$displays $id"
done< <(xvinfo | sed -n 's/^screen #\([0-9]\+\)$/\1/p')
# Detect screensaver being used
if [ `dbus-send --session --print-reply=literal --type=method_call --dest=org.freedesktop.ScreenSaver /ScreenSaver/ org.freedesktop.ScreenSaver.GetActive &> /dev/null; echo $?` -eq 0 ]; then
screensaver="freedesktop-screensaver"
#elif [ `pgrep -c gnome-shell` -ge 1 ] ;then
# screensaver="xdofallback"
elif [ `pgrep -c xscreensaver` -ge 1 ]; then
screensaver="xscreensaver"
elif [ `pgrep -c mate-screensaver` -ge 1 ]; then
screensaver="mate-screensaver"
elif [ `pgrep -c xautolock` -ge 1 ]; then
screensaver="xautolock"
elif [ -e "/usr/bin/xdotool" ]; then
screensaver="xdofallback"
else
screensaver=""
die "No screensaver detected"
fi
checkFullscreen() {
# loop through every display looking for a fullscreen window
for display in $displays; do
# get id of active window and clean output
active_win_id=`DISPLAY=$realdisp.${display} xprop -root _NET_ACTIVE_WINDOW`
active_win_id=${active_win_id##*# }
active_win_id=${active_win_id:0:9} # eliminate potentially trailing spaces
top_win_id=`DISPLAY=$realdisp.${display} xprop -root _NET_CLIENT_LIST_STACKING`
top_win_id=${active_win_id##*, }
top_win_id=${top_win_id:0:9} # eliminate potentially trailing spaces
# Check if Active Window (the foremost window) is in fullscreen state
if [ ${#active_win_id} -ge 3 ]; then
isActiveWinFullscreen=`DISPLAY=$realdisp.${display} xprop -id $active_win_id | grep _NET_WM_STATE_FULLSCREEN`
else
isActiveWinFullscreen=""
fi
if [ ${#top_win_id} -ge 3 ]; then
isTopWinFullscreen=`DISPLAY=$realdisp.${display} xprop -id $top_win_id | grep _NET_WM_STATE_FULLSCREEN`
else
isTopWinFullscreen=""
fi
if [[ "$isActiveWinFullscreen" = *NET_WM_STATE_FULLSCREEN* ]] || [[ "$isTopWinFullscreen" = *NET_WM_STATE_FULLSCREEN* ]]; then
isAppRunning && delayScreensaver
fi
done
}
# Check if active window is mplayer, vlc or firefox
# Then change IFs to detect more specifically the apps "<vlc>" and if process name exist
isAppRunning() {
# Get title of active window
active_win_title=`xprop -id $active_win_id | grep "WM_CLASS(STRING)" | sed 's/^.*", //;s/"//g'`
case "$active_win_title" in
*[Cc]hromium*)
[ "$chromium_flash_detection" = 1 ] && [ `pgrep -fc "chromium --type=ppapi"` -ge 1 ] && return 0
[ "$html5_detection" = 1 ] && [ `pgrep -c chromium` -ge 1 ] && checkAudio "chromium" && return 0
;;
*[Cc]hrome*)
[ "$chromium_flash_detection" = 1 ] && [ `pgrep -fc "chrome --type=ppapi"` -ge 1 ] && return 0
[ "$html5_detection" = 1 ] && [ `pgrep -c chrome` -ge 1 ] && checkAudio "chrom" && return 0
;;
*Firefox*)
[ "$html5_detection" = 1 ] && [ `pgrep -c firefox` -ge 1 ] && checkAudio "firefox" && return 0
;;
*opera*)
[ "$html5_detection" = 1 ] && [ `pgrep -c opera` -ge 1 ] && checkAudio "opera" && return 0
;;
*epiphany*)
[ "$html5_detection" = 1 ] && [ `pgrep -c epiphany` -ge 1 ] && checkAudio "epiphany" && return 0
;;
*unknown*|*plugin-container*)
[ "$firefox_flash_detection" = 1 ] && [ `pgrep -c plugin-container` -ge 1 ] && return 0
;;
*WebKitPluginProcess*)
[ "$webkit_flash_detection" = 1 ] && [ `pgrep -fc ".*WebKitPluginProcess.*flashp.*"` -ge 1 ] && return 0
;;
*MPlayer|mplayer*)
[ "$mplayer_detection" = 1 ] && [ `pgrep -c mplayer` -ge 1 ] && checkAudio mplayer && return 0
;;
*vlc*|*VLC*)
[ $vlc_detection = 1 ] && [ `pgrep -c vlc` -ge 1 ] && checkAudio vlc && return 0
;;
*totem*)
[ $totem_detection = 1 ] && [ `pgrep -c totem` -ge 1 ] && checkAudio totem && return 0
;;
*steam*)
[ $steam_detection = 1 ] && [ `pgrep -c steam` -ge 1 ] && return 0
;;
*minitube*)
[ $minitube_detection = 1 ] && [ `pgrep -c minitube` -ge 1 ] && return 0
;;
*)
if [ -n "$chrome_app_name" ]; then
# Check if google chrome is running in app mode
[[ "$active_win_title" == *$chrome_app_name* ]] && [ `pgrep -fc "chrome --app"` -ge 1 ] && return 0
fi
;;
esac
[ -n "$minload" ] && [ "$(echo "$(sed 's/ .*$//' /proc/loadavg) > $minload" | bc -q)" -eq "1" ] && return 0
false
}
checkAudio() {
# Check if application is streaming sound to PulseAudio
[ $audio_detection = 0 ] && return 0
pacmd list-sink-inputs | grep -Eiq "application.name = .*$1.*"
}
delayScreensaver() {
# Reset inactivity time counter so screensaver is not started
case $screensaver in
"xscreensaver" )
xscreensaver-command -deactivate > /dev/null;;
"mate-screensaver" )
mate-screensaver-command --poke > /dev/null;;
"xautolock" )
xautolock -disable
xautolock -enable;;
"xdofallback" )
xdotool key shift
;;
"freedesktop-screensaver" )
dbus-send --session --reply-timeout=2000 --type=method_call --dest=org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.SimulateUserActivity;;
esac
# Check if DPMS is on. If it is, deactivate and reactivate again. If it is not, do nothing.
dpmsStatus=`xset -q | grep -c 'DPMS is Enabled'`
[ "$dpmsStatus" = 1 ] && xset -dpms && xset dpms
}
help() {
echo "USAGE: $ lighsonplus [FLAG1 ARG1] ... [FLAGn ARGn]"
echo "FLAGS (ARGUMENTS must be 0 or 1, except stated otherwise):"
echo ""
echo " -d, --delay Time interval in minutes, default is 1 min"
echo " -pa, --audio Audio detection"
echo " -mp, --mplayer mplayer detection"
echo " -v, --vlc VLC detection"
echo " -t, --totem Totem detection"
echo " -ff, --firefox-flash Firefox flash plugin detection"
echo " -cf, --chromium-flash Chromium flash plugin detection"
echo " -ca, --chrome-app Chrome app detection, app name must be passed"
echo " -wf, --webkit-flash Webkit flash detection"
echo " -h5, --html5 HTML5 detection"
echo " -s, --steam Steam detection"
echo " -mt, --minitube MiniTube detection"
echo " -la, --minload Load average detection"
}
checkBool() {
[ -n "$2" ] && [[ $2 = [01] ]] || die "Invalid argument. 0 or 1 expected after \"$1\" flag."
}
while [ -n "$1" ]; do
case $1 in
"-d" | "--delay" )
[[ -z "$2" || "$2" = *[^0-9]* ]] && die "Invalid argument. Time in minutes expected after \"$1\" flag. Got \"$2\"" || delay=$2;;
"-ca" | "--chrome-app" )
[ -n "$2" ] && chrome_app_name="$2" || die "Missing argument. Chrome app name expected after \"$1\" flag.";;
"-la" | "--minload" )
[ -n "$2" ] && [[ "$(echo "$2 > 0" | bc -q)" -eq 1 ]] && minload=$2 || die "Invalid argument. >0 expected after \"$1\" flag.";;
"-pa" | "--audio" )
checkBool "$@"; audio_detection=$2;;
"-mp" | "--mplayer" )
checkBool "$@"; mplayer_detection=$2;;
"-v" | "--vlc" )
checkBool "$@"; vlc_detection=$2;;
"-t" | "--totem" )
checkBool "$@"; totem_detection=$2;;
"-ff" | "--firefox-flash" )
checkBool "$@"; firefox_flash_detection=$2;;
"-cf" | "--chromium-flash" )
checkBool "$@"; chromium_flash_detection=$2;;
"-wf" | "--webkit-flash" )
checkBool "$@"; webkit_flash_detection=$2;;
"-h5" | "--html5" )
checkBool "$@"; html5_detection=$2;;
"-s" | "--steam" )
checkBool "$@"; steam_detection=$2;;
"-mt" | "--minitube" )
checkBool "$@"; minitube_detection=$2;;
"-h" | "--help" )
help && exit 0;;
* )
die "Invalid argument. See -h, --help for more information.";;
esac
# Arguments must always be passed in tuples
shift 2
done
# Convert delay to seconds. We substract 10 for assurance.
delay=$[delay*60-10]
echo "Start lightson+ mainloop"
while true; do
[ -f "$inhibitfile" ] && delayScreensaver || checkFullscreen
sleep $delay
done
exit 0

View File

@ -1,47 +0,0 @@
#!/bin/bash
# Requires: xprop
##################################
# Adjust values to suit
PANEL=top
PANEL_ALPHA_REGULAR=0
PANEL_ALPHA_MAXIMUM=1
##################################
##################################
# don't change anything below here
gsettings set org.mate.panel.toplevel.background:/org/mate/panel/toplevels/top/background/ type "color"
CURR=0
while true
do
MAX_FND=0
for w in $(xprop -notype -root _NET_CLIENT_LIST 2>/dev/null | cut -d'#' -f2 | tr ',' '\n' | awk '{print $1}')
do
if [[ "$(xprop -id $w -notype _NET_WM_DESKTOP 2>/dev/null | cut -d' ' -f3)" -eq "$(xprop -root -notype _NET_CURRENT_DESKTOP 2>/dev/null | cut -d' ' -f3)" ]]
then
if xprop -id $w _NET_WM_STATE | grep -E "MAXIMIZED_HORZ.*MAXIMIZED_VERT" > /dev/null 2>&1
then
if xprop -id $w WM_STATE | grep -E "window state: Normal" > /dev/null 2>&1
then
MAX_FND=1
break
fi
fi
fi
done
if [[ $MAX_FND -eq 1 && $CURR -eq 0 ]]
then
gsettings set org.mate.panel.toplevel.background:/org/mate/panel/toplevels/${PANEL}/background/ color "rgba(60,59,55,$PANEL_ALPHA_MAXIMUM)"
CURR=1
elif [[ $MAX_FND -eq 0 && $CURR -eq 1 ]]
then
gsettings set org.mate.panel.toplevel.background:/org/mate/panel/toplevels/${PANEL}/background/ color "rgba(60,59,55,$PANEL_ALPHA_REGULAR)"
CURR=0
fi
sleep 1
done
exit 0

View File

@ -1,9 +0,0 @@
#!/bin/sh
music=$(mpc listall --format '%artist% : %title% ' | rofi -i -dmenu)
artist=$(echo "$music" | cut -d: -f1)
title=$(echo "$music" | cut -d: -f2)
echo title "$title" artist "$artist"
mpc searchplay title "$title"
#artist "$artist"

View File

@ -1,5 +0,0 @@
#!/bin/sh
scrot "Imagens/Screenshots/%Y-%m-%d_%H-%M-%S.$t" -e \
"xclip -selection clipboard -target image/png -i $f" \
-e "twmnc 'Captura de tela copiada e sava em $f' --ac 'feh $f'"

View File

@ -1,5 +0,0 @@
#!/bin/bash
xfconf-query --channel xfce4-desktop \
--property /backdrop/screen0/monitorHDMI-2/workspace0/last-image \
--set $1
echo $1

View File

@ -1,3 +0,0 @@
#!/bin/sh
pactl set-sink-volume @DEFAULT_SINK@ $1

View File

@ -1,48 +0,0 @@
#!/usr/bin/env bash
#-- CONFIGURATION
transparent_alpha=0
maximized_alpha=100
interval=0.5
#--
alpha_prop_list=()
for prop in $(xfconf-query -c xfce4-panel -p /panels -l); do
[[ "$prop" == *"background-alpha"* ]] && alpha_prop_list+=($prop)
done
on_maximized() {
for alpha_prop in "${alpha_prop_list[@]}"; do
xfconf-query -c xfce4-panel -p "$alpha_prop" -s "$maximized_alpha"
done
}
on_no_window_maximized() {
for alpha_prop in "${alpha_prop_list[@]}"; do
xfconf-query -c xfce4-panel -p "$alpha_prop" -s "$transparent_alpha"
done
}
echo $alpha_prop_list
while true; do
current_desktop=$(wmctrl -d | grep '*' | cut -d ' ' -f1)
is_any_window_maximized=false
for i in $(wmctrl -lG | awk -v d="$current_desktop" '$2==d {print $1}'); do
status=$(xprop -id $i _NET_WM_STATE)
if [[ "$status" == *"MAXIMIZED"* && "$status" != *"HIDDEN"* ]]; then
is_any_window_maximized=true
break
else
is_any_window_maximized=false
fi
done
if [[ $is_any_window_maximized == true ]]; then
on_maximized
else
on_no_window_maximized
fi
sleep $interval
done

15
scripts/.local/bin/bmenu Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
BEMENU_BACKEND=w
bemenu \
--ignorecase\
--bottom\
--list 20\
--prefix '->'\
--fn "pango:Inter 12"\
--tb "#202020" --tf "#cc5757" \
--fb "#202020" --ff "#cccccc" \
--nb "#202020" --nf "#cccccc" \
--hb "#303030" --hf "#cc5757" \
$@

View File

@ -1,7 +1,7 @@
#!/bin/bash
opts="Fone\nSpeaker\nHDMI"
out=$(echo -e $opts | wofi -p "Saida:" --dmenu)
out=$(echo -e $opts | .local/bin/bmenu -p "Saida:")
if [ "$out" == "HDMI" ]
then

9
scripts/.local/bin/rofimusic Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
set -ex
music=$(mpc listall --format '%artist% : %title%' | bmenu)
artist=$(echo "$music" | perl -pe 's/(.*) : (.*)/\1/')
title=$(echo "$music" | perl -pe 's/(.*) : (.*)/\2/')
echo title "'$title'" artist "'$artist'"
mpc searchplay artist "$artist" title "$title"