Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
8af65c3607 | |||
f0129a370f | |||
723c7ae6c1 | |||
d2af9c3d5a | |||
df42bdaefd | |||
b27e71f228 | |||
80825915df | |||
dd44d1a7d2 | |||
594dd8f937 | |||
1cf0ee3c42 | |||
84c57d53ea | |||
7f40a5bbea | |||
58906ccfdb | |||
75c5ec6422 | |||
ddaa1c4222 | |||
6816ebc07f | |||
d1a8a9ba91 | |||
6753a9e68e | |||
8b1a3f4eab | |||
9abbff4c7e | |||
61bf1af1af | |||
db2287f15b | |||
491bfa2c49 | |||
9224505e4e | |||
ac567ebcaa |
11
README.md
Normal file
11
README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# My dotfiles
|
||||
Welcome!
|
||||
|
||||
## Dependencies
|
||||
All neccessary dependencies I could think of are listed in the *dependencies* file.
|
||||
|
||||
## Link configs
|
||||
```sh
|
||||
cd .dotfiles
|
||||
stow i3 mc emacs vim
|
||||
```
|
@ -21,7 +21,7 @@
|
||||
;; font string. You generally only need these two:
|
||||
;; (setq doom-font (font-spec :family "monospace" :size 13 :weight 'semi-light)
|
||||
;; doom-variable-pitch-font (font-spec :family "sans" :size 13))
|
||||
(setq doom-font (font-spec :family "Source Code Pro" :size 13))
|
||||
(setq doom-font (font-spec :family "Source Code Pro" :size 14))
|
||||
|
||||
;; There are two ways to load a theme. Both assume the theme is installed and
|
||||
;; available. You can either set `doom-theme' or manually load a theme with the
|
||||
@ -56,7 +56,7 @@
|
||||
|
||||
;; Open external terminal
|
||||
;; (map! :map doom-leader-open-map :desc "Open" "t" (cmd! (call-process-shell-command "terminal&" nil 0)))
|
||||
(map! :leader :desc "Open external terminal" "o t" (cmd! (call-process-shell-command "terminal&" nil 0)))
|
||||
(map! :leader :desc "Open external terminal" "o t" (cmd! (call-process-shell-command "xfce4-terminal&" nil 0)))
|
||||
|
||||
;; Remap font scaling keybindings to make more sense
|
||||
(map! :desc "Increase font size" :n "C-+" #'text-scale-increase)
|
||||
@ -118,10 +118,7 @@
|
||||
(after! org
|
||||
(setq org-agenda-files (expand-file-name "org-agenda-files" doom-private-dir)))
|
||||
|
||||
(map! :map cdlatex-mode-map
|
||||
:i "TAB" #'cdlatex-tab)
|
||||
|
||||
(map! :desc "Open external terminal" :nv "g C" #'toggle-word-case)
|
||||
(map! :desc "Toggle case of word" :nv "g C" #'toggle-word-case)
|
||||
|
||||
(defun toggle-word-case ()
|
||||
"Toggle the case of current word or text selection."
|
||||
|
@ -1,13 +0,0 @@
|
||||
(custom-set-variables
|
||||
;; custom-set-variables was added by Custom.
|
||||
;; If you edit it by hand, you could mess it up, so be careful.
|
||||
;; Your init file should contain only one such instance.
|
||||
;; If there is more than one, they won't work right.
|
||||
'(org-agenda-files '("~/org-tests.org"))
|
||||
'(package-selected-packages '(matlab-mode)))
|
||||
(custom-set-faces
|
||||
;; custom-set-faces was added by Custom.
|
||||
;; If you edit it by hand, you could mess it up, so be careful.
|
||||
;; Your init file should contain only one such instance.
|
||||
;; If there is more than one, they won't work right.
|
||||
)
|
@ -139,7 +139,7 @@
|
||||
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
|
||||
;; julia ; a better, faster MATLAB
|
||||
;;kotlin ; a better, slicker Java(Script)
|
||||
(latex +cdlatex) ; writing papers in Emacs has never been so fun
|
||||
latex ; writing papers in Emacs has never been so fun
|
||||
;;lean ; for folks with too much to prove
|
||||
;;ledger ; be audit you can be
|
||||
;;lua ; one-based indices? one-based indices
|
||||
|
@ -0,0 +1,3 @@
|
||||
~/nextcloud/studium/vorlesungen/SS21/raumfahrtbetrieb/rb-vorbereitung.org
|
||||
~/nextcloud/studium/vorlesungen/SS21/borddatenverarbeitung/bdv-fragenkatalog.org
|
||||
~/nextcloud/studium/vorlesungen/SS21/luftundraumfahrtlabor/lrl-fragenkatalog.org
|
@ -254,8 +254,8 @@
|
||||
# These values can be strung together for each mouse event, and
|
||||
# will be executed in sequence.
|
||||
mouse_left_click = do_action, close_current
|
||||
mouse_middle_click = do_action, close_current
|
||||
mouse_right_click = close_all
|
||||
mouse_middle_click = close_all
|
||||
mouse_right_click = close_current
|
||||
|
||||
# Experimental features that may or may not work correctly. Do not expect them
|
||||
# to have a consistent behaviour across releases.
|
||||
|
@ -10,6 +10,7 @@
|
||||
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
|
||||
|
||||
set $mod Mod4
|
||||
set $scripts ~/.config/i3/scripts
|
||||
|
||||
# Font for window titles. Will also be used by the bar unless a different font
|
||||
# is used in the bar {} block below.
|
||||
@ -31,11 +32,12 @@ exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork
|
||||
# exec --no-startup-id nm-applet
|
||||
|
||||
# Use pactl to adjust volume in PulseAudio.
|
||||
set $refresh_i3status killall -SIGUSR1 i3status
|
||||
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
|
||||
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
|
||||
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
|
||||
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
|
||||
# set $refresh_i3status killall -SIGUSR1 i3status
|
||||
set $refresh_i3blocks pkill -RTMIN+1 i3blocks
|
||||
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3blocks
|
||||
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3blocks
|
||||
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3blocks
|
||||
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3blocks
|
||||
|
||||
# Use Mouse+$mod to drag floating windows to their wanted position
|
||||
floating_modifier $mod
|
||||
@ -158,8 +160,8 @@ bindsym $mod+Shift+9 move container to workspace number $ws9; workspace $ws9
|
||||
bindsym $mod+Shift+0 move container to workspace number $ws10; workspace $ws10
|
||||
|
||||
# Monitor config
|
||||
set $monitor_left DVI-D-0
|
||||
set $monitor_right DVI-D-1
|
||||
set $monitor_left eDP1
|
||||
set $monitor_right HDMI1
|
||||
|
||||
workspace $ws1 output $monitor_left
|
||||
workspace $ws2 output $monitor_left
|
||||
@ -260,14 +262,18 @@ bindsym $mod+c exec xfce4-terminal --role floating --hide-scrollbar --title Calc
|
||||
bindsym $mod+p exec xwacomcalibrate
|
||||
bindsym $mod+t exec thunar
|
||||
bindsym $mod+m exec xfce4-terminal -x mc
|
||||
bindsym $mod+Shift+c exec jupyter-calculator
|
||||
bindsym $mod+Shift+c exec $scripts/jupyter-calculator
|
||||
bindsym $mod+b exec firefox
|
||||
bindsym $mod+s exec pavucontrol
|
||||
bindsym $mod+u exec pamac-manager
|
||||
|
||||
workspace_auto_back_and_forth yes
|
||||
|
||||
########## Window settings ##########
|
||||
default_border normal
|
||||
exec_always $scripts/setup-screens
|
||||
|
||||
########## Window settings ##########
|
||||
default_border pixel
|
||||
default_floating_border normal
|
||||
|
||||
assign [class="firefox" title="Mozilla Firefox$"] workspace $ws1
|
||||
@ -316,7 +322,7 @@ exec --no-startup-id msm_notifier
|
||||
exec --no-startup-id start-pulseaudio-x11
|
||||
# Background
|
||||
#exec --no-startup-id feh --randomize --bg-fill /home/julian/Pictures/Hintergrundbilder/*
|
||||
exec --no-startup-id feh --bg-fill /home/julian/Pictures/Hintergrundbilder/space.jpg
|
||||
exec --no-startup-id feh --bg-fill /home/julian/nextcloud/space.jpg
|
||||
# Notifications
|
||||
exec --no-startup-id dunst -config /home/julian/.config/dunst/dunstrc
|
||||
|
||||
|
9
i3/.config/i3/scripts/setup-screens
Executable file
9
i3/.config/i3/scripts/setup-screens
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
# Author: Julian Mutter
|
||||
# Date: 12.07.2021
|
||||
|
||||
if [[ $(xrandr | grep "HDMI1 connected") ]]; then
|
||||
~/.screenlayout/layout2screen.sh
|
||||
else
|
||||
~/.screenlayout/layout1screen.sh
|
||||
fi
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
zoom &
|
||||
flatpak run us.zoom.Zoom &
|
||||
|
||||
i3-msg "workspace --no-auto-back-and-forth 5; exec mousepad /home/julian/Nextcloud/studium/zoom.txt"
|
||||
i3-msg "workspace --no-auto-back-and-forth 5; append_layout ~/.config/i3/workspace-zoom.json"
|
||||
|
@ -1,22 +1,23 @@
|
||||
// vim:ts=4:sw=4:et
|
||||
{
|
||||
"border": "none",
|
||||
"border": "pixel",
|
||||
"current_border_width": 2,
|
||||
"floating": "auto_off",
|
||||
"geometry": {
|
||||
"height": 1026,
|
||||
"width": 560,
|
||||
"x": 1680,
|
||||
"y": 24
|
||||
"height": 1033,
|
||||
"width": 956,
|
||||
"x": 1366,
|
||||
"y": 45
|
||||
},
|
||||
"marks": [],
|
||||
"name": "Telegram",
|
||||
"name": "Element | Familie",
|
||||
"percent": 0.5,
|
||||
"swallows": [
|
||||
{
|
||||
"class": "^TelegramDesktop$",
|
||||
"instance": "^telegram\\-desktop$"
|
||||
// "title": "^Telegram\\ \\(18\\)$"
|
||||
"class": "^Element$",
|
||||
// "instance": "^element$",
|
||||
// "title": "^Element\\ \\|\\ Familie$",
|
||||
"window_role": "^browser\\-window$"
|
||||
}
|
||||
],
|
||||
"type": "con"
|
||||
@ -24,7 +25,7 @@
|
||||
|
||||
{
|
||||
// splitv split container with 2 children
|
||||
"border": "normal",
|
||||
"border": "pixel",
|
||||
"floating": "auto_off",
|
||||
"layout": "splitv",
|
||||
"marks": [],
|
||||
@ -33,7 +34,7 @@
|
||||
"nodes": [
|
||||
{
|
||||
// splith split container with 1 children
|
||||
"border": "normal",
|
||||
"border": "pixel",
|
||||
"floating": "auto_off",
|
||||
"layout": "splith",
|
||||
"marks": [],
|
||||
@ -41,60 +42,48 @@
|
||||
"type": "con",
|
||||
"nodes": [
|
||||
{
|
||||
// splith split container with 1 children
|
||||
"border": "normal",
|
||||
"border": "pixel",
|
||||
"current_border_width": 2,
|
||||
"floating": "auto_off",
|
||||
"layout": "splith",
|
||||
"geometry": {
|
||||
"height": 524,
|
||||
"width": 1916,
|
||||
"x": 1368,
|
||||
"y": 25
|
||||
},
|
||||
"marks": [],
|
||||
"name": "Telegram",
|
||||
"percent": 1,
|
||||
"type": "con",
|
||||
"nodes": [
|
||||
{
|
||||
"border": "normal",
|
||||
"current_border_width": 2,
|
||||
"floating": "auto_off",
|
||||
"geometry": {
|
||||
"height": 1002,
|
||||
"width": 800,
|
||||
"x": 2242,
|
||||
"y": 46
|
||||
},
|
||||
"marks": [],
|
||||
"name": "Element",
|
||||
"percent": 1,
|
||||
"swallows": [
|
||||
{
|
||||
"class": "^Element$",
|
||||
"instance": "^element$"
|
||||
// "title": "^Element\\ \\|\\ Skipper$",
|
||||
// "window_role": "^browser\\-window$"
|
||||
}
|
||||
],
|
||||
"type": "con"
|
||||
}
|
||||
]
|
||||
"swallows": [
|
||||
{
|
||||
"class": "^TelegramDesktop$",
|
||||
// "instance": "^telegram\\-desktop$",
|
||||
"title": "^Telegram$"
|
||||
}
|
||||
],
|
||||
"type": "con"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"border": "normal",
|
||||
"border": "pixel",
|
||||
"current_border_width": 2,
|
||||
"floating": "auto_off",
|
||||
"geometry": {
|
||||
"height": 715,
|
||||
"width": 1366,
|
||||
"x": 183,
|
||||
"y": 396
|
||||
"height": 1033,
|
||||
"width": 1916,
|
||||
"x": 1368,
|
||||
"y": 45
|
||||
},
|
||||
"marks": [],
|
||||
"name": "Rocket Chat",
|
||||
"name": "Chat der Uni Würzburg",
|
||||
"percent": 0.5,
|
||||
"swallows": [
|
||||
{
|
||||
"class": "^Rocket\\.Chat$",
|
||||
"instance": "^rocket\\.chat$"
|
||||
"class": "^Rocket\\.Chat$",
|
||||
// "instance": "^rocket\\.chat$",
|
||||
// "title": "^Chat\\ der\\ Uni\\ Würzburg$",
|
||||
// "window_role": "^browser\\-window$"
|
||||
"window_role": "^browser\\-window$"
|
||||
}
|
||||
],
|
||||
"type": "con"
|
||||
|
98
i3/.config/i3blocks/battery
Executable file
98
i3/.config/i3blocks/battery
Executable file
@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2016 James Murphy
|
||||
# Licensed under the GPL version 2 only
|
||||
#
|
||||
# A battery indicator blocklet script for i3blocks
|
||||
|
||||
import re
|
||||
from subprocess import check_output
|
||||
|
||||
status = check_output(['acpi'], universal_newlines=True)
|
||||
|
||||
if not status:
|
||||
# stands for no battery found
|
||||
fulltext = "<span color='red'><span font='FontAwesome'>\uf00d \uf240</span></span>"
|
||||
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)
|
||||
|
||||
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
|
||||
FA_LIGHTNING = "<span color='yellow'><span font='FontAwesome'>\uf0e7</span></span>"
|
||||
|
||||
# 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 "#FFFFFF"
|
||||
if percent < 20:
|
||||
return "#FF3300"
|
||||
if percent < 30:
|
||||
return "#FF6600"
|
||||
if percent < 50:
|
||||
return "#FFCC00"
|
||||
if percent < 60:
|
||||
return "#FFFF00"
|
||||
if percent < 70:
|
||||
return "#FFFF33"
|
||||
if percent < 80:
|
||||
return "#FFFF66"
|
||||
return "#FFFFFF"
|
||||
|
||||
form = '<span color="{}">{}%</span>'
|
||||
fulltext += form.format(color(percentleft), percentleft)
|
||||
fulltext += timeleft
|
||||
|
||||
print(fulltext)
|
||||
print(fulltext)
|
||||
if percentleft < 10:
|
||||
exit(33)
|
@ -1,793 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# battery-plus
|
||||
#
|
||||
# An enhanced battery status indicator for i3blocks.
|
||||
#
|
||||
# Requires:
|
||||
# awk (POSIX compatible)
|
||||
# bc
|
||||
# upower
|
||||
#
|
||||
# Recommended:
|
||||
# fonts-font-awesome or fonts-hack
|
||||
#
|
||||
# Optional:
|
||||
# notify-send or dunstify -- for notifications
|
||||
# zenity -- for dialogs
|
||||
#
|
||||
# Copyright (c) 2018 Beau Hastings. All rights reserved.
|
||||
# License: GNU General Public License v2
|
||||
#
|
||||
# Author: Beau Hastings <beau@saweet.net>
|
||||
# URL: https://github.com/hastinbe/i3blocks-battery-plus
|
||||
|
||||
_PERCENT="%"
|
||||
|
||||
# Hide the battery status if fully-charged,
|
||||
_HIDE_IF_CHARGED=${_HIDE_IF_CHARGED:-false}
|
||||
|
||||
# Color the battery symbol using gradient.
|
||||
_USE_BATT_GRADIENT=${_USE_BATT_GRADIENT:-false}
|
||||
|
||||
# Only show symbols.
|
||||
_SYMBOLS_ONLY=${_SYMBOLS_ONLY:-false}
|
||||
|
||||
# Hide the battery percentage
|
||||
_HIDE_PERCENTAGE=${_HIDE_PERCENTAGE:-false}
|
||||
|
||||
# Hide the battery time remaining
|
||||
_HIDE_TIME_REMAINING=${_HIDE_TIME_REMAINING:-true}
|
||||
|
||||
# Hide the time to charge the battery to full
|
||||
_HIDE_TIME_TO_FULL=${_HIDE_TIME_TO_FULL:-true}
|
||||
|
||||
# Show the direction of change for the battery's percentage
|
||||
_SHOW_CHARGE_DIRECTION=${_SHOW_CHARGE_DIRECTION:-true}
|
||||
|
||||
# Show an alert symbol when the battery capacity drops to the given percent (0=disable).
|
||||
_CAPACITY_ALERT=${_CAPACITY_ALERT:-75}
|
||||
|
||||
# Action to take when the battery level reaches critical.
|
||||
_CRITICAL_ACTION=${_CRITICAL_ACTION:-"notify"}
|
||||
|
||||
# Action to take when the battery level reaches low.
|
||||
_LOW_ACTION=${_LOW_ACTION:-"notify"}
|
||||
|
||||
# Method to use for notifications
|
||||
_NOTIFY_PROGRAM=${_NOTIFY_PROGRAM:-"notify-send"}
|
||||
|
||||
# The duration, in milliseconds, for the notification to appear on screen.
|
||||
_NOTIFY_EXPIRES="1500"
|
||||
|
||||
# Minimum time in seconds between notifications to prevent spam.
|
||||
_NOTIFY_THROTTLE=${_NOTIFY_THROTTLE:-120}
|
||||
|
||||
# Colors
|
||||
_COLOR_FULLY_CHARGED=${_COLOR_FULLY_CHARGED:-""}
|
||||
_COLOR_CHARGING=${_COLOR_CHARGING:-"yellow"}
|
||||
_COLOR_DISCHARGING=${_COLOR_CHARGING:-"yellow"}
|
||||
_COLOR_PENDING=${_COLOR_PENDING:-"blue"}
|
||||
_COLOR_ERROR=${_COLOR_ERROR:-"red"}
|
||||
_COLOR_BATTERY=${_COLOR_BATTERY:-"white"}
|
||||
_COLOR_ALERT=${_COLOR_ALERT:-"orange"}
|
||||
_COLOR_DIRECTIONAL_UP=${_COLOR_DIRECTIONAL_UP:-"green"}
|
||||
_COLOR_DIRECTIONAL_DOWN=${_COLOR_DIRECTIONAL_DOWN:-"red"}
|
||||
_COLOR_GRADIENT_START=${_COLOR_GRADIENT_START:-"#FF0000"}
|
||||
_COLOR_GRADIENT_END=${_COLOR_GRADIENT_END:-"#00FF00"}
|
||||
|
||||
# Symbols
|
||||
_SYMBOL_FULLY_CHARGED=${_SYMBOL_FULLY_CHARGED:-""}
|
||||
_SYMBOL_CHARGING=${_SYMBOL_CHARGING:-""}
|
||||
_SYMBOL_DISCHARGING=${_SYMBOL_DISCHARGING:-""}
|
||||
_SYMBOL_UNKNOWN=${_SYMBOL_UNKNOWN:-""}
|
||||
_SYMBOL_PENDING=${_SYMBOL_PENDING:-""}
|
||||
_SYMBOL_ERROR=${_SYMBOL_ERROR:-""}
|
||||
_SYMBOL_ALERT=${_SYMBOL_ALERT:-""}
|
||||
_SYMBOL_BATT_100=${_SYMBOL_BATT_100:-""}
|
||||
_SYMBOL_BATT_75=${_SYMBOL_BATT_75:-""}
|
||||
_SYMBOL_BATT_50=${_SYMBOL_BATT_50:-""}
|
||||
_SYMBOL_BATT_25=${_SYMBOL_BATT_25:-""}
|
||||
_SYMBOL_BATT_0=${_SYMBOL_BATT_0:-""}
|
||||
_SYMBOL_DIRECTION_UP=${_SYMBOL_DIRECTION_UP:-"↑"}
|
||||
_SYMBOL_DIRECTION_DOWN=${_SYMBOL_DIRECTION_DOWN:-"↓"}
|
||||
|
||||
# Get a the system's temporary files directory.
|
||||
#
|
||||
# Notes:
|
||||
# Executes a dry-run so we don't create a file.
|
||||
# Linux doesn't require the template option, but MacOSX does.
|
||||
#
|
||||
# Returns:
|
||||
# The path to the temporary directory.
|
||||
get_temp_dir() {
|
||||
echo $(dirname $(mktemp -ut "battery-plus.XXX"))
|
||||
}
|
||||
|
||||
# Output text wrapped in a span element
|
||||
#
|
||||
# Options:
|
||||
# -c <color> To specify a text color
|
||||
#
|
||||
# Arguments:
|
||||
# $1 or $3 - String to encapsulate within a span
|
||||
span() {
|
||||
local -A attribs
|
||||
local text="$*"
|
||||
|
||||
if [ -n "$FONT" ]; then attribs[font]="$FONT"; fi
|
||||
|
||||
if [ "$1" = "-c" ]; then
|
||||
attribs[color]="$2"
|
||||
text="${*:3}"
|
||||
fi
|
||||
|
||||
echo "<span$(build_attribs attribs)>$text</span>"
|
||||
}
|
||||
|
||||
# Builds html element attributes
|
||||
#
|
||||
# Arguments:
|
||||
# $1 - An associative array of attribute-value pairs
|
||||
build_attribs() {
|
||||
local -n array=$1
|
||||
for k in "${!array[@]}"; do
|
||||
echo -n " $k='${array[$k]}'"
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
# Interpolate between 2 RGB colors
|
||||
#
|
||||
# Arguments:
|
||||
# $1 - Color to interpolate from, as a hex triplet prefixed with #
|
||||
# $2 - Color to interpolate to, as a hex triplet prefixed with #
|
||||
# $3 - Amount of steps needed to get from start to end color
|
||||
interpolate_rgb() {
|
||||
local -i steps=$3
|
||||
local -a colors
|
||||
local color1=$1
|
||||
local color2=$2
|
||||
local reversed=false
|
||||
|
||||
if (( 0x${color1:1:5} > 0x${color2:1:5} )); then
|
||||
color1=$2
|
||||
color2=$1
|
||||
reversed=true
|
||||
fi
|
||||
|
||||
printf -v startR "%d" 0x${color1:1:2}
|
||||
printf -v startG "%d" 0x${color1:3:2}
|
||||
printf -v startB "%d" 0x${color1:5:2}
|
||||
printf -v endR "%d" 0x${color2:1:2}
|
||||
printf -v endG "%d" 0x${color2:3:2}
|
||||
printf -v endB "%d" 0x${color2:5:2}
|
||||
|
||||
stepR=$(( ($endR - $startR) / $steps ))
|
||||
stepG=$(( ($endG - $startG) / $steps ))
|
||||
stepB=$(( ($endB - $startB) / $steps ))
|
||||
|
||||
for i in $(seq 0 $steps); do
|
||||
local -i R=$(( $startR + ($stepR * $i) ))
|
||||
local -i G=$(( $startG + ($stepG * $i) ))
|
||||
local -i B=$(( $startB + ($stepB * $i) ))
|
||||
|
||||
colors+=( "$(printf "#%02x%02x%02x\n" $R $G $B)" )
|
||||
done
|
||||
colors+=( "$(printf "#%02x%02x%02x\n" $endR $endG $endB)" )
|
||||
|
||||
if $reversed; then
|
||||
reverse colors colors_reversed
|
||||
echo "${colors_reversed[@]}"
|
||||
else
|
||||
echo "${colors[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Reverse an array
|
||||
#
|
||||
# Arguments:
|
||||
# $1 - Array to reverse
|
||||
# $2 - Destination array
|
||||
reverse() {
|
||||
local -n arr="$1" rev="$2"
|
||||
for i in "${arr[@]}"
|
||||
do
|
||||
rev=("$i" "${rev[@]}")
|
||||
done
|
||||
}
|
||||
|
||||
min() {
|
||||
echo "if ($1 < $2) $1 else $2" | bc
|
||||
}
|
||||
|
||||
max() {
|
||||
echo "if ($1 > $2) $1 else $2" | bc
|
||||
}
|
||||
|
||||
clamp() {
|
||||
echo $(min $(max $1 $2) $3)
|
||||
}
|
||||
|
||||
# Retrieve an item from the provided lookup table based on the percentage of a number
|
||||
#
|
||||
# Arguments:
|
||||
# $1 - A number
|
||||
# $2 - Number to get a percentage of
|
||||
# $3 - An array of potential values
|
||||
plookup() {
|
||||
if [ -z "$2" -o -z "$3" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local table=( ${@:3} )
|
||||
local number2=${2%.*}
|
||||
local number1=$(min ${1%.*} $number2)
|
||||
local percent_max=$(( $number1 * $number2 / 100 ))
|
||||
local index=$(( $percent_max * ${#table[@]} / 100 ))
|
||||
|
||||
index=$(clamp $index 0 $(( ${#table[@]} - 1 )) )
|
||||
|
||||
echo ${table[$index]}
|
||||
}
|
||||
|
||||
# Get battery status.
|
||||
#
|
||||
# Returns:
|
||||
# The battery's status or state.
|
||||
get_battery_status() {
|
||||
echo "$__UPOWER_INFO" | awk -W posix '$1 == "state:" {print $2}'
|
||||
}
|
||||
|
||||
# Get battery warning level.
|
||||
#
|
||||
# Returns:
|
||||
# The battery's warning level.
|
||||
get_battery_warning_level() {
|
||||
echo "$__UPOWER_INFO" | awk -W posix '$1 == "warning-level:" {print $2}'
|
||||
}
|
||||
|
||||
# Get battery percentage.
|
||||
#
|
||||
# Returns:
|
||||
# The battery's percentage, without the %.
|
||||
get_battery_percent() {
|
||||
echo "$__UPOWER_INFO" | awk -W posix '$1 == "percentage:" { gsub("%","",$2); print $2}'
|
||||
}
|
||||
|
||||
# Get battery capacity.
|
||||
#
|
||||
# Returns:
|
||||
# The battery's capcity, without the %.
|
||||
get_battery_capacity() {
|
||||
echo "$__UPOWER_INFO" | awk -W posix '$1 == "capacity:" { gsub("%","",$2); print $2}'
|
||||
}
|
||||
|
||||
# Get battery time left.
|
||||
#
|
||||
# Returns:
|
||||
# The battery's time left.
|
||||
get_time_to_empty() {
|
||||
echo "$__UPOWER_INFO" | awk -W posix -F':' '/time to empty:/{print $2}' | xargs
|
||||
}
|
||||
|
||||
# Get the time remaining until the battery is fully charged.
|
||||
#
|
||||
# Returns:
|
||||
# The time remaining until battery is fully charged.
|
||||
get_time_to_full() {
|
||||
echo "$__UPOWER_INFO" | awk -W posix -F':' '/time to full:/{print $2}' | xargs
|
||||
}
|
||||
|
||||
# Get symbol for the given battery percentage.
|
||||
#
|
||||
# Arguments:
|
||||
# $percent (int) Battery percentage.
|
||||
#
|
||||
# Returns:
|
||||
# The battery symbol.
|
||||
get_battery_charge_symbol() {
|
||||
local percent="$1"
|
||||
local symbol
|
||||
|
||||
if [ "$battery_percentage" -ge 90 ]; then symbol="$_SYMBOL_BATT_100"
|
||||
elif [ "$battery_percentage" -ge 70 ]; then symbol="$_SYMBOL_BATT_75"
|
||||
elif [ "$battery_percentage" -ge 40 ]; then symbol="$_SYMBOL_BATT_50"
|
||||
elif [ "$battery_percentage" -ge 20 ]; then symbol="$_SYMBOL_BATT_25"
|
||||
else symbol="$_SYMBOL_BATT_0"
|
||||
fi
|
||||
|
||||
echo "$symbol"
|
||||
}
|
||||
|
||||
# Get battery status symbol.
|
||||
#
|
||||
# Returns:
|
||||
# An symbol name, following the Symbol Naming Specification
|
||||
get_battery_status_symbol() {
|
||||
echo "$__UPOWER_INFO" | awk -W posix '$1 == "symbol-name:" {print $2}'
|
||||
}
|
||||
|
||||
# Get color for the given battery percentage.
|
||||
#
|
||||
# Arguments:
|
||||
# $percent (int) Battery percentage.
|
||||
#
|
||||
# Returns:
|
||||
# The color to use for the given battery percentage.
|
||||
get_percentage_color() {
|
||||
local colors=( $(interpolate_rgb "$_COLOR_GRADIENT_START" "$_COLOR_GRADIENT_END" 8) )
|
||||
echo $(plookup $1 100 ${colors[@]})
|
||||
}
|
||||
|
||||
# Determines whether or not we can send a notification.
|
||||
#
|
||||
# Returns:
|
||||
# 0 on false, 1 on true.
|
||||
can_notify() {
|
||||
local -i now=$(date +"%s")
|
||||
local -i last=$(get_last_notify_time)
|
||||
|
||||
if [ -z "$last" ]; then return 0; fi
|
||||
|
||||
local -i diff=$(($now - $last))
|
||||
|
||||
[ $diff -gt $_NOTIFY_THROTTLE ]
|
||||
}
|
||||
|
||||
# Get the last time we sent a notification.
|
||||
#
|
||||
# Returns:
|
||||
# Time in seconds since the Epoch.
|
||||
get_last_notify_time() {
|
||||
if [ -f "$TMP_NOTIFY" ]; then
|
||||
echo $(stat -c '%Y' "$TMP_NOTIFY")
|
||||
fi
|
||||
}
|
||||
|
||||
# Save the last time we sent a notification.
|
||||
save_last_notify_time() {
|
||||
touch -m "$TMP_NOTIFY"
|
||||
}
|
||||
|
||||
# Display the charging indicator.
|
||||
#
|
||||
# Returns:
|
||||
# The charging indicator.
|
||||
display_batt_charging() {
|
||||
if [ -n "$_SYMBOL_CHARGING" ]; then
|
||||
echo -n "$(span -c "${_COLOR_CHARGING}" "$_SYMBOL_CHARGING") "
|
||||
fi
|
||||
|
||||
echo "$colored_battery_symbol"
|
||||
}
|
||||
|
||||
# Display the discharging indicator.
|
||||
#
|
||||
# Returns:
|
||||
# The discharging indicator.
|
||||
display_batt_discharging() {
|
||||
if [ -n "$_SYMBOL_DISCHARGING" ]; then
|
||||
echo -n "$(span -c "${_COLOR_DISCHARGING}" "$_SYMBOL_DISCHARGING") "
|
||||
fi
|
||||
|
||||
echo "$battery_charge_symbol"
|
||||
}
|
||||
|
||||
# Display the pending charge indicator.
|
||||
#
|
||||
# Returns:
|
||||
# The pending charge indicator.
|
||||
display_batt_pending_charge() {
|
||||
if [ -n "$_SYMBOL_PENDING" ]; then
|
||||
echo -n "$(span -c "${_COLOR_PENDING}" "$_SYMBOL_PENDING") "
|
||||
fi
|
||||
|
||||
if [ -n "$_SYMBOL_CHARGING" ]; then
|
||||
echo -n "$(span -c "${_COLOR_CHARGING}" "$_SYMBOL_CHARGING") "
|
||||
fi
|
||||
|
||||
echo "${battery_charge_symbol}"
|
||||
}
|
||||
|
||||
# Display the pending discharge indicator.
|
||||
#
|
||||
# Returns:
|
||||
# The pending discharge indicator.
|
||||
display_batt_pending_discharge() {
|
||||
if [ -n "$_SYMBOL_PENDING" ]; then
|
||||
echo -n "$(span -c "${_COLOR_PENDING}" "$_SYMBOL_PENDING") "
|
||||
fi
|
||||
|
||||
if [ -n "$_SYMBOL_DISCHARGING" ]; then
|
||||
echo -n "$(span -c "${_COLOR_DISCHARGING}" "$_SYMBOL_DISCHARGING") "
|
||||
fi
|
||||
|
||||
echo "$colored_battery_symbol"
|
||||
}
|
||||
|
||||
# Display the empty battery indicator.
|
||||
#
|
||||
# Returns:
|
||||
# The empty battery indicator.
|
||||
display_batt_empty() {
|
||||
echo "$battery_charge_symbol"
|
||||
}
|
||||
|
||||
# Display the fully charged indicator.
|
||||
#
|
||||
# Returns:
|
||||
# The fully-charged indicator.
|
||||
display_batt_fully_charged() {
|
||||
if [ -n "$_SYMBOL_FULLY_CHARGED" ]; then
|
||||
echo -n "$(span -c "${_COLOR_FULLY_CHARGED}" "$_SYMBOL_FULLY_CHARGED") "
|
||||
fi
|
||||
|
||||
echo "$battery_charge_symbol"
|
||||
}
|
||||
|
||||
# Display the unknown battery indicator.
|
||||
#
|
||||
# Returns:
|
||||
# The unknonw battery indicator.
|
||||
display_batt_unknown() {
|
||||
if [ -n "$_SYMBOL_UNKNOWN" ]; then
|
||||
echo -n "$(span "$_SYMBOL_UNKNOWN") "
|
||||
fi
|
||||
|
||||
echo "$(get_battery_charge_symbol 0)"
|
||||
}
|
||||
|
||||
# Display the battery error indicator.
|
||||
#
|
||||
# Returns:
|
||||
# The battery error indicator.
|
||||
display_batt_error() {
|
||||
echo "$(span -c "${_COLOR_ERROR}" "$_SYMBOL_ERROR" "$_SYMBOL_BATT_0")"
|
||||
}
|
||||
|
||||
# Display the battery percentage.
|
||||
#
|
||||
# Returns:
|
||||
# The battery percentage, or nothing if disabled.
|
||||
display_percentage() {
|
||||
if ! [ $_SYMBOLS_ONLY = true -o $_HIDE_PERCENTAGE = true ]; then
|
||||
echo -n " $(span -c "${percentage_color}" "${battery_percentage:---}${_PERCENT}")"
|
||||
|
||||
if [ "$status" = "charging" ] && $_SHOW_CHARGE_DIRECTION; then
|
||||
echo -n "$(span -c "${_COLOR_DIRECTIONAL_UP}" "${_SYMBOL_DIRECTION_UP}")"
|
||||
elif [ "$status" = "discharging" ] && $_SHOW_CHARGE_DIRECTION; then
|
||||
echo -n "$(span -c "${_COLOR_DIRECTIONAL_DOWN}" "${_SYMBOL_DIRECTION_DOWN}")"
|
||||
fi
|
||||
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
# Display the battery time remaining.
|
||||
#
|
||||
# Arguments:
|
||||
# $force (bool) Force display.
|
||||
#
|
||||
# Returns:
|
||||
# The time remaining, or nothing if disabled.
|
||||
display_time_remaining() {
|
||||
local force=${1:-false}
|
||||
|
||||
if [ $force = true ] || ! [ $_SYMBOLS_ONLY = true -o $_HIDE_TIME_REMAINING = true ]; then
|
||||
time_to_empty=$(get_time_to_empty "$battery_info")
|
||||
if [ -n "$time_to_empty" ]; then
|
||||
echo "$time_to_empty"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Display the battery time to fully charge.
|
||||
#
|
||||
# Arguments:
|
||||
# $force (bool) Force display.
|
||||
#
|
||||
# Returns:
|
||||
# The time to fully charge, or nothing if disabled.
|
||||
display_time_to_full() {
|
||||
local force=${1:-false}
|
||||
|
||||
if [ $force = true ] || ! [ $_SYMBOLS_ONLY = true -o $_HIDE_TIME_TO_FULL = true ]; then
|
||||
time_to_full=$(get_time_to_full "$battery_info")
|
||||
if [ -n "$time_to_full" ]; then
|
||||
echo "$time_to_full"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Displays an array of segments.
|
||||
#
|
||||
# Arguments:
|
||||
# $segments (array) The an array of segments.
|
||||
#
|
||||
# Returns:
|
||||
# Each segment after another, followed by a newline.
|
||||
display_segments() {
|
||||
local -a segments="$@"
|
||||
|
||||
for segment in "${segments[@]}"; do
|
||||
if [ -n "$segment" ]; then
|
||||
echo -n "$segment"
|
||||
fi
|
||||
done
|
||||
|
||||
echo
|
||||
}
|
||||
|
||||
# Colors text using either the first or second color
|
||||
#
|
||||
# Arguments:
|
||||
# $1 - Text
|
||||
# $2 - Color to use if toggle is false
|
||||
# $3 - Color to use if toggle is true
|
||||
# $4 - A boolean used to toggle between colors
|
||||
#
|
||||
# Returns:
|
||||
# The colored text
|
||||
multicolor() {
|
||||
local color="$2"
|
||||
local toggle=$4
|
||||
|
||||
if $toggle && [ -n "$3" ]; then
|
||||
color="$3"
|
||||
fi
|
||||
|
||||
if [ -n "$color" ]; then
|
||||
echo "$(span -c "$color" "$1")"
|
||||
else
|
||||
echo "$(span "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Display a notification.
|
||||
#
|
||||
# Arguments:
|
||||
# $text (string) The notification text.
|
||||
# $symbol (string) Name of an symbol.
|
||||
# $type (string) The type of notification.
|
||||
# $force (string) Force the notification, ignoring any throttle.
|
||||
# $rest (string) Any additional options to pass to the command.
|
||||
notify() {
|
||||
local text="$1"
|
||||
local symbol="$2"
|
||||
local type="$3"
|
||||
local force="$4"
|
||||
local rest="${@:5}"
|
||||
local command
|
||||
|
||||
if [ -z "$text" ] || ! $force && ! $(can_notify); then return; fi
|
||||
|
||||
if [ "$_NOTIFY_PROGRAM" = "dunstify" ]; then
|
||||
command="dunstify -r 1001"
|
||||
elif [ "$_NOTIFY_PROGRAM" = "notify-send" ]; then
|
||||
command="notify-send"
|
||||
fi
|
||||
|
||||
if [ -n "$_NOTIFY_EXPIRES" ]; then command="$command -t $_NOTIFY_EXPIRES"; fi
|
||||
if [ -n "$symbol" ]; then command="$command -i $symbol"; fi
|
||||
if [ -n "$type" ]; then command="$command -u $type"; fi
|
||||
|
||||
command="$command $rest \"$text\""
|
||||
if eval $command; then
|
||||
save_last_notify_time
|
||||
fi
|
||||
}
|
||||
|
||||
# Display a dialog.
|
||||
#
|
||||
# Arguments:
|
||||
# $text (string) The dialog text.
|
||||
# $symbol (string) Name of an symbol.
|
||||
# $type (string) The type of dialog.
|
||||
# $rest (string) Any additional options to pass to the command.
|
||||
dialog() {
|
||||
local text="$1"
|
||||
local symbol="$2"
|
||||
local type="$3"
|
||||
local rest="${@:4}"
|
||||
|
||||
if [ -z "$text" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
command="zenity"
|
||||
|
||||
if [ -n "$symbol" ]; then command="$command --symbol-name=\"$symbol\""; fi
|
||||
if [ -n "$type" ]; then command="$command --${type}"; fi
|
||||
|
||||
command="$command --text=\"$text\" $rest"
|
||||
eval $command
|
||||
}
|
||||
|
||||
# Display program usage.
|
||||
usage() {
|
||||
echo -e "Usage: $0 [options]
|
||||
Display the battery status using upower for i3blocks.\n
|
||||
Options:
|
||||
-a <none|notify>\taction to take when battery is low
|
||||
-A <color>\t\tcolor of the alert symbol
|
||||
-B <color>\t\tcolor of the battery symbol
|
||||
-c <capacity>\t\tset battery capacity alert percentage (0=disable)
|
||||
-C <color>\t\tcolor of the charging symbol
|
||||
-d\t\t\tshow the direction of change for the battery's percentage
|
||||
-D <color>\t\tcolor of the discharging symbol
|
||||
-e <millseconds>\texpiration time of notifications (Ubuntu's Notify OSD and GNOME Shell both ignore this parameter.)
|
||||
-E <color>\t\tcolor of the battery error symbol
|
||||
-f <font>\t\tfont for text and symbols
|
||||
-F <color>\t\tcolor of the fully-charged symbol
|
||||
-G\t\t\tcolor the battery symbol according to battery percentage
|
||||
-h\t\t\tdisplay this help and exit
|
||||
-H\t\t\tsuppress displaying if battery is fully-charged
|
||||
-i <color>\t\tcolor gradient start color
|
||||
-I\t\t\tonly display symbols
|
||||
-j <color>\t\tcolor gradient end color
|
||||
-J <symbol>\t\tsymbol for a battery 100% charged
|
||||
-k\t\t\thide the battery percentage
|
||||
-K <symbol>\t\tsymbol for a battery 75% charged
|
||||
-l <none|notify>\taction to take when the battery level reaches critical
|
||||
-L <symbol>\t\tsymbol to indicate there is an alert
|
||||
-M <symbol>\t\tsymbol for a battery 50% charged
|
||||
-n <program>\t\ta libnotify compatible notification program
|
||||
-N <color>\t\tcolor of the battery charge decreasing indicator
|
||||
-O <symbol>\t\tsymbol for a battery with no/low charge
|
||||
-p <symbol>\t\tsymbol to use for the percent sign
|
||||
-P <color>\t\tcolor of the pending charge symbol
|
||||
-Q <symbol>\t\tsymbol for a battery 25% charged
|
||||
-r\t\t\thide the battery time remaining
|
||||
-R <symbol>\t\tsymbol to indicate the battery state is undefined
|
||||
-S <symbol>\t\tsymbol to indicate battery is fully charged
|
||||
-t <seconds>\t\tminimum time in seconds between notifications to prevent spam
|
||||
-T <symbol>\t\tsymbol to indicate the battery is charging
|
||||
-u\t\t\thide the time to charge the battery to full
|
||||
-U <color>\t\tcolor of the battery charge increasing indicator
|
||||
-V <symbol>\t\tsymbol to indicate the battery state is unknown
|
||||
-W <symbol>\t\tsymbol to indicate battery charge is increasing
|
||||
-X <symbol>\t\tsymbol to indicate the battery state is pending
|
||||
-Y <symbol>\t\tsymbol to indicate the battery is discharging
|
||||
-Z <symbol>\t\tsymbol to indicate battery charge is decreasing
|
||||
" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
||||
declare -a long_segments
|
||||
declare -a short_segments
|
||||
|
||||
__UPOWER_INFO=$(upower --show-info "/org/freedesktop/UPower/devices/battery_${BLOCK_INSTANCE:-BAT0}")
|
||||
TMP_NOTIFY="$(get_temp_dir)/battery-plus.last_notify"
|
||||
|
||||
while getopts "a:A:B:c:C:dD:e:E:F:GhHi:Ij:J:kK:l:L:M:n:N:O:p:P:Q:rR:S:t:T:uU:V:W:X:Y:Z:" o; do
|
||||
case "$o" in
|
||||
a) _LOW_ACTION="${OPTARG}" ;;
|
||||
A) _COLOR_ALERT="${OPTARG}" ;;
|
||||
B) _COLOR_BATTERY="${OPTARG}" ;;
|
||||
c) _CAPACITY_ALERT="${OPTARG}" ;;
|
||||
C) _COLOR_CHARGING="${OPTARG}" ;;
|
||||
d) _SHOW_CHARGE_DIRECTION=true ;;
|
||||
D) _COLOR_DISCHARGING="${OPTARG}" ;;
|
||||
e) _NOTIFY_EXPIRES="${OPTARG}" ;;
|
||||
E) _COLOR_ERROR="${OPTARG}" ;;
|
||||
F) _COLOR_FULLY_CHARGED="${OPTARG}" ;;
|
||||
G) _USE_BATT_GRADIENT=true ;;
|
||||
h | *) usage ;;
|
||||
H) _HIDE_IF_CHARGED=true ;;
|
||||
i) _COLOR_GRADIENT_START="${OPTARG}" ;;
|
||||
I) _SYMBOLS_ONLY=true ;;
|
||||
j) _COLOR_GRADIENT_END="${OPTARG}" ;;
|
||||
J) _SYMBOL_BATT_100="${OPTARG}" ;;
|
||||
k) _HIDE_PERCENTAGE=true ;;
|
||||
K) _SYMBOL_BATT_75="${OPTARG}" ;;
|
||||
l) _CRITICAL_ACTION="${OPTARG}" ;;
|
||||
L) _SYMBOL_ALERT="${OPTARG}" ;;
|
||||
M) _SYMBOL_BATT_50="${OPTARG}" ;;
|
||||
n) _NOTIFY_PROGRAM="${OPTARG}" ;;
|
||||
N) _COLOR_DIRECTIONAL_DOWN="${OPTARG}" ;;
|
||||
O) _SYMBOL_BATT_0="${OPTARG}" ;;
|
||||
p) _PERCENT="${OPTARG}" ;;
|
||||
P) _COLOR_PENDING="${OPTARG}" ;;
|
||||
Q) _SYMBOL_BATT_25="${OPTARG}" ;;
|
||||
r) _HIDE_TIME_REMAINING=true ;;
|
||||
R) _SYMBOL_ERROR="${OPTARG}" ;;
|
||||
S) _SYMBOL_FULLY_CHARGED="${OPTARG}" ;;
|
||||
t) _NOTIFY_THROTTLE="${OPTARG}" ;;
|
||||
T) _SYMBOL_CHARGING="${OPTARG}" ;;
|
||||
u) _HIDE_TIME_TO_FULL=true ;;
|
||||
U) _COLOR_DIRECTIONAL_UP="${OPTARG}" ;;
|
||||
V) _SYMBOL_UNKNOWN="${OPTARG}" ;;
|
||||
W) _SYMBOL_DIRECTION_UP="${OPTARG}" ;;
|
||||
X) _SYMBOL_PENDING="${OPTARG}" ;;
|
||||
Y) _SYMBOL_DISCHARGING="${OPTARG}" ;;
|
||||
Z) _SYMBOL_DIRECTION_DOWN="${OPTARG}" ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1)) # Shift off options and optional --
|
||||
|
||||
battery_percentage=$(get_battery_percent)
|
||||
percentage_color=$(get_percentage_color "$battery_percentage")
|
||||
capacity=$(get_battery_capacity)
|
||||
battery_charge_symbol=$(get_battery_charge_symbol "$battery_percentage")
|
||||
battery_status_symbol=$(get_battery_status_symbol)
|
||||
colored_battery_symbol=$(multicolor "$battery_charge_symbol" "$_COLOR_BATTERY" "$percentage_color" $_USE_BATT_GRADIENT)
|
||||
warning_level=$(get_battery_warning_level)
|
||||
|
||||
# Handle battery warning levels
|
||||
case "$warning_level" in
|
||||
critical)
|
||||
case "$_CRITICAL_ACTION" in
|
||||
notify) $(notify "$(span "Your battery level is ${warning_level}!")" "$battery_status_symbol" "critical" false "-c device") ;;
|
||||
esac
|
||||
;;
|
||||
low)
|
||||
case "$_LOW_ACTION" in
|
||||
notify) $(notify "$(span "Your battery level is ${warning_level}")" "$battery_status_symbol" "normal" false "-c device") ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
# Displayable alerts
|
||||
if [ "$_CAPACITY_ALERT" -gt 0 ] && [ "${capacity%.*}" -le $_CAPACITY_ALERT ]; then
|
||||
CAPACITY_TRIGGERED=true
|
||||
long_segments+=( "$(span -c "$_COLOR_ALERT" "$_SYMBOL_ALERT") " )
|
||||
fi
|
||||
|
||||
# Battery statuses
|
||||
status=$(get_battery_status)
|
||||
case "$status" in
|
||||
charging) long_segments+=( "$(display_batt_charging)" ) ;;
|
||||
discharging) long_segments+=( "$(display_batt_discharging)" ) ;;
|
||||
empty) long_segments+=( "$(display_batt_empty)" ) ;;
|
||||
fully-charged)
|
||||
if $_HIDE_IF_CHARGED; then
|
||||
exit 0
|
||||
fi
|
||||
long_segments+=( "$(display_batt_fully_charged)" )
|
||||
;;
|
||||
pending-charge) long_segments+=( "$(display_batt_pending_charge)" ) ;;
|
||||
pending-discharge) long_segments+=( "$(display_batt_pending_discharge)" ) ;;
|
||||
unknown) long_segments+=( "$(display_batt_unknown)" ) ;;
|
||||
*) long_segments+=( "$(display_batt_error)" ) ;;
|
||||
esac
|
||||
|
||||
# Since long_segments contains no text at this point, lets use it for the short_text
|
||||
short_segments=( "${long_segments[@]}" )
|
||||
|
||||
# Append all text segments
|
||||
long_segments+=( "$(display_percentage)" )
|
||||
if [ -n "$(display_time_remaining)" ]; then
|
||||
long_segments+=( "($(display_time_remaining))" )
|
||||
fi
|
||||
if [ -n "$(display_time_to_full)" ]; then
|
||||
long_segments+=( "($(display_time_to_full))" )
|
||||
fi
|
||||
|
||||
# Display the block long_text
|
||||
display_segments ${long_segments[@]}
|
||||
|
||||
# Display the block short_text
|
||||
display_segments ${short_segments[@]}
|
||||
|
||||
# Handle click events
|
||||
case $BLOCK_BUTTON in
|
||||
1)
|
||||
if [ -n "$CAPACITY_TRIGGERED" ]; then
|
||||
$(dialog "$(span "Your battery capacity has reduced to ${capacity%.*}${_PERCENT}!")" "battery-caution" "warning" "--no-wrap")
|
||||
else
|
||||
if [ "$status" = "discharging" ]; then
|
||||
$(notify "$(span "$(display_time_remaining true) remaining")" "alarm-symbolic" "normal" true "-c device")
|
||||
elif [ "$status" = "charging" ]; then
|
||||
$(notify "$(span "$(display_time_to_full true) until fully charged")" "alarm-symbolic" "normal" true "-c device")
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$battery_percentage" ] && [ "$battery_percentage" -le 5 ]; then
|
||||
exit 33
|
||||
fi
|
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
DATEFMT=${DATEFMT:-"+%a %d.%m.%Y %H:%M:%S"}
|
||||
SHORTFMT=${SHORTFMT:-"+%H:%M:%S"}
|
||||
|
||||
OPTIND=1
|
||||
while getopts ":f:" opt; do
|
||||
case $opt in
|
||||
f) DATEFMT="$OPTARG" ;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "$BLOCK_BUTTON" in
|
||||
1|2|3)
|
||||
# Try to focus Thunderbird
|
||||
i3-msg -q [class="Thunderbird" instance="Mail"] focus
|
||||
if [ $? == 2 ]
|
||||
then
|
||||
# Open Thunderbird if it was not open
|
||||
i3-msg -q "exec thunderbird -mail -calendar"
|
||||
else
|
||||
# Open calendar
|
||||
xdotool key --clearmodifiers --delay 5 ctrl+shift+c
|
||||
fi
|
||||
esac
|
||||
echo "$LABEL$(date "$DATEFMT")"
|
||||
echo "$LABEL$(date "$SHORTFMT")"
|
@ -5,10 +5,6 @@
|
||||
#
|
||||
# https://vivien.github.io/i3blocks
|
||||
|
||||
# Sources:
|
||||
# https://github.com/hastinbe/i3blocks-battery-plus
|
||||
# https://github.com/zakariaGatter/i3blocks-gate
|
||||
|
||||
# Global properties
|
||||
separator=true
|
||||
separator_block_width=15
|
||||
@ -18,11 +14,22 @@ command=./activity
|
||||
interval=10
|
||||
LABEL=
|
||||
|
||||
[dunst]
|
||||
command=./dunst
|
||||
markup=pango
|
||||
interval=once
|
||||
format=json
|
||||
|
||||
[volume]
|
||||
command=./volume
|
||||
LABEL=
|
||||
interval=10
|
||||
signal=10
|
||||
signal=1
|
||||
|
||||
[battery]
|
||||
command=./battery
|
||||
markup=pango
|
||||
interval=120
|
||||
|
||||
[calendar]
|
||||
command=./calendar
|
||||
|
60
i3/.config/i3blocks/dunst
Executable file
60
i3/.config/i3blocks/dunst
Executable file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
A do-not-disturb button for muting Dunst notifications in i3 using i3blocks
|
||||
Mute is handled by passing 'DUNST_COMMAND_PAUSE' and 'DUNST_COMMAND_RESUME' to
|
||||
the notify-send script and the 'DUNST_MUTE' environment variable is set to keep
|
||||
track of the toggle.
|
||||
"""
|
||||
|
||||
__author__ = "Jessey White-Cinis <j@cin.is>"
|
||||
__copyright__ = "Copyright (c) 2019 Jessey White-Cinis"
|
||||
__license__ = "MIT"
|
||||
__version__ = "1.1.0"
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
def mute_on():
|
||||
'''Turns off dunst notifications'''
|
||||
subprocess.run(["dunstctl", "set-paused", "true"], check=True)
|
||||
return {
|
||||
"full_text":"<span font='Font Awesome 5 Free Solid' color='#BE616E'>\uf1f6</span>",
|
||||
"DUNST_MUTE":"on"
|
||||
}
|
||||
|
||||
def mute_off():
|
||||
'''Turns back on dunst notifications'''
|
||||
subprocess.run(["dunstctl", "set-paused", "false"], check=True)
|
||||
return {
|
||||
"full_text":"<span font='Font Awesome 5 Free Solid' color='#FFFFFF'>\uf0f3</span>",
|
||||
"DUNST_MUTE":"off"
|
||||
}
|
||||
|
||||
def clicked():
|
||||
'''Returns True if the button was clicked'''
|
||||
button = "BLOCK_BUTTON" in os.environ and os.environ["BLOCK_BUTTON"]
|
||||
return bool(button)
|
||||
|
||||
def muted():
|
||||
'''Returns True if Dunst is muted'''
|
||||
cmd = ['dunstctl', 'is-paused']
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
output = proc.communicate()[0]
|
||||
return u'true' == output.strip().decode("UTF-8")
|
||||
|
||||
if clicked():
|
||||
# toggle button click to turn mute on and off
|
||||
if muted():
|
||||
RTN = mute_off()
|
||||
else:
|
||||
RTN = mute_on()
|
||||
|
||||
else:
|
||||
# Set default state using 'DUNST_MUTE' environment variable
|
||||
if muted():
|
||||
RTN = mute_on()
|
||||
else:
|
||||
RTN = mute_off()
|
||||
|
||||
print(json.dumps(RTN))
|
@ -1,462 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Zakaria Barkouk ( Zakaria.gatter@gmail.com)
|
||||
|
||||
#---------------------#
|
||||
# SHOW CPU INFO (TOP) #
|
||||
#---------------------#
|
||||
_BLOCK_1_(){ #{{{
|
||||
mpstat | awk '/all/{print "'"${1:-} "'"$4}'
|
||||
} #}}}
|
||||
|
||||
#--------------------#
|
||||
# SHOW ALL CPUS INFO #
|
||||
#--------------------#
|
||||
_BLOCK_2_(){ #{{{
|
||||
mpstat -P ALL | awk -v icon=${1:-} 'BEGIN{printf "%s ", icon} {
|
||||
if($3 ~ /^[0-9]/){
|
||||
printf "%s ", $4
|
||||
}
|
||||
}'
|
||||
} #}}}
|
||||
|
||||
#--------------------------#
|
||||
# SHOW MEMORY USAGE (FREE) #
|
||||
#--------------------------#
|
||||
_BLOCK_3_(){ #{{{
|
||||
free -h | awk '/^Mem:/{print "'"${1:-} "'"$3}'
|
||||
} #}}}
|
||||
|
||||
#------------------------#
|
||||
# SHOW SWAP USAGE (FREE) #
|
||||
#------------------------#
|
||||
_BLOCK_4_(){ #{{{
|
||||
free -h | awk '/^Swap:/{print "'"${1:-}"' "$3}'
|
||||
} #}}}
|
||||
|
||||
#---------------------------#
|
||||
# SHOW DATE AND TIME (DATE) #
|
||||
#---------------------------#
|
||||
_BLOCK_5_(){ #{{{
|
||||
date +"${1:-} %R %D"
|
||||
} #}}}
|
||||
|
||||
#----------------------------#
|
||||
# SHOW BATTERY STATUS (ACPI) #
|
||||
#----------------------------#
|
||||
_BLOCK_6_(){ #{{{
|
||||
Bat=$(acpi | awk '{gsub(",|%","",$4); print $4}');
|
||||
adapt=$(acpi -a | awk '{print $3}');
|
||||
|
||||
if [ "$adapt" = "on-line" -a -n "$Bat" ];then
|
||||
icon0=" "
|
||||
icon1=" "
|
||||
icon2=" "
|
||||
icon3=" "
|
||||
icon4=" "
|
||||
elif [ "$adapt" = "on-line" ];then
|
||||
icon0=""
|
||||
icon1=""
|
||||
icon2=""
|
||||
icon3=""
|
||||
icon4=""
|
||||
else
|
||||
icon0=""
|
||||
icon1=""
|
||||
icon2=""
|
||||
icon3=""
|
||||
icon4=""
|
||||
fi
|
||||
|
||||
[ -z "$Bat" ] && echo "$icon0 $adapt" && return
|
||||
[ "$Bat" -gt "100" ] && echo "$icon4 Full"
|
||||
[ "$Bat" -gt "90" ] && echo "$icon3 $Bat%"
|
||||
[ "$Bat" -gt "60" ] && echo "$icon2 $Bat%"
|
||||
[ "$Bat" -gt "30" ] && echo "$icon1 $Bat%"
|
||||
[ "$Bat" -lt "30" ] && echo "$icon0 $Bat%"
|
||||
} #}}}
|
||||
|
||||
#----------------------#
|
||||
# SHOW DISK USAGE (DF) #
|
||||
#----------------------#
|
||||
_BLOCK_7_() { #{{{
|
||||
df -h "${1:-/}" | awk '/\/dev\//{print "'"${2:-}"' "$3-G"/"$2}'
|
||||
} #}}}
|
||||
|
||||
#----------------------#
|
||||
# SHOW KEYBOARD LAYOUT #
|
||||
#----------------------#
|
||||
_BLOCK_8_() { #{{{
|
||||
awk -F '"' '/XKBLAYOUT/{print "'"${1:-} "'"$2}' /etc/default/keyboard
|
||||
} #}}}
|
||||
|
||||
#----------------------#
|
||||
# SHOW SYSTEM LANGUAGE #
|
||||
#----------------------#
|
||||
_BLOCK_9_(){ #{{{
|
||||
echo "${1:-} ${LANG/.UTF-8/}"
|
||||
} #}}}
|
||||
|
||||
#------------------------------#
|
||||
# SHOW MACHINE UPTIME (UPTIME) #
|
||||
#------------------------------#
|
||||
_BLOCK_10_() { #{{{
|
||||
uptime | awk '{sub(",","",$4); print "'"${1:- } "'"$3 " " $4}'
|
||||
} #}}}
|
||||
|
||||
#----------------------#
|
||||
# SHOW TRASH SIZE (DU) #
|
||||
#----------------------#
|
||||
_BLOCK_11_() { #{{{
|
||||
[ -d "$HOME/.local/share/Trash/files" ] && {
|
||||
du -hc $HOME/.local/share/Trash/files | awk '/total$/{print "'"${1:-} "'"$1}'
|
||||
} || {
|
||||
echo "${1:-} ---"
|
||||
}
|
||||
} #}}}
|
||||
|
||||
#-------------------#
|
||||
# SHOW WINDOW USAGE #
|
||||
#-------------------#
|
||||
_BLOCK_12_() { #{{{
|
||||
focus=$(xprop -id `xprop -root | awk '/^_NET_ACTIVE_WINDOW/{print $5}'` | awk -F '"' '/^WM_NAME/{print $2}')
|
||||
if [ -z "$focus" ];then
|
||||
echo "${1:-} Welcome"
|
||||
else
|
||||
[ "${#focus}" -gt "${2:-30}" ] && echo "${1:-} ${focus::${2:-30}} ..." || echo "${1:-} $focus"
|
||||
fi
|
||||
} #}}}
|
||||
|
||||
#-----------------------------------------#
|
||||
# SHOW MOCP PLAYING SONG AND STATUS (MOC) #
|
||||
#-----------------------------------------#
|
||||
_BLOCK_13_() { # {{{
|
||||
Title=$(mocp -Q %title)
|
||||
F_Title=$(basename `mocp -Q %file | tr " " "_"`)
|
||||
Status=$(mocp -Q %state)
|
||||
|
||||
if [ "$Status" != "PLAY" ];then
|
||||
echo "${1:-} Pause"
|
||||
elif [ -z "$Title" ];then
|
||||
echo "${1:-} ${F_Title::30}"
|
||||
else
|
||||
echo "${1:-} $Title"
|
||||
fi
|
||||
} #}}}
|
||||
|
||||
#------------------------------------------------------#
|
||||
# SHOW MPD PLAYING SONG AND STATUS (MPD; NCMPCCP, MPC) #
|
||||
#------------------------------------------------------#
|
||||
_BLOCK_14_() { #{{{
|
||||
local NCMP=$(mpc | awk '/^\[playing\]/{print $1}')
|
||||
|
||||
if [ "$NCMP" = "[playing]" ];then
|
||||
echo "${1:-} $(basename $(mpc current)) "
|
||||
else
|
||||
echo "${1:-} Pause "
|
||||
fi
|
||||
} #}}}
|
||||
|
||||
#-------------------------#
|
||||
# SHOW CPU TEMP (XSENSER) #
|
||||
#-------------------------#
|
||||
_BLOCK_15_() { #{{{
|
||||
sensors | awk '/^CPU/{gsub("\+",""); print "'"${1:-} "'"$2}'
|
||||
} #}}}
|
||||
|
||||
#-------------------------#
|
||||
# SHOW GPU TEMP (XSENSER) #
|
||||
#-------------------------#
|
||||
_BLOCK_16_() { #{{{
|
||||
sensors | awk '/^GPU/{gsub("\+",""); print "'"${1:-} "'"$2}' | tail -1
|
||||
} #}}}
|
||||
|
||||
#----------------------------------#
|
||||
# SHOW TOUCHPAD STATUS (SYSCLIENT) #
|
||||
#----------------------------------#
|
||||
_BLOCK_17_() { #{{{
|
||||
[ "$(synclient -l | awk '/Touchpad/{print $3}')" = "0" ] && echo "${1:-} Enable" || echo "${1:-} Disable"
|
||||
} #}}}
|
||||
|
||||
#---------------------------#
|
||||
# SHOW VOLUME STATUS (ALSA) #
|
||||
#---------------------------#
|
||||
_BLOCK_18_() { #{{{
|
||||
local Vol=$(amixer get Master | awk '/Mono:/{gsub("\[|\%|\]",""); print $4}')
|
||||
local Mute=$(amixer get Master | awk '/Mono:/{gsub("\[|\]",""); print $6}')
|
||||
|
||||
if [ "$Mute" = "off" ];then
|
||||
echo -e " --"
|
||||
else
|
||||
if [ "$Vol" -gt "60" ];then
|
||||
echo -e " $Vol%"
|
||||
elif [ "$Vol" -gt "30" ];then
|
||||
echo -e " $Vol%"
|
||||
elif [ "$Vol" -lt "30" ];then
|
||||
echo -e " $Vol%"
|
||||
fi
|
||||
fi
|
||||
} #}}}
|
||||
|
||||
#----------------------------------------------#
|
||||
# SHOW WIFI INFO ; IP ; CONNECTED NAME (NMCLI) #
|
||||
#----------------------------------------------#
|
||||
_BLOCK_19_() { #{{{
|
||||
while read -a W ;do
|
||||
[ "${W[2]}" = "connected" ] && {
|
||||
_ip=$(nmcli device show ${W[0]} | awk '/^IP4.ADDRESS/{print $NF}')
|
||||
_name=$(nmcli device show ${W[0]} | awk '/^GENERAL.CONNECTION:/{$1=""; print $0}')
|
||||
echo -n "${1:-} ${_ip%/*} (${_name} )"
|
||||
} || {
|
||||
echo -n "${1:-} ---"
|
||||
}
|
||||
done< <(nmcli d | grep -w "wifi")
|
||||
echo -e ""
|
||||
} #}}}
|
||||
|
||||
#-------------------------------------------#
|
||||
# SHOW ETHERNET INFO ; IP ; CONNECTED NAME #
|
||||
#-------------------------------------------#
|
||||
_BLOCK_20_() { #{{{
|
||||
while read -a W ;do
|
||||
[ "${W[2]}" = "connected" ] && {
|
||||
_ip=$(nmcli device show ${W[0]} | awk '/^IP4.ADDRESS/{print $NF}')
|
||||
_name=$(nmcli device show ${W[0]} | awk '/^GENERAL.CONNECTION:/{$1=""; print $0}')
|
||||
echo -n "${1:-} ${_ip%/*} (${_name} ) "
|
||||
} || {
|
||||
echo -n "${1:-} ---"
|
||||
}
|
||||
done< <(nmcli d | grep "ethernet")
|
||||
echo -e ""
|
||||
} #}}}
|
||||
|
||||
|
||||
#-----------------------------------------------#
|
||||
# SHOW WIFI INFO ; IP6 ; CONNECTED NAME (NMCLI) #
|
||||
#-----------------------------------------------#
|
||||
_BLOCK_21_() { #{{{
|
||||
while read -a W ;do
|
||||
[ "${W[2]}" = "connected" ] && {
|
||||
_ip=$(nmcli device show ${W[0]} | awk '/^IP6.ADDRESS/{print $NF}')
|
||||
_name=$(nmcli device show ${W[0]} | awk '/^GENERAL.CONNECTION:/{$1=""; print $0}')
|
||||
echo -n "${1:-} ${_ip%/*} (${_name} ) "
|
||||
} || {
|
||||
echo -n "${1:-} ---"
|
||||
}
|
||||
done< <(nmcli d | grep "wifi")
|
||||
echo -e ""
|
||||
} #}}}
|
||||
|
||||
#--------------------------------------------#
|
||||
# SHOW ETHERNET INFO ; IP6 ; CONNECTED NAME #
|
||||
#--------------------------------------------#
|
||||
_BLOCK_22_() { #{{{
|
||||
while read -a W ;do
|
||||
[ "${W[2]}" = "connected" ] && {
|
||||
_ip=$(nmcli device show ${W[0]} | awk '/^IP6.ADDRESS/{print $NF}')
|
||||
_name=$(nmcli device show ${W[0]} | awk '/^GENERAL.CONNECTION:/{$1=""; print $0}')
|
||||
echo -n "${1:-} ${_ip%/*} (${_name} ) "
|
||||
} || {
|
||||
echo -n "${1:-} ---"
|
||||
}
|
||||
done< <(nmcli d | grep "ethernet")
|
||||
echo -e ""
|
||||
} #}}}
|
||||
|
||||
#-------------------------------#
|
||||
# SHOW PROSSES USE BY THIS USER #
|
||||
#-------------------------------#
|
||||
_BLOCK_23_() { #{{{
|
||||
echo "${1:-} $(ps -U $USER | wc -l)"
|
||||
} #}}}
|
||||
|
||||
#---------------------#
|
||||
# SHOW SYSTEM KERENEL #
|
||||
#---------------------#
|
||||
_BLOCK_24_() { #{{{
|
||||
echo "${1:-} $(uname -r)"
|
||||
} #}}}
|
||||
|
||||
#-----------------------------#
|
||||
# SHOW USB PLUG IN UR COMPUTE #
|
||||
#-----------------------------#
|
||||
_BLOCK_25_() { #{{{
|
||||
echo "${1:-} $(lsblk -l -o 'TRAN' | grep -c "usb")"
|
||||
} #}}}
|
||||
|
||||
#---------------------------------------#
|
||||
# SHOW TOTAL PKGS INSTALL IN YOUR SYSTE #
|
||||
#---------------------------------------#
|
||||
_BLOCK_26_() { #{{{
|
||||
echo "${1:-} $(dpkg -l | grep -c "^ii")"
|
||||
} #}}}
|
||||
|
||||
#--------------------------------------------#
|
||||
# CHECK IF THERE IS ANY UPDATE IN UR SYSTEM #
|
||||
#--------------------------------------------#
|
||||
_BLOCK_27_() { #{{{
|
||||
local U_PKGS=$(apt-get -s -o APT::Get::Show-User-Simulation-Note=0 dist-upgrade | grep "^\s\s" | wc -w);
|
||||
echo "${1:-} $U_PKGS"
|
||||
} #}}}
|
||||
|
||||
#-----------------#
|
||||
# SHOW UFW STATUS #
|
||||
#-----------------#
|
||||
_BLOCK_28_() { #{{{
|
||||
[ "$(systemctl status ufw | awk '/Active:/{print $2}')" == "active" ] && echo "${1:-} On" || echo "${1:-} Off"
|
||||
} #}}}
|
||||
|
||||
#-------------------------#
|
||||
# SHOW NUMBER LOCK STATUS #
|
||||
#-------------------------#
|
||||
_BLOCK_29_() { #{{{
|
||||
[ "$(xset -q | awk '/00:/{print $8}')" == "on" ] && echo "${1:-} On" || echo "${1:-} Off"
|
||||
} #}}}
|
||||
|
||||
#-----------------------#
|
||||
# SHOW BLUETOOTH STATUS #
|
||||
#-----------------------#
|
||||
_BLOCK_30_() { #{{{
|
||||
[ "$(systemctl status bluetooth.target | awk '/Active:/{print $2}')" == "active" ] && echo "${1:-} On" || echo "${1:-} Off"
|
||||
} #}}}
|
||||
|
||||
#------------------------#
|
||||
# SHOW CAPS LOCK STATUS #
|
||||
#------------------------#
|
||||
_BLOCK_31_() { #{{{
|
||||
[ "$(xset -q | awk '/00:/{print $4}')" == "on" ] && echo "${1:-} On" || echo "${1:-} Off"
|
||||
} #}}}
|
||||
|
||||
#-----------------------------#
|
||||
# DISPLAY X SCREENSAVER STATE #
|
||||
#-----------------------------#
|
||||
_BLOCK_32_() { #{{{
|
||||
[ "$(xdg-screensaver status)" != "enabled" ] && echo "${1:-} Off" || echo "${1:-} On"
|
||||
} #}}}
|
||||
|
||||
#--------------------------------#
|
||||
# CALCULE MOUNT POINTS ON SYSTEM #
|
||||
#--------------------------------#
|
||||
_BLOCK_33_() { #{{{
|
||||
echo "${1:-} $(cat /proc/mounts | grep -c "^/dev/sd*") "
|
||||
} #}}}
|
||||
|
||||
#-------------------------#
|
||||
# SHOW CMUS PLAYING SONG #
|
||||
#-------------------------#
|
||||
_BLOCK_34_() { #{{{
|
||||
local CMUS_P=$(cmus-remote -Q | awk '/^status/{print $2}')
|
||||
local CMUS_F=$(cmus-remote -Q | awk '/^file/{$1=""; print $2}')
|
||||
|
||||
if [ "$CMUS_P" = "Playing" ];then
|
||||
echo "${1:-} $(basename $CMUS_F)"
|
||||
else
|
||||
echo "${1:-} Pause"
|
||||
fi
|
||||
} #}}}
|
||||
|
||||
#----------------------#
|
||||
# SHOW APPARMOR STATUS #
|
||||
#----------------------#
|
||||
_BLOCK_35_() { #{{{
|
||||
[ "$(aa-enabled)" = "Yes" ] && {
|
||||
echo "${1:-} On"
|
||||
}||{
|
||||
echo "${1:-} Off"
|
||||
}
|
||||
} #}}}
|
||||
|
||||
#-----------------------------#
|
||||
# SHOW TOTAL PACKAGES IN ARCH #
|
||||
#-----------------------------#{{{
|
||||
_BLOCK_36_(){
|
||||
echo "${1:-} $(pacman -Q | grep -c "*")"
|
||||
}
|
||||
#}}}
|
||||
|
||||
#--------------------#
|
||||
# SHOW I3 WORKSPACES #
|
||||
#--------------------#
|
||||
_BLOCK_37_() { #{{{
|
||||
i3-msg -t get_workspaces | awk -F , '{
|
||||
for(i=1;i<=NF;i++){
|
||||
if($i~"name"){
|
||||
gsub("\"name\":|\"","",$i)
|
||||
WK=$i
|
||||
}
|
||||
if($i~"focused"){
|
||||
gsub("\"focused\":","",$i)
|
||||
WKF=$i
|
||||
}
|
||||
if($i~"urgent"){
|
||||
gsub("\"urgent\":|\]|\}","",$i)
|
||||
if($i=="false" && WKF=="true"){
|
||||
printf "%s ", WK
|
||||
}
|
||||
if($i=="false" && WKF=="false"){
|
||||
printf"[%s] ", WK
|
||||
}
|
||||
if($i=="true" && WKF=="false"){
|
||||
printf "[*%s] ", WK
|
||||
}
|
||||
if($i=="true" && WKF=="true"){
|
||||
printf "*%s ", WK
|
||||
}
|
||||
}
|
||||
}
|
||||
}'
|
||||
} #}}}
|
||||
|
||||
#-----------------#
|
||||
# SHOW USER NAME #
|
||||
#-----------------#
|
||||
_BLOCK_38_(){ #{{{
|
||||
echo -e "${1:-} $USER"
|
||||
} #}}}
|
||||
|
||||
#-------------------#
|
||||
# SHOW VOLUME PULSE #
|
||||
#-------------------#
|
||||
_BLOCK_39_(){
|
||||
local Vol=$(pactl list sinks | awk '/Volume: front/{print $5-"%"}')
|
||||
local Mute=$(amixer get Master | awk '/Mono:/{gsub("\[|\]",""); print $6}')
|
||||
|
||||
if [ "$Mute" = "off" ];then
|
||||
echo -e " --"
|
||||
else
|
||||
if [ "$Vol" -gt "60" ];then
|
||||
echo -e " $Vol%"
|
||||
elif [ "$Vol" -gt "30" ];then
|
||||
echo -e " $Vol%"
|
||||
elif [ "$Vol" -lt "30" ];then
|
||||
echo -e " $Vol%"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#------------------------#
|
||||
# USAGE AND HELP DIALOG #
|
||||
#------------------------#
|
||||
_USAGE_(){ #{{{
|
||||
echo -e "
|
||||
i3b-gate : is a all in one collaction of small script
|
||||
show you useful unformation about your system
|
||||
|
||||
There is 39 deffirent script to use
|
||||
for more information you can see the 'README' file
|
||||
or visite 'https://gitlab.com/zakariagatter/i3blocks-gate'
|
||||
|
||||
SYNTAX :
|
||||
i3b-gate [NUMBER] ...
|
||||
"
|
||||
} #}}}
|
||||
|
||||
#----------------#
|
||||
# MAIN ARGUMENT #
|
||||
#----------------#
|
||||
if [ "$1" -gt "39" ] || [ -z "$1" ] ;then
|
||||
_USAGE_
|
||||
elif [ "$1" = "-h" ]; then
|
||||
_USAGE_
|
||||
else
|
||||
eval $(echo "_BLOCK_$1_ $2 $3")
|
||||
fi
|
58
manjaro/.config/mimeapps.list
Normal file
58
manjaro/.config/mimeapps.list
Normal file
@ -0,0 +1,58 @@
|
||||
[Default Applications]
|
||||
application/octet-stream=mousepad.desktop
|
||||
application/pdf=FoxitReader.desktop
|
||||
application/pdf=org.gnome.Evince.desktop
|
||||
application/x-gettext-translation=mousepad.desktop
|
||||
application/xml=mousepad.desktop
|
||||
application/x-wine-extension-ini=mousepad.desktop
|
||||
image/gif=viewnior.desktop;gimp.desktop
|
||||
image/gif=viewnior.desktop;gimp.desktop
|
||||
image/jpeg=viewnior.desktop;gimp.desktop
|
||||
image/png=viewnior.desktop;gimp.desktop
|
||||
text/plain=mousepad.desktop
|
||||
video/mp4=vlc.desktop
|
||||
video/ogg=vlc.desktop
|
||||
video/x-flv=vlc.desktop
|
||||
video/x-ms-wmv=vlc.desktop
|
||||
video/x-ogm+ogg=vlc.desktop
|
||||
video/x-theora+ogg=vlc.desktop
|
||||
application/ppdf=FoxitReader.desktop
|
||||
application/xfdf=FoxitReader.desktop
|
||||
application/fdf=FoxitReader.desktop
|
||||
x-scheme-handler/tg=userapp-Telegram Desktop-DQX5U0.desktop
|
||||
application/x-compressed-tar=engrampa.desktop
|
||||
application/x-tar=engrampa.desktop
|
||||
application/zip=engrampa.desktop
|
||||
text/html=firefox.desktop
|
||||
x-scheme-handler/http=firefox.desktop
|
||||
x-scheme-handler/https=firefox.desktop
|
||||
x-scheme-handler/about=firefox.desktop
|
||||
x-scheme-handler/unknown=firefox.desktop
|
||||
text/x-csrc=code-oss.desktop
|
||||
x-scheme-handler/eclipse+installer=_home_julian_Downloads_eclipse-installer_.desktop
|
||||
x-scheme-handler/eclipse+command x-scheme-handler/eclipse+mpc=_home_julian_eclipse_cpp-2021-03_eclipse_.desktop
|
||||
text/x-c++src=mousepad.desktop
|
||||
inode/directory=/usr/share/applications/thunar.desktop
|
||||
|
||||
[Added Associations]
|
||||
text/plain=wolfram-mathematica12.desktop;code-oss.desktop;libreoffice-writer.desktop;code-oss-url-handler.desktop;mousepad.desktop;
|
||||
application/pdf=qpdfview.desktop;com.github.xournalpp.xournalpp.desktop;code-oss.desktop;org.gnome.Evince.desktop;firefox.desktop;FoxitReader.desktop;libreoffice-draw.desktop;
|
||||
application/x-qw=libreoffice-startcenter.desktop;
|
||||
text/csv=libreoffice-calc.desktop;mousepad.desktop;
|
||||
application/zip=org.gnome.FileRoller.desktop;
|
||||
application/x-ms-dos-executable=wine.desktop;engrampa.desktop;
|
||||
image/png=gimp.desktop;
|
||||
image/jpeg=gimp.desktop;
|
||||
application/x-shellscript=mousepad.desktop;
|
||||
text/x-python=code-oss.desktop;
|
||||
application/x-perl=code-oss.desktop;
|
||||
font/ttf=org.gnome.font-viewer.desktop;
|
||||
application/vnd.appimage=unity-editor.desktop;
|
||||
x-scheme-handler/tg=userapp-Telegram Desktop-DQX5U0.desktop;
|
||||
text/x-tex=texstudio.desktop;
|
||||
application/x-compressed-tar=engrampa.desktop;
|
||||
application/x-tar=engrampa.desktop;
|
||||
text/x-c++src=nvim.desktop;mousepad.desktop;
|
||||
text/x-java=nvim.desktop;vim.desktop;
|
||||
text/x-csrc=code-oss.desktop;
|
||||
application/x-7z-compressed=mplayer.desktop;
|
Loading…
x
Reference in New Issue
Block a user