Přidání nových skriptů a konfiguračních souborů
This commit is contained in:
parent
4984384a94
commit
f86f4cb729
18
.config/i3/scripts/battery-pinebook-pro
Executable file
18
.config/i3/scripts/battery-pinebook-pro
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#simple Shellscript for i3blocks on Pinebook pro
|
||||||
|
#05012020 geri123@gmx.net Gerhard S.
|
||||||
|
#battery-symbols: on Manjaro you need the awesome-terminal-fonts package installed!
|
||||||
|
PERCENT=$(cat /sys/class/power_supply/cw2015-battery/capacity)
|
||||||
|
STATUS=$(cat /sys/class/power_supply/cw2015-battery/status)
|
||||||
|
case $((
|
||||||
|
$PERCENT >= 0 && $PERCENT <= 20 ? 1 :
|
||||||
|
$PERCENT > 20 && $PERCENT <= 40 ? 2 :
|
||||||
|
$PERCENT > 40 && $PERCENT <= 60 ? 3 :
|
||||||
|
$PERCENT > 60 && $PERCENT <= 80 ? 4 : 5)) in
|
||||||
|
#
|
||||||
|
(1) echo $STATUS:"" :$PERCENT%;;
|
||||||
|
(2) echo $STATUS:"" :$PERCENT%;;
|
||||||
|
(3) echo $STATUS:"" :$PERCENT%;;
|
||||||
|
(4) echo $STATUS:"" :$PERCENT%;;
|
||||||
|
(5) echo $STATUS:"" :$PERCENT%;;
|
||||||
|
esac
|
106
.config/i3/scripts/battery2
Executable file
106
.config/i3/scripts/battery2
Executable file
@ -0,0 +1,106 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# Copyright (C) 2016 James Murphy
|
||||||
|
# Licensed under the GPL version 2 only
|
||||||
|
#
|
||||||
|
# A battery indicator blocklet script for i3blocks
|
||||||
|
|
||||||
|
from subprocess import check_output
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
config = dict(os.environ)
|
||||||
|
status = check_output(['acpi'], universal_newlines=True)
|
||||||
|
|
||||||
|
if not status:
|
||||||
|
# stands for no battery found
|
||||||
|
color = config.get("color_10", "red")
|
||||||
|
fulltext = "<span color='{}'><span font='FontAwesome'>\uf00d \uf240</span></span>".format(color)
|
||||||
|
percentleft = 100
|
||||||
|
else:
|
||||||
|
# if there is more than one battery in one laptop, the percentage left is
|
||||||
|
# available for each battery separately, although state and remaining
|
||||||
|
# time for overall block is shown in the status of the first battery
|
||||||
|
batteries = status.split("\n")
|
||||||
|
state_batteries=[]
|
||||||
|
commasplitstatus_batteries=[]
|
||||||
|
percentleft_batteries=[]
|
||||||
|
time = ""
|
||||||
|
for battery in batteries:
|
||||||
|
if battery!='':
|
||||||
|
state_batteries.append(battery.split(": ")[1].split(", ")[0])
|
||||||
|
commasplitstatus = battery.split(", ")
|
||||||
|
if not time:
|
||||||
|
time = commasplitstatus[-1].strip()
|
||||||
|
# check if it matches a time
|
||||||
|
time = re.match(r"(\d+):(\d+)", time)
|
||||||
|
if time:
|
||||||
|
time = ":".join(time.groups())
|
||||||
|
timeleft = " ({})".format(time)
|
||||||
|
else:
|
||||||
|
timeleft = ""
|
||||||
|
|
||||||
|
p = int(commasplitstatus[1].rstrip("%\n"))
|
||||||
|
if p>0:
|
||||||
|
percentleft_batteries.append(p)
|
||||||
|
commasplitstatus_batteries.append(commasplitstatus)
|
||||||
|
state = state_batteries[0]
|
||||||
|
commasplitstatus = commasplitstatus_batteries[0]
|
||||||
|
if percentleft_batteries:
|
||||||
|
percentleft = int(sum(percentleft_batteries)/len(percentleft_batteries))
|
||||||
|
else:
|
||||||
|
percentleft = 0
|
||||||
|
|
||||||
|
# stands for charging
|
||||||
|
color = config.get("color_charging", "yellow")
|
||||||
|
FA_LIGHTNING = "<span color='{}'><span font='FontAwesome'>\uf0e7</span></span>".format(color)
|
||||||
|
|
||||||
|
# stands for plugged in
|
||||||
|
FA_PLUG = "<span font='FontAwesome'>\uf1e6</span>"
|
||||||
|
|
||||||
|
# stands for using battery
|
||||||
|
FA_BATTERY = "<span font='FontAwesome'>\uf240</span>"
|
||||||
|
|
||||||
|
# stands for unknown status of battery
|
||||||
|
FA_QUESTION = "<span font='FontAwesome'>\uf128</span>"
|
||||||
|
|
||||||
|
|
||||||
|
if state == "Discharging":
|
||||||
|
fulltext = FA_BATTERY + " "
|
||||||
|
elif state == "Full":
|
||||||
|
fulltext = FA_PLUG + " "
|
||||||
|
timeleft = ""
|
||||||
|
elif state == "Unknown":
|
||||||
|
fulltext = FA_QUESTION + " " + FA_BATTERY + " "
|
||||||
|
timeleft = ""
|
||||||
|
else:
|
||||||
|
fulltext = FA_LIGHTNING + " " + FA_PLUG + " "
|
||||||
|
|
||||||
|
def color(percent):
|
||||||
|
if percent < 10:
|
||||||
|
# exit code 33 will turn background red
|
||||||
|
return config.get("color_10", "#FFFFFF")
|
||||||
|
if percent < 20:
|
||||||
|
return config.get("color_20", "#FF3300")
|
||||||
|
if percent < 30:
|
||||||
|
return config.get("color_30", "#FF6600")
|
||||||
|
if percent < 40:
|
||||||
|
return config.get("color_40", "#FF9900")
|
||||||
|
if percent < 50:
|
||||||
|
return config.get("color_50", "#FFCC00")
|
||||||
|
if percent < 60:
|
||||||
|
return config.get("color_60", "#FFFF00")
|
||||||
|
if percent < 70:
|
||||||
|
return config.get("color_70", "#FFFF33")
|
||||||
|
if percent < 80:
|
||||||
|
return config.get("color_80", "#FFFF66")
|
||||||
|
return config.get("color_full", "#FFFFFF")
|
||||||
|
|
||||||
|
form = '<span color="{}">{}%</span>'
|
||||||
|
fulltext += form.format(color(percentleft), percentleft)
|
||||||
|
#fulltext += timeleft
|
||||||
|
|
||||||
|
print(fulltext)
|
||||||
|
print(fulltext)
|
||||||
|
if percentleft < 10:
|
||||||
|
exit(33)
|
62
.config/i3/scripts/cpu_usage
Executable file
62
.config/i3/scripts/cpu_usage
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# Copyright 2014 Pierre Mavro <deimos@deimos.fr>
|
||||||
|
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
|
||||||
|
# Copyright 2014 Andreas Guldstrand <andreas.guldstrand@gmail.com>
|
||||||
|
#
|
||||||
|
# Licensed under the terms of the GNU GPL v3, or any later version.
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use utf8;
|
||||||
|
use Getopt::Long;
|
||||||
|
|
||||||
|
# default values
|
||||||
|
my $t_warn = $ENV{T_WARN} // 50;
|
||||||
|
my $t_crit = $ENV{T_CRIT} // 80;
|
||||||
|
my $cpu_usage = -1;
|
||||||
|
my $decimals = $ENV{DECIMALS} // 0;
|
||||||
|
my $label = $ENV{LABEL} // "";
|
||||||
|
|
||||||
|
sub help {
|
||||||
|
print "Usage: cpu_usage [-w <warning>] [-c <critical>] [-d <decimals>]\n";
|
||||||
|
print "-w <percent>: warning threshold to become yellow\n";
|
||||||
|
print "-c <percent>: critical threshold to become red\n";
|
||||||
|
print "-d <decimals>: Use <decimals> decimals for percentage (default is $decimals) \n";
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetOptions("help|h" => \&help,
|
||||||
|
"w=i" => \$t_warn,
|
||||||
|
"c=i" => \$t_crit,
|
||||||
|
"d=i" => \$decimals,
|
||||||
|
);
|
||||||
|
|
||||||
|
# Get CPU usage
|
||||||
|
$ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is
|
||||||
|
open (MPSTAT, 'mpstat 1 1 |') or die;
|
||||||
|
while (<MPSTAT>) {
|
||||||
|
if (/^.*\s+(\d+\.\d+)[\s\x00]?$/) {
|
||||||
|
$cpu_usage = 100 - $1; # 100% - %idle
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(MPSTAT);
|
||||||
|
|
||||||
|
$cpu_usage eq -1 and die 'Can\'t find CPU information';
|
||||||
|
|
||||||
|
# Print short_text, full_text
|
||||||
|
print "${label}";
|
||||||
|
printf "%02.${decimals}f%%\n", $cpu_usage;
|
||||||
|
print "${label}";
|
||||||
|
printf "%02.${decimals}f%%\n", $cpu_usage;
|
||||||
|
|
||||||
|
# Print color, if needed
|
||||||
|
if ($cpu_usage >= $t_crit) {
|
||||||
|
print "#FF0000\n";
|
||||||
|
exit 33;
|
||||||
|
} elsif ($cpu_usage >= $t_warn) {
|
||||||
|
print "#FFFC00\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0;
|
10
.config/i3/scripts/empty_workspace
Executable file
10
.config/i3/scripts/empty_workspace
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
MAX_DESKTOPS=20
|
||||||
|
|
||||||
|
WORKSPACES=$(seq -s '\n' 1 1 ${MAX_DESKTOPS})
|
||||||
|
|
||||||
|
EMPTY_WORKSPACE=$( (i3-msg -t get_workspaces | tr ',' '\n' | grep num | awk -F: '{print int($2)}' ; \
|
||||||
|
echo -e ${WORKSPACES} ) | sort -n | uniq -u | head -n 1)
|
||||||
|
|
||||||
|
i3-msg workspace ${EMPTY_WORKSPACE}
|
5
.config/i3/scripts/keyboard-layout
Executable file
5
.config/i3/scripts/keyboard-layout
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
KBD=$(/usr/bin/xkblayout-state print '%s')
|
||||||
|
echo $KBD
|
||||||
|
|
6
.config/i3/scripts/keyhint-2
Executable file
6
.config/i3/scripts/keyhint-2
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
I3_CONFIG=$HOME/.config/i3/config
|
||||||
|
mod_key=$(sed -nre 's/^set \$mod (.*)/\1/p' ${I3_CONFIG})
|
||||||
|
grep "^bindsym" ${I3_CONFIG} \
|
||||||
|
| sed "s/-\(-\w\+\)\+//g;s/\$mod/${mod_key}/g;s/Mod1/Alt/g;s/exec //;s/bindsym //;s/^\s\+//;s/^\([^ ]\+\) \(.\+\)$/\2: \1/;s/^\s\+//" \
|
||||||
|
| tr -s ' ' \
|
||||||
|
| rofi -dmenu -theme ~/.config/rofi/rofikeyhint.rasi
|
93
.config/i3/scripts/openweather
Executable file
93
.config/i3/scripts/openweather
Executable file
@ -0,0 +1,93 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Edited by Andreas Lindlbauer <endeavouros.mousily@aleeas.com>
|
||||||
|
|
||||||
|
temps=("#0600FF" "#0500FF" "#0400FF" "#0300FF" "#0200FF" "#0100FF" "#0000FF" "#0002FF" "#0012FF" "#0022FF" "#0032FF" "#0044FF" "#0054FF" "#0064FF" "#0074FF" "#0084FF" "#0094FF" "#00A4FF" "#00B4FF" "#00C4FF" "#00D4FF" "#00E4FF" "#00FFF4" "#00FFD0" "#00FFA8" "#00FF83" "#00FF5C" "#00FF36" "#00FF10" "#17FF00" "#3EFF00" "#65FF00" "#B0FF00" "#FDFF00" "#FFF000" "#FFDC00" "#FFC800" "#FFB400" "#FFA000" "#FF8C00" "#FF7800" "#FF6400" "#FF5000" "#FF3C00" "#FF2800" "#FF1400" "#FF0000")
|
||||||
|
|
||||||
|
command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed.
|
||||||
|
Aborting."; exit 1; }
|
||||||
|
command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed.
|
||||||
|
Aborting."; exit 1; }
|
||||||
|
|
||||||
|
# To use this script you need to create an API key here https://home.openweathermap.org
|
||||||
|
# You need to put your Open Weather APIKEY here:
|
||||||
|
APIKEY="0b4c4fbf6f9bbb8403a997c4cc861237"
|
||||||
|
# And get your Latitute and Longitudes to put in here:
|
||||||
|
LAT="XX.XXXX"
|
||||||
|
LON="XX.XXXX"
|
||||||
|
URL="http://api.openweathermap.org/data/2.5/onecall?lat=${LAT}&lon=${LON}&units=metric&exclude=minutely,hourly,daily&APPID=${APIKEY}"
|
||||||
|
WEATHER_RESPONSE=$(wget -qO- "${URL}")
|
||||||
|
|
||||||
|
WEATHER_CONDITION=$(echo "$WEATHER_RESPONSE" | jq '.current.weather[0].main' | sed 's/"//g')
|
||||||
|
WEATHER_TEMP=$(echo "$WEATHER_RESPONSE" | jq '.current.feels_like')
|
||||||
|
WEATHER_INT=${WEATHER_TEMP%.*}
|
||||||
|
|
||||||
|
TIME_NOW=$( echo "$WEATHER_RESPONSE" | jq '.current.dt')
|
||||||
|
SUNRISE=$( echo "$WEATHER_RESPONSE" | jq '.current.sunrise')
|
||||||
|
SUNSET=$( echo "$WEATHER_RESPONSE" | jq '.current.sunset')
|
||||||
|
DESCRIPTION=$( echo "$WEATHER_RESPONSE" | jq '.current.weather[0].description' | sed 's/"//g')
|
||||||
|
WEATHER_ALERT=$( echo "$WEATHER_RESPONSE" | jq '.alerts[0].event' | sed 's/"//g')
|
||||||
|
DAYTIME="n"
|
||||||
|
|
||||||
|
if [[ "$TIME_NOW" > "$SUNRISE" ]] && [[ "$TIME_NOW" < "$SUNSET" ]]; then
|
||||||
|
DAYTIME="d"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $WEATHER_CONDITION in
|
||||||
|
'Clouds')
|
||||||
|
if [ "$DAYTIME" == "d" ]; then
|
||||||
|
WEATHER_ICON=""
|
||||||
|
else
|
||||||
|
WEATHER_ICON=""
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
'Rain')
|
||||||
|
WEATHER_ICON=""
|
||||||
|
;;
|
||||||
|
'Drizzle')
|
||||||
|
if [ "$DAYTIME" == "d" ]; then
|
||||||
|
WEATHER_ICON=""
|
||||||
|
else
|
||||||
|
WEATHER_ICON=""
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
'Thunderstorm')
|
||||||
|
WEATHER_ICON=""
|
||||||
|
;;
|
||||||
|
'Snow')
|
||||||
|
WEATHER_ICON=""
|
||||||
|
;;
|
||||||
|
'Clear')
|
||||||
|
if [ "$DAYTIME" == "d" ]; then
|
||||||
|
WEATHER_ICON=""
|
||||||
|
else
|
||||||
|
WEATHER_ICON=""
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
WEATHER_ICON="🌫"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
WEATHER_COLOR="#FFFFFF"
|
||||||
|
if [ "$WEATHER_INT" -lt "-11" ]; then
|
||||||
|
WEATHER_COLOR="#0000FF"
|
||||||
|
elif [ "$WEATHER_INT" -gt 35 ]; then
|
||||||
|
WEATHER_COLOR="#FF0000"
|
||||||
|
else
|
||||||
|
WEATHER_INT=$(( WEATHER_INT + 11 ))
|
||||||
|
WEATHER_COLOR="${temps[$WEATHER_INT]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
full_text="${WEATHER_ICON} ${WEATHER_TEMP}°C: ${DESCRIPTION} "
|
||||||
|
if [ "$WEATHER_ALERT" != "null" ]; then
|
||||||
|
WARN_START=$(echo "$WEATHER_RESPONSE" | jq '.alerts[0].start')
|
||||||
|
WARN_END=$(echo "$WEATHER_RESPONSE" | jq '.alerts[0].end')
|
||||||
|
WARN_START=$(date -d @"$WARN_START" +%a_%k:%M)
|
||||||
|
WARN_END=$(date -d @"$WARN_END" +%a_%k:%M)
|
||||||
|
full_text="${WEATHER_ICON} ${WEATHER_TEMP}°C: ${DESCRIPTION} ${WEATHER_ALERT} from ${WARN_START} to ${WARN_END} "
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo "${full_text}"
|
||||||
|
echo "${WEATHER_TEMP}°C "
|
||||||
|
echo "${WEATHER_COLOR}"
|
5
.config/i3/scripts/openweather.conf
Executable file
5
.config/i3/scripts/openweather.conf
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
# Weather
|
||||||
|
[Weather]
|
||||||
|
command=~/.config/i3/scripts/openweather
|
||||||
|
interval=1800
|
||||||
|
color=#7275b3
|
7
.config/i3/scripts/picom-toggle.sh
Executable file
7
.config/i3/scripts/picom-toggle.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
if pgrep -x "picom" > /dev/null
|
||||||
|
then
|
||||||
|
killall picom
|
||||||
|
else
|
||||||
|
picom -b --config ~/.config/i3/picom.conf
|
||||||
|
fi
|
204
.config/i3/scripts/power-profiles
Executable file
204
.config/i3/scripts/power-profiles
Executable file
@ -0,0 +1,204 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Use rofi/zenity to change system runstate thanks to systemd.
|
||||||
|
#
|
||||||
|
# Note: this currently relies on associative array support in the shell.
|
||||||
|
#
|
||||||
|
# Inspired from i3pystatus wiki:
|
||||||
|
# https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu
|
||||||
|
#
|
||||||
|
# Copyright 2015 Benjamin Chrétien <chretien at lirmm dot fr>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# power-profiles-daemon implementation:
|
||||||
|
# needs package power-profiles-daemon installed and the service running see here:
|
||||||
|
# https://wiki.archlinux.org/title/CPU_frequency_scaling#power-profiles-daemon
|
||||||
|
# used in i3-blocks: ~/.config/i3/i3blocks.conf together with: ~/.config/i3/scripts/ppd-status
|
||||||
|
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# BEGIN CONFIG #
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
# Use a custom lock script
|
||||||
|
#LOCKSCRIPT="i3lock-extra -m pixelize"
|
||||||
|
|
||||||
|
# Colors: FG (foreground), BG (background), HL (highlighted)
|
||||||
|
FG_COLOR="#bbbbbb"
|
||||||
|
BG_COLOR="#111111"
|
||||||
|
HLFG_COLOR="#111111"
|
||||||
|
HLBG_COLOR="#bbbbbb"
|
||||||
|
BORDER_COLOR="#222222"
|
||||||
|
|
||||||
|
# Options not related to colors
|
||||||
|
#ROFI_TEXT=":"
|
||||||
|
#ROFI_OPTIONS=(-width -11 -location 0 -hide-scrollbar -bw 30 -color-window "#dd310027,#dd0310027,#dd310027" -padding 5)
|
||||||
|
#ROFI_OPTIONS=(-width -18 -location 4 -hide-scrollbar -color-window "#cc310027,#00a0009a,#cc310027" -padding 5 -font "Sourcecode Pro Regular 10, FontAwesome 9")
|
||||||
|
ROFI_OPTIONS=(-theme ~/.config/rofi/power-profiles.rasi)
|
||||||
|
# Zenity options
|
||||||
|
ZENITY_TITLE="Power Profiles"
|
||||||
|
ZENITY_TEXT="Set Profiles:"
|
||||||
|
ZENITY_OPTIONS=(--column= --hide-header)
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# END CONFIG #
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
# Whether to ask for user's confirmation
|
||||||
|
enable_confirmation=false
|
||||||
|
|
||||||
|
# Preferred launcher if both are available
|
||||||
|
preferred_launcher="rofi"
|
||||||
|
|
||||||
|
usage="$(basename "$0") [-h] [-c] [-p name] -- display a menu for shutdown, reboot, lock etc.
|
||||||
|
|
||||||
|
where:
|
||||||
|
-h show this help text
|
||||||
|
-c ask for user confirmation
|
||||||
|
-p preferred launcher (rofi or zenity)
|
||||||
|
|
||||||
|
This script depends on:
|
||||||
|
- systemd,
|
||||||
|
- i3,
|
||||||
|
- rofi or zenity."
|
||||||
|
|
||||||
|
# Check whether the user-defined launcher is valid
|
||||||
|
launcher_list=(rofi zenity)
|
||||||
|
function check_launcher() {
|
||||||
|
if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then
|
||||||
|
echo "Supported launchers: ${launcher_list[*]}"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
# Get array with unique elements and preferred launcher first
|
||||||
|
# Note: uniq expects a sorted list, so we cannot use it
|
||||||
|
i=1
|
||||||
|
launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \
|
||||||
|
| sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' '))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse CLI arguments
|
||||||
|
while getopts "hcp:" option; do
|
||||||
|
case "${option}" in
|
||||||
|
h) echo "${usage}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
c) enable_confirmation=true
|
||||||
|
;;
|
||||||
|
p) preferred_launcher="${OPTARG}"
|
||||||
|
check_launcher "${preferred_launcher}"
|
||||||
|
;;
|
||||||
|
*) exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check whether a command exists
|
||||||
|
function command_exists() {
|
||||||
|
command -v "$1" &> /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# systemctl required
|
||||||
|
if ! command_exists systemctl ; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# default_menu_options defined as an associative array
|
||||||
|
typeset -A default_menu_options
|
||||||
|
|
||||||
|
# The default options with keys/commands
|
||||||
|
|
||||||
|
default_menu_options=(
|
||||||
|
[ Performance]="powerprofilesctl set performance"
|
||||||
|
[ Balanced]="powerprofilesctl set balanced"
|
||||||
|
[ Power Saver]="powerprofilesctl set power-saver"
|
||||||
|
[ Cancel]=""
|
||||||
|
)
|
||||||
|
|
||||||
|
# The menu that will be displayed
|
||||||
|
typeset -A menu
|
||||||
|
menu=()
|
||||||
|
|
||||||
|
# Only add power profiles that are available to menu
|
||||||
|
for key in "${!default_menu_options[@]}"; do
|
||||||
|
grep_arg=${default_menu_options[${key}]##* }
|
||||||
|
if powerprofilesctl list | grep -q "$grep_arg"; then
|
||||||
|
menu[${key}]=${default_menu_options[${key}]}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
unset grep_arg
|
||||||
|
unset default_menu_options
|
||||||
|
|
||||||
|
menu_nrows=${#menu[@]}
|
||||||
|
|
||||||
|
# Menu entries that may trigger a confirmation message
|
||||||
|
menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout"
|
||||||
|
|
||||||
|
launcher_exe=""
|
||||||
|
launcher_options=""
|
||||||
|
rofi_colors=""
|
||||||
|
|
||||||
|
function prepare_launcher() {
|
||||||
|
if [[ "$1" == "rofi" ]]; then
|
||||||
|
rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \
|
||||||
|
-hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}")
|
||||||
|
launcher_exe="rofi"
|
||||||
|
launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \
|
||||||
|
"${rofi_colors}" "${ROFI_OPTIONS[@]}")
|
||||||
|
elif [[ "$1" == "zenity" ]]; then
|
||||||
|
launcher_exe="zenity"
|
||||||
|
launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \
|
||||||
|
"${ZENITY_OPTIONS[@]}")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
for l in "${launcher_list[@]}"; do
|
||||||
|
if command_exists "${l}" ; then
|
||||||
|
prepare_launcher "${l}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# No launcher available
|
||||||
|
if [[ -z "${launcher_exe}" ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
launcher=(${launcher_exe} "${launcher_options[@]}")
|
||||||
|
selection="$(printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}")"
|
||||||
|
|
||||||
|
function ask_confirmation() {
|
||||||
|
if [ "${launcher_exe}" == "rofi" ]; then
|
||||||
|
confirmed=$(echo -e "Yes\nNo" | rofi -dmenu -i -lines 2 -p "${selection}?" \
|
||||||
|
"${rofi_colors}" "${ROFI_OPTIONS[@]}")
|
||||||
|
[ "${confirmed}" == "Yes" ] && confirmed=0
|
||||||
|
elif [ "${launcher_exe}" == "zenity" ]; then
|
||||||
|
zenity --question --text "Are you sure you want to ${selection,,}?"
|
||||||
|
confirmed=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${confirmed}" == 0 ]; then
|
||||||
|
i3-msg -q "exec --no-startup-id ${menu[${selection}]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $? -eq 0 && ! -z ${selection} ]]; then
|
||||||
|
if [[ "${enable_confirmation}" = true && \
|
||||||
|
${menu_confirm} =~ (^|[[:space:]])"${selection}"($|[[:space:]]) ]]; then
|
||||||
|
ask_confirmation
|
||||||
|
else
|
||||||
|
i3-msg -q "exec --no-startup-id ${menu[${selection}]}"
|
||||||
|
fi
|
||||||
|
fi
|
86
.config/i3/scripts/temperature
Executable file
86
.config/i3/scripts/temperature
Executable file
@ -0,0 +1,86 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2014 Pierre Mavro <deimos@deimos.fr>
|
||||||
|
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
|
||||||
|
# Copyright 2014 Andreas Guldstrand <andreas.guldstrand@gmail.com>
|
||||||
|
# Copyright 2014 Benjamin Chretien <chretien at lirmm dot fr>
|
||||||
|
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Edited by Andreas Lindlbauer <endeavouros.mousily@aleeas.com>
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use utf8;
|
||||||
|
use Getopt::Long;
|
||||||
|
|
||||||
|
binmode(STDOUT, ":utf8");
|
||||||
|
|
||||||
|
# default values
|
||||||
|
my $t_warn = $ENV{T_WARN} || 70;
|
||||||
|
my $t_crit = $ENV{T_CRIT} || 90;
|
||||||
|
my $chip = $ENV{SENSOR_CHIP} || "";
|
||||||
|
my $temperature = -9999;
|
||||||
|
my $label = "😀 ";
|
||||||
|
|
||||||
|
sub help {
|
||||||
|
print "Usage: temperature [-w <warning>] [-c <critical>] [--chip <chip>]\n";
|
||||||
|
print "-w <percent>: warning threshold to become yellow\n";
|
||||||
|
print "-c <percent>: critical threshold to become red\n";
|
||||||
|
print "--chip <chip>: sensor chip\n";
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetOptions("help|h" => \&help,
|
||||||
|
"w=i" => \$t_warn,
|
||||||
|
"c=i" => \$t_crit,
|
||||||
|
"chip=s" => \$chip);
|
||||||
|
|
||||||
|
# Get chip temperature
|
||||||
|
open (SENSORS, "sensors -u $chip |") or die;
|
||||||
|
while (<SENSORS>) {
|
||||||
|
if (/^\s+temp1_input:\s+[\+]*([\-]*\d+\.\d)/) {
|
||||||
|
$temperature = $1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(SENSORS);
|
||||||
|
|
||||||
|
$temperature eq -9999 and die 'Cannot find temperature';
|
||||||
|
|
||||||
|
if ($temperature < 45) {
|
||||||
|
$label = '';
|
||||||
|
} elsif ($temperature < 55) {
|
||||||
|
$label = '';
|
||||||
|
} elsif ($temperature < 65) {
|
||||||
|
$label = '';
|
||||||
|
} elsif ($temperature < 75) {
|
||||||
|
$label = '';
|
||||||
|
} else {
|
||||||
|
$label = '';
|
||||||
|
}
|
||||||
|
# Print short_text, full_text
|
||||||
|
print "${label}";
|
||||||
|
print " $temperature°C\n";
|
||||||
|
print "${label}";
|
||||||
|
print " $temperature°C\n";
|
||||||
|
|
||||||
|
# Print color, if needed
|
||||||
|
if ($temperature >= $t_crit) {
|
||||||
|
print "#FF0000\n";
|
||||||
|
exit 33;
|
||||||
|
} elsif ($temperature >= $t_warn) {
|
||||||
|
print "#FFFC00\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0;
|
96
.config/i3/scripts/volume_brightness.sh
Executable file
96
.config/i3/scripts/volume_brightness.sh
Executable file
@ -0,0 +1,96 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# original source: https://gitlab.com/Nmoleo/i3-volume-brightness-indicator
|
||||||
|
|
||||||
|
# taken from here: https://gitlab.com/Nmoleo/i3-volume-brightness-indicator
|
||||||
|
|
||||||
|
# See README.md for usage instructions
|
||||||
|
bar_color="#7f7fff"
|
||||||
|
volume_step=1
|
||||||
|
brightness_step=2.5
|
||||||
|
max_volume=100
|
||||||
|
|
||||||
|
# Uses regex to get volume from pactl
|
||||||
|
function get_volume {
|
||||||
|
pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '[0-9]{1,3}(?=%)' | head -1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Uses regex to get mute status from pactl
|
||||||
|
function get_mute {
|
||||||
|
pactl get-sink-mute @DEFAULT_SINK@ | grep -Po '(?<=Mute: )(yes|no)'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Uses regex to get brightness from xbacklight
|
||||||
|
function get_brightness {
|
||||||
|
xbacklight | grep -Po '[0-9]{1,3}' | head -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Returns a mute icon, a volume-low icon, or a volume-high icon, depending on the volume
|
||||||
|
function get_volume_icon {
|
||||||
|
volume=$(get_volume)
|
||||||
|
mute=$(get_mute)
|
||||||
|
if [ "$volume" -eq 0 ] || [ "$mute" == "yes" ] ; then
|
||||||
|
volume_icon=""
|
||||||
|
elif [ "$volume" -lt 50 ]; then
|
||||||
|
volume_icon=""
|
||||||
|
else
|
||||||
|
volume_icon=""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Always returns the same icon - I couldn't get the brightness-low icon to work with fontawesome
|
||||||
|
function get_brightness_icon {
|
||||||
|
brightness_icon=""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Displays a volume notification using dunstify
|
||||||
|
function show_volume_notif {
|
||||||
|
volume=$(get_mute)
|
||||||
|
get_volume_icon
|
||||||
|
dunstify -i audio-volume-muted-blocking -t 1000 -r 2593 -u normal "$volume_icon $volume%" -h int:value:$volume -h string:hlcolor:$bar_color
|
||||||
|
}
|
||||||
|
|
||||||
|
# Displays a brightness notification using dunstify
|
||||||
|
function show_brightness_notif {
|
||||||
|
brightness=$(get_brightness)
|
||||||
|
get_brightness_icon
|
||||||
|
dunstify -t 1000 -r 2593 -u normal "$brightness_icon $brightness%" -h int:value:$brightness -h string:hlcolor:$bar_color
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main function - Takes user input, "volume_up", "volume_down", "brightness_up", or "brightness_down"
|
||||||
|
case $1 in
|
||||||
|
volume_up)
|
||||||
|
# Unmutes and increases volume, then displays the notification
|
||||||
|
pactl set-sink-mute @DEFAULT_SINK@ 0
|
||||||
|
volume=$(get_volume)
|
||||||
|
if [ $(( "$volume" + "$volume_step" )) -gt $max_volume ]; then
|
||||||
|
pactl set-sink-volume @DEFAULT_SINK@ $max_volume%
|
||||||
|
else
|
||||||
|
pactl set-sink-volume @DEFAULT_SINK@ +$volume_step%
|
||||||
|
fi
|
||||||
|
show_volume_notif
|
||||||
|
;;
|
||||||
|
|
||||||
|
volume_down)
|
||||||
|
# Raises volume and displays the notification
|
||||||
|
pactl set-sink-volume @DEFAULT_SINK@ -$volume_step%
|
||||||
|
show_volume_notif
|
||||||
|
;;
|
||||||
|
|
||||||
|
volume_mute)
|
||||||
|
# Toggles mute and displays the notification
|
||||||
|
pactl set-sink-mute @DEFAULT_SINK@ toggle
|
||||||
|
show_volume_notif
|
||||||
|
;;
|
||||||
|
|
||||||
|
brightness_up)
|
||||||
|
# Increases brightness and displays the notification
|
||||||
|
xbacklight -inc $brightness_step -time 0
|
||||||
|
show_brightness_notif
|
||||||
|
;;
|
||||||
|
|
||||||
|
brightness_down)
|
||||||
|
# Decreases brightness and displays the notification
|
||||||
|
xbacklight -dec $brightness_step -time 0
|
||||||
|
show_brightness_notif
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in New Issue
Block a user