From f40c5304b83875dd6c9a220a7fc13e84c48551a7 Mon Sep 17 00:00:00 2001 From: CroLinuxGamer Date: Sun, 13 Dec 2020 12:51:52 +0100 Subject: [PATCH] Added my lemonbar config files. --- killlemonade | 4 ++ launchlemonade | 8 ++++ lemoncpu | 35 ++++++++++++++ lemoncpu-notify | 3 ++ lemonlight | 5 ++ lemonram-notify | 3 ++ lemonsong-status | 10 ++++ lemonvol | 14 ++++++ lemonvol.py | 30 ++++++++++++ panel-top | 122 +++++++++++++++++++++++++++++++++++++++++++++++ panel_bar-top | 106 ++++++++++++++++++++++++++++++++++++++++ panel_colors | 25 ++++++++++ 12 files changed, 365 insertions(+) create mode 100755 killlemonade create mode 100755 launchlemonade create mode 100755 lemoncpu create mode 100755 lemoncpu-notify create mode 100755 lemonlight create mode 100755 lemonram-notify create mode 100755 lemonsong-status create mode 100755 lemonvol create mode 100755 lemonvol.py create mode 100755 panel-top create mode 100755 panel_bar-top create mode 100755 panel_colors diff --git a/killlemonade b/killlemonade new file mode 100755 index 0000000..33dc0f7 --- /dev/null +++ b/killlemonade @@ -0,0 +1,4 @@ +#!/bin/sh + +killall lemonbar +killall panel-top diff --git a/launchlemonade b/launchlemonade new file mode 100755 index 0000000..2eece75 --- /dev/null +++ b/launchlemonade @@ -0,0 +1,8 @@ +#!/bin/sh + +pkill lemonbar +sleep 0.1 +pkill panel-top +sleep 0.1 + +panel-top diff --git a/lemoncpu b/lemoncpu new file mode 100755 index 0000000..5f180ff --- /dev/null +++ b/lemoncpu @@ -0,0 +1,35 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# Copyright 2014 Andreas Guldstrand +# +# Licensed under the terms of the GNU GPL v3, or any later version. + +use strict; +use utf8; +use Getopt::Long; + +# default values +my $cpu_usage = -1; +my $decimals = $ENV{DECIMALS} // 2; +my $label ="C "; + +# 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 () { + 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 +printf "${label}"; +printf "%.${decimals}f%%\n", $cpu_usage; + +exit 0; diff --git a/lemoncpu-notify b/lemoncpu-notify new file mode 100755 index 0000000..64e1a86 --- /dev/null +++ b/lemoncpu-notify @@ -0,0 +1,3 @@ +#!/bin/sh +notify-send "Biggest cpu hogs: +$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)" diff --git a/lemonlight b/lemonlight new file mode 100755 index 0000000..c5e23aa --- /dev/null +++ b/lemonlight @@ -0,0 +1,5 @@ +#!/bin/sh + +lightness=$(light -G | sed 's/\.[0-9]*//') + +printf "%s\n" "L $lightness%" diff --git a/lemonram-notify b/lemonram-notify new file mode 100755 index 0000000..8779d34 --- /dev/null +++ b/lemonram-notify @@ -0,0 +1,3 @@ +#!/bin/sh +notify-send "Biggest memory hogs: +$(ps axch -o cmd:15,%mem --sort=-%mem | head)" diff --git a/lemonsong-status b/lemonsong-status new file mode 100755 index 0000000..ccca862 --- /dev/null +++ b/lemonsong-status @@ -0,0 +1,10 @@ +#!/bin/sh + +status=$(mpc status | sed -n '/playing/p' | cut -c2-8 | sed 's/^[ \t]*//') + +if [ "$status" = "playing" ]; then # If song is playing + printf "%s\n" "S契" +else + printf "%s\n" "S" +fi + diff --git a/lemonvol b/lemonvol new file mode 100755 index 0000000..934a57d --- /dev/null +++ b/lemonvol @@ -0,0 +1,14 @@ +#!/bin/sh + +vol=$(pamixer --get-volume) +mute=$(pamixer --get-volume-human) + + icon=$(echo "奔") + +if [ "$mute" = "muted" ]; then + label=$(printf "mute \n") +else + label=$vol% +fi + +printf "%s\n" "V奔 $vol" diff --git a/lemonvol.py b/lemonvol.py new file mode 100755 index 0000000..f082d79 --- /dev/null +++ b/lemonvol.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +from pulsectl import Pulse, PulseLoopStop +import sys + +# Adapt to your use-case +sink_id = 0 + +with Pulse() as pulse: + def callback(ev): + if ev.index == sink_id: + raise PulseLoopStop + try: + pulse.event_mask_set('sink') + pulse.event_callback_set(callback) + last_value = round(pulse.sink_list()[sink_id].volume.value_flat * 100) + last_mute = pulse.sink_list()[sink_id].mute == 1 + while True: + pulse.event_listen() + value = round(pulse.sink_list()[sink_id].volume.value_flat * 100) + mute = pulse.sink_list()[sink_id].mute == 1 + if value != last_value or mute != last_mute: + if mute: + print('mute') + else: + print(value) + last_value = value + last_mute = mute + sys.stdout.flush() + except: + pass diff --git a/panel-top b/panel-top new file mode 100755 index 0000000..37767a6 --- /dev/null +++ b/panel-top @@ -0,0 +1,122 @@ +#!/bin/sh + +PANEL_FIFO=/tmp/panel-top-fifo +PANEL_HEIGHT=18 + +PANEL_FONT_FAMILY="JetBrains Mono Medium" +ICON_FONT2="IPAGothic" +ICON_FONT="SauceCodePro Nerd Font Mono" + +# setup +if [ $(pgrep -cx panel-top) -gt 1 ] ; then + printf "%s\n" "The panel is already running." >&2 + exit 1 +fi + +trap 'trap - TERM; kill 0' INT TERM QUIT EXIT + +[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO" +mkfifo "$PANEL_FIFO" + +bspc subscribe report > "$PANEL_FIFO" & +# find out how to make this scroll +xtitle -sf 'X%s\n\n' -t 30 > "$PANEL_FIFO" & + +# time and date +while true; +do + echo "D$(date '+%d.%m.%Y %H:%M:%S')" + sleep 1 +done > "$PANEL_FIFO" & + +# battery +while true; +do + for battery in /sys/class/power_supply/BAT? + do + mode=$(cat "$battery"/status) + percent=$(cat "$battery"/capacity) + symbol="" + + if [ "$mode" = "Discharging" ]; then + symbol='' + elif [ "$mode" = "Charging" ]; then + symbol='' + else + symbol='' + fi + + echo "B$symbol $percent%" + done + sleep 10 +done > "$PANEL_FIFO" & + +# backlight +lemonlight > "$PANEL_FIFO" & + +# cpu temp +while true; +do + temp=$(sensors | awk '/^Tdie:/ {print $2}') + echo "T $temp" + sleep 10 +done > "$PANEL_FIFO" & + +# wifi +while true; +do + for wifi in /sys/class/net/w* + do + state=$(cat "$wifi"/operstate) + + if [ "$state" = "up" ]; then # if connected + echo "N直  " + else + echo "N睊  " + fi + done + sleep 5 +done > "$PANEL_FIFO" & + +# volume +# initial volume +lemonvol > "$PANEL_FIFO" & +# python volume watcher +lemonvol.py > "$PANEL_FIFO" & + +# ram +while true; +do + mem=$(free -h --mega | awk '/^Mem:/ {print $3 "/" $2}') + + printf "%s\n" "R $mem" + sleep 10 +done > "$PANEL_FIFO" & + +# cpu +while true; +do + lemoncpu > "$PANEL_FIFO" + sleep 5 +done > "$PANEL_FIFO" & + +# mpc song status +lemonsong-status > "$PANEL_FIFO" & + +# mpc playing song +while true +do + song=$(mpc current) + printf "%s\n" "M $song" > "$PANEL_FIFO" + mpc idle player > /dev/null 2>&1 +done & + +. panel_colors + +cat "$PANEL_FIFO" | panel_bar-top | lemonbar -g x$PANEL_HEIGHT -o -1 -f "$PANEL_FONT_FAMILY"-8 -f "$ICON_FONT"-9 -f "$ICON_FONT2"-7 -F "$COLOR_FOREGROUND" -B "$COLOR_BACKGROUND" -u 2 | sh & + +sleep 1 +xdo above -t $(xdo id -n root) $(xdo id -n lemonbar) + +wait + diff --git a/panel_bar-top b/panel_bar-top new file mode 100755 index 0000000..d281551 --- /dev/null +++ b/panel_bar-top @@ -0,0 +1,106 @@ +#!/bin/sh + +. panel_colors + +num_mon=$(bspc query -M | wc -l) +PADDING=" " +SEP="|" + +while read -r line ; do + case $line in + R*) + #ram output + ram="%{U$COLOR_UNDERLINE}%{+u}%{A:lemonram-notify:}${line#?}%{A}%{-u}$PADDING" + ;; + C*) + #cpu output + cpu="%{U$COLOR_UNDERLINE}%{+u}%{A:lemoncpu-notify:}${line#?}%{A}%{-u}$PADDING" + ;; + S*) + # mpc song status + state="%{F$COLOR_OCCUPIED_UNDERLINE}${line#?}%{F-}$PADDING" + ;; + M*) + # mpc current song + song="%{F$COLOR_OCCUPIED_UNDERLINE}${line#?}%{F-}$PADDING" + ;; + X*) + # xtitle output + title="$PADDING%{F$COLOR_TITLE}${line#?}%{F-}" + ;; + D*) + #time and date output + date="%{U$COLOR_UNDERLINE}%{+u}${line#?}%{-u}" + ;; + B*) + # battery output + batt="%{U$COLOR_UNDERLINE}%{+u}${line#?}%{-u}$PADDING" + ;; + L*) + # backlight output + light="%{U$COLOR_UNDERLINE}%{+u}${line#?}%{-u}$PADDING" + ;; + T*) + # cpu temperature + temp="%{U$COLOR_UNDERLINE}%{+u}${line#?}%{-u}$PADDING" + ;; + N*) + # wifi output + wifi="%{U$COLOR_UNDERLINE}%{+u}${line#?}%{-u}$PADDING" + ;; + V*) + # volume output + vol="%{U$COLOR_UNDERLINE}%{+u}${line#?}%{-u}$PADDING" + ;; + W*) + # bspwm internal state + wm_infos="" + IFS=':' + set -- ${line#?} + while [ $# -gt 0 ] ; do + item=$1 + name=${item#?} + case $item in + M*) + # active monitor + if [ $num_mon -gt 1 ] ; then + wm_infos="$wm_infos $SEP%{F$COLOR_ACTIVE_MONITOR_FG}%{B$COLOR_FOCUSED_OCCUPIED_FG}$PADDING${name}$PADDING%{B-}%{F-} " + fi + ;; + m*) + # inactive monitor + if [ $num_mon -gt 1 ] ; then + wm_infos="$wm_infos $SEP%{F$COLOR_INACTIVE_MONITOR_FG}%{B$COLOR_INACTIVE_MONITOR_BG}$PADDING${name}$PADDING%{B-}%{F-} " + fi + ;; + O*) + # focused occupied desktop + wm_infos="${wm_infos}$SEP%{F$COLOR_FOCUSED_OCCUPIED_FG}%{B$COLOR_FOCUSED_OCCUPIED_BG}%{U$COLOR_UNDERLINE}%{+u}$PADDING${name}$PADDING%{-u}%{B-}%{F-}" + ;; + F*) + # focused free desktop + wm_infos="${wm_infos}$SEP%{F$COLOR_FOCUSED_FREE_FG}%{B$COLOR_FOCUSED_FREE_BG}%{U$COLOR_UNDERLINE}%{+u}$PADDING${name}$PADDING%{-u}%{B-}%{F-}" + ;; + U*) + # focused urgent desktop + wm_infos="${wm_infos}$SEP%{F$COLOR_FOCUSED_URGENT_FG}%{B$COLOR_FOCUSED_URGENT_BG}%{U$COLOR_UNDERLINE}%{+u}$PADDING${name}$PADDING%{-u}%{B-}%{F-}" + ;; + o*) + # occupied desktop + wm_infos="${wm_infos}$SEP%{F$COLOR_OCCUPIED_FG}%{B$COLOR_OCCUPIED_BG}%{A:bspc desktop -f ${name}:}%{U$COLOR_OCCUPIED_UNDERLINE}%{+u}$PADDING${name}$PADDING%{-u}%{A}%{B-}%{F-}" + ;; + f*) + # free desktop + wm_infos="${wm_infos}$SEP%{F$COLOR_FREE_FG}%{B$COLOR_FREE_BG}%{A:bspc desktop -f ${name}:}$PADDING${name}$PADDING%{A}%{B-}%{F-}" + ;; + u*) + # urgent desktop + wm_infos="${wm_infos}$SEP%{F$COLOR_URGENT_FG}%{B$COLOR_URGENT_BG}$PADDING${name}$PADDING%{B-}%{F-}" + ;; + esac + shift + done + ;; + esac + printf "%s\n" "%{l}${wm_infos}${SEP}${title}%{c}${song}${state}%{r}${temp}${cpu}${ram}${wifi}${vol}${light}${batt}${date}" +done diff --git a/panel_colors b/panel_colors new file mode 100755 index 0000000..6a8202c --- /dev/null +++ b/panel_colors @@ -0,0 +1,25 @@ +#!/bin/sh + +COLOR_FOREGROUND="#d8dee9" +COLOR_BACKGROUND="#2e3440" +COLOR_FOCUSED_OCCUPIED_BG="#3b4252" +COLOR_FOCUSED_OCCUPIED_FG="#d8dee9" +COLOR_ACTIVE_MONITOR_FG="#d8dee9" +COLOR_ACTIVE_MONITOR_BG="#3b4252" +COLOR_INACTIVE_MONITOR_FG="#d8dee9" +COLOR_INACTIVE_MONITOR_BG="#2e3440" +COLOR_FOCUSED_OCCUPIED_FG="#d8dee9" +COLOR_FOCUSED_OCCUPIED_BG="#3b4252" +COLOR_FOCUSED_FREE_FG="#d8dee9" +COLOR_FOCUSED_FREE_BG="#3b4252" +COLOR_FOCUSED_URGENT_FG="#2e3440" +COLOR_FOCUSED_URGENT_BG="#bf616a" +COLOR_OCCUPIED_FG="#d8dee9" +COLOR_OCCUPIED_BG="#2e3440" +COLOR_FREE_FG="#d8dee9" +COLOR_FREE_BG="#2e3440" +COLOR_URGENT_FG="#3b4252" +COLOR_URGENT_BG="#bf616a" +COLOR_UNDERLINE="#a3be8c" +COLOR_TITLE="#ebcb8b" +COLOR_OCCUPIED_UNDERLINE="#88c0d0"