aboutsummaryrefslogtreecommitdiff
path: root/.config/polybar/scripts
diff options
context:
space:
mode:
Diffstat (limited to '.config/polybar/scripts')
-rwxr-xr-x.config/polybar/scripts/bluetooth.sh12
-rwxr-xr-x.config/polybar/scripts/check-network.sh21
-rwxr-xr-x.config/polybar/scripts/check_updates.sh118
-rwxr-xr-x.config/polybar/scripts/cmus.sh39
-rwxr-xr-x.config/polybar/scripts/get_spotify_status.sh52
-rwxr-xr-x.config/polybar/scripts/menu.sh63
-rwxr-xr-x.config/polybar/scripts/menu.shsave63
-rwxr-xr-x.config/polybar/scripts/menu_full.sh65
-rwxr-xr-x.config/polybar/scripts/now-playing.sh217
-rwxr-xr-x.config/polybar/scripts/polybar_wrapper92
-rwxr-xr-x.config/polybar/scripts/popup-calendar.sh41
-rwxr-xr-x.config/polybar/scripts/rofi-power.sh45
-rwxr-xr-x.config/polybar/scripts/scroll_spotify_status.sh12
-rwxr-xr-x.config/polybar/scripts/sysmenu.sh40
-rwxr-xr-x.config/polybar/scripts/sysmenu.shsave40
-rwxr-xr-x.config/polybar/scripts/system-usb-mount.sh53
-rwxr-xr-x.config/polybar/scripts/toggle_bluetooth.sh8
17 files changed, 981 insertions, 0 deletions
diff --git a/.config/polybar/scripts/bluetooth.sh b/.config/polybar/scripts/bluetooth.sh
new file mode 100755
index 0000000..061604b
--- /dev/null
+++ b/.config/polybar/scripts/bluetooth.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]
+then
+ echo ""
+else
+ if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ]
+ then
+ echo ""
+ fi
+ echo ""
+fi
+
diff --git a/.config/polybar/scripts/check-network.sh b/.config/polybar/scripts/check-network.sh
new file mode 100755
index 0000000..dabe74c
--- /dev/null
+++ b/.config/polybar/scripts/check-network.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+count=0
+disconnected="睊"
+wireless_connected="直"
+ethernet_connected="泌"
+
+ID="$(ip link | awk '/state UP/ {print $2}')"
+
+while true; do
+ if (ping -c 1 archlinux.org || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) &>/dev/null; then
+ if [[ $ID == e* ]]; then
+ echo "$ethernet_connected" ; sleep 25
+ else
+ echo "$wireless_connected" ; sleep 25
+ fi
+ else
+ echo "$disconnected" ; sleep 0.5
+ fi
+done
+
diff --git a/.config/polybar/scripts/check_updates.sh b/.config/polybar/scripts/check_updates.sh
new file mode 100755
index 0000000..52e51a9
--- /dev/null
+++ b/.config/polybar/scripts/check_updates.sh
@@ -0,0 +1,118 @@
+
+#!/usr/bin/bash
+#
+# checkupdates: Safely print a list of pending updates.
+#
+# Copyright (c) 2013 Kyle Keen <keenerd@gmail.com>
+#
+# 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 2 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/>.
+#
+
+declare -r myname='checkupdates'
+declare -r myver='1.0.0'
+
+plain() {
+ (( QUIET )) && return
+ local mesg=$1; shift
+ printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1
+}
+
+msg() {
+ (( QUIET )) && return
+ local mesg=$1; shift
+ printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1
+}
+
+msg2() {
+ (( QUIET )) && return
+ local mesg=$1; shift
+ printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1
+}
+
+ask() {
+ local mesg=$1; shift
+ printf "${BLUE}::${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}" "$@" >&1
+}
+
+warning() {
+ local mesg=$1; shift
+ printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
+
+error() {
+ local mesg=$1; shift
+ printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+}
+
+# check if messages are to be printed using color
+unset ALL_OFF BOLD BLUE GREEN RED YELLOW
+if [[ -t 2 && ! $USE_COLOR = "n" ]]; then
+ # prefer terminal safe colored and bold text when tput is supported
+ if tput setaf 0 &>/dev/null; then
+ ALL_OFF="$(tput sgr0)"
+ BOLD="$(tput bold)"
+ BLUE="${BOLD}$(tput setaf 4)"
+ GREEN="${BOLD}$(tput setaf 2)"
+ RED="${BOLD}$(tput setaf 1)"
+ YELLOW="${BOLD}$(tput setaf 3)"
+ else
+ ALL_OFF="\e[1;0m"
+ BOLD="\e[1;1m"
+ BLUE="${BOLD}\e[1;34m"
+ GREEN="${BOLD}\e[1;32m"
+ RED="${BOLD}\e[1;31m"
+ YELLOW="${BOLD}\e[1;33m"
+ fi
+fi
+readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
+
+
+if (( $# > 0 )); then
+ echo "${myname} v${myver}"
+ echo
+ echo "Safely print a list of pending updates"
+ echo
+ echo "Usage: ${myname}"
+ echo
+ echo 'Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database.'
+ exit 0
+fi
+
+if ! type -P fakeroot >/dev/null; then
+ error 'Cannot find the fakeroot binary.'
+ exit 1
+fi
+
+if [[ -z $CHECKUPDATES_DB ]]; then
+ CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/"
+fi
+
+trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT
+
+DBPath="$(pacman-conf DBPath)"
+if [[ -z "$DBPath" ]] || [[ ! -d "$DBPath" ]]; then
+ DBPath="/var/lib/pacman/"
+fi
+
+mkdir -p "$CHECKUPDATES_DB"
+ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null
+if ! fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null; then
+ error 'Cannot fetch updates'
+ exit 1
+fi
+pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]'
+
+exit 0
+
+# vim: set noet:
diff --git a/.config/polybar/scripts/cmus.sh b/.config/polybar/scripts/cmus.sh
new file mode 100755
index 0000000..2f42c63
--- /dev/null
+++ b/.config/polybar/scripts/cmus.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+prepend_zero () {
+ seq -f "%02g" $1 $1
+}
+
+artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-))
+
+if [[ $artist = *[!\ ]* ]]; then
+ song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-))
+ position=$(cmus-remote -C status | grep position | cut -c 10-)
+ minutes1=$(prepend_zero $(($position / 60)))
+ seconds1=$(prepend_zero $(($position % 60)))
+ duration=$(cmus-remote -C status | grep duration | cut -c 10-)
+ minutes2=$(prepend_zero $(($duration / 60)))
+ seconds2=$(prepend_zero $(($duration % 60)))
+ echo -n "$artist - $song "
+else
+ echo
+fi
+
+#prepend_zero () {
+# seq -f "%02g" $1 $1
+#}
+#
+#artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-))
+#
+#if [[ $artist = *[!\ ]* ]]; then
+# song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-))
+# position=$(cmus-remote -C status | grep position | cut -c 10-)
+# minutes1=$(prepend_zero $(($position / 60)))
+# seconds1=$(prepend_zero $(($position % 60)))
+# duration=$(cmus-remote -C status | grep duration | cut -c 10-)
+# minutes2=$(prepend_zero $(($duration / 60)))
+# seconds2=$(prepend_zero $(($duration % 60)))
+# echo -n "$artist - $song [$minutes1:$seconds1/$minutes2:$seconds2]"
+#else
+# echo
+#fi
diff --git a/.config/polybar/scripts/get_spotify_status.sh b/.config/polybar/scripts/get_spotify_status.sh
new file mode 100755
index 0000000..f04400d
--- /dev/null
+++ b/.config/polybar/scripts/get_spotify_status.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+# The name of polybar bar which houses the main spotify module and the control modules.
+PARENT_BAR="now-playing"
+PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1)
+
+# Set the source audio player here.
+# Players supporting the MPRIS spec are supported.
+# Examples: spotify, vlc, chrome, mpv and others.
+# Use `playerctld` to always detect the latest player.
+# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
+#PLAYER="spotify"
+PLAYER="playerctld"
+
+# Format of the information displayed
+# Eg. {{ artist }} - {{ album }} - {{ title }}
+# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
+FORMAT="{{ title }} - {{ artist }}"
+
+# Sends $2 as message to all polybar PIDs that are part of $1
+update_hooks() {
+ while IFS= read -r id
+ do
+ polybar-msg -p "$id" hook spotify-play-pause $2 1>/dev/null 2>&1
+ done < <(echo "$1")
+}
+
+PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
+EXIT_CODE=$?
+
+if [ $EXIT_CODE -eq 0 ]; then
+ STATUS=$PLAYERCTL_STATUS
+else
+ STATUS="No player is running"
+fi
+
+if [ "$1" == "--status" ]; then
+ echo "$STATUS"
+else
+ if [ "$STATUS" = "Stopped" ]; then
+ echo "No music is playing"
+ elif [ "$STATUS" = "Paused" ]; then
+ update_hooks "$PARENT_BAR_PID" 2
+ playerctl --player=$PLAYER metadata --format "$FORMAT"
+ elif [ "$STATUS" = "No player is running" ]; then
+ echo ""
+ else
+ update_hooks "$PARENT_BAR_PID" 1
+ playerctl --player=$PLAYER metadata --format "$FORMAT"
+ fi
+fi
+
diff --git a/.config/polybar/scripts/menu.sh b/.config/polybar/scripts/menu.sh
new file mode 100755
index 0000000..93f3779
--- /dev/null
+++ b/.config/polybar/scripts/menu.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+# Custom Rofi Script
+
+BORDER="#1F1F1F"
+SEPARATOR="#1F1F1F"
+FOREGROUND="#A9ABB0"
+BACKGROUND="#1F1F1F"
+BACKGROUND_ALT="#252525"
+HIGHLIGHT_BACKGROUND="#FF6F00"
+HIGHLIGHT_FOREGROUND="#FFFFFF"
+
+BLACK="#000000"
+WHITE="#ffffff"
+RED="#e53935"
+GREEN="#43a047"
+YELLOW="#fdd835"
+BLUE="#1e88e5"
+MAGENTA="#00897b"
+CYAN="#00acc1"
+PINK="#d81b60"
+PURPLE="#8e24aa"
+INDIGO="#3949ab"
+TEAL="#00897b"
+LIME="#c0ca33"
+AMBER="#ffb300"
+ORANGE="#fb8c00"
+BROWN="#6d4c41"
+GREY="#757575"
+BLUE_GREY="#546e7a"
+DEEP_PURPLE="#5e35b1"
+DEEP_ORANGE="#f4511e"
+LIGHT_BLUE="#039be5"
+LIGHT_GREEN="#7cb342"
+
+# Launch Rofi
+rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true \
+-hide-sidebar-mode true \
+-bw 0 \
+-lines 15 \
+-line-padding 10 \
+-padding 0 \
+-width 20 \
+-xoffset 7 -yoffset 28 \
+-location 1 \
+-columns 1 \
+-show-icons -icon-theme "Papirus" \
+-color-enabled true \
+-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \
+-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \
+-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \
+-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND"
+#rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true -sidebar-mode false -bw 0 -lines 6 -line-padding 10 -padding 20 -width 30 -xoffset 7 -yoffset 25 -location 1 -columns 2 -show-icons -icon-theme "Papirus"
+
+# More Options
+# -fullscreen \
+
+# Theming help
+# color window = background, border, separator
+# color normal = background, foreground, background-alt, highlight-background, highlight-foreground
+# color active = background, foreground, background-alt, highlight-background, highlight-foreground
+# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground
+
diff --git a/.config/polybar/scripts/menu.shsave b/.config/polybar/scripts/menu.shsave
new file mode 100755
index 0000000..ea5bf8e
--- /dev/null
+++ b/.config/polybar/scripts/menu.shsave
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+# Custom Rofi Script
+
+BORDER="#1F1F1F"
+SEPARATOR="#1F1F1F"
+FOREGROUND="#A9ABB0"
+BACKGROUND="#1F1F1F"
+BACKGROUND_ALT="#252525"
+HIGHLIGHT_BACKGROUND="#FF6F00"
+HIGHLIGHT_FOREGROUND="#FFFFFF"
+
+BLACK="#000000"
+WHITE="#ffffff"
+RED="#e53935"
+GREEN="#43a047"
+YELLOW="#fdd835"
+BLUE="#1e88e5"
+MAGENTA="#00897b"
+CYAN="#00acc1"
+PINK="#d81b60"
+PURPLE="#8e24aa"
+INDIGO="#3949ab"
+TEAL="#00897b"
+LIME="#c0ca33"
+AMBER="#ffb300"
+ORANGE="#fb8c00"
+BROWN="#6d4c41"
+GREY="#757575"
+BLUE_GREY="#546e7a"
+DEEP_PURPLE="#5e35b1"
+DEEP_ORANGE="#f4511e"
+LIGHT_BLUE="#039be5"
+LIGHT_GREEN="#7cb342"
+
+# Launch Rofi
+rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar false \
+-hide-sidebar-mode true \
+-bw 0 \
+-lines 15 \
+-line-padding 10 \
+-padding 0 \
+-width 20 \
+-xoffset 7 -yoffset 28 \
+-location 1 \
+-columns 1 \
+-show-icons -icon-theme "Papirus" \
+-color-enabled true \
+-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \
+-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \
+-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \
+-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND"
+#rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true -sidebar-mode false -bw 0 -lines 6 -line-padding 10 -padding 20 -width 30 -xoffset 7 -yoffset 25 -location 1 -columns 2 -show-icons -icon-theme "Papirus"
+
+# More Options
+# -fullscreen \
+
+# Theming help
+# color window = background, border, separator
+# color normal = background, foreground, background-alt, highlight-background, highlight-foreground
+# color active = background, foreground, background-alt, highlight-background, highlight-foreground
+# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground
+
diff --git a/.config/polybar/scripts/menu_full.sh b/.config/polybar/scripts/menu_full.sh
new file mode 100755
index 0000000..9f898a4
--- /dev/null
+++ b/.config/polybar/scripts/menu_full.sh
@@ -0,0 +1,65 @@
+
+#!/bin/bash
+
+# Custom Rofi Script
+
+BORDER="#1F1F1F"
+SEPARATOR="#1F1F1F"
+FOREGROUND="#A9ABB0"
+BACKGROUND="#1F1F1F"
+BACKGROUND_ALT="#252525"
+HIGHLIGHT_BACKGROUND="#FF6F00"
+HIGHLIGHT_FOREGROUND="#FFFFFF"
+
+BLACK="#000000"
+WHITE="#ffffff"
+RED="#e53935"
+GREEN="#43a047"
+YELLOW="#fdd835"
+BLUE="#1e88e5"
+MAGENTA="#00897b"
+CYAN="#00acc1"
+PINK="#d81b60"
+PURPLE="#8e24aa"
+INDIGO="#3949ab"
+TEAL="#00897b"
+LIME="#c0ca33"
+AMBER="#ffb300"
+ORANGE="#fb8c00"
+BROWN="#6d4c41"
+GREY="#757575"
+BLUE_GREY="#546e7a"
+DEEP_PURPLE="#5e35b1"
+DEEP_ORANGE="#f4511e"
+LIGHT_BLUE="#039be5"
+LIGHT_GREEN="#7cb342"
+
+# Launch Rofi
+rofi -no-lazy-grab -show drun \
+-display-drun "Applications " -drun-display-format "{name}" \
+-hide-scrollbar true \
+-bw 0 \
+-lines 10 \
+-line-padding 15 \
+-padding 60 \
+-width 30 \
+-xoffset 10 -yoffset 40 \
+-location 1 \
+-fullscreen \
+-columns 4 \
+-show-icons -icon-theme "Papirus" \
+-font "Fantasque Sans Mono 10" \
+-color-enabled true \
+-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \
+-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \
+-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \
+-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND"
+
+# More Options
+# -fullscreen \
+
+# Theming help
+# color window = background, border, separator
+# color normal = background, foreground, background-alt, highlight-background, highlight-foreground
+# color active = background, foreground, background-alt, highlight-background, highlight-foreground
+# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground
diff --git a/.config/polybar/scripts/now-playing.sh b/.config/polybar/scripts/now-playing.sh
new file mode 100755
index 0000000..8fa6000
--- /dev/null
+++ b/.config/polybar/scripts/now-playing.sh
@@ -0,0 +1,217 @@
+#!/usr/bin/env python3
+import dbus
+import signal
+import time
+from unicodedata import east_asian_width
+
+# Config options
+
+# (int) : Length of media info string. If length of string exceedes this value, the text will scroll. Default value is 20
+message_display_len = 20
+
+# (int) : Font index of polybar. this value should be 1 more than the font value specified in polybar config.
+font_index = 1
+
+# (float) : Update speed of the text in seconds.
+update_delay = 0.3
+
+# (list) : list of chars containing previous, play, pause, next glyphs for media controls in respective order
+control_chars = ['','','','']
+
+# (dict) : dict of char icons to display as prefix.
+# If player name is available as key, then use the corressponding icon,
+# else default key value.
+# example:
+display_player_prefix = {
+ "spotify": ' ',
+ "firefox": ' ',
+ "default": ' '
+}
+
+# (list) : list of metadata fields based on mpris sepecification.
+# For more details/ field names, refer [mpris sepecification](https://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/)
+metadata_fields = ["xesam:title", "xesam:artist"]
+
+# (char) : separator for metadata fields
+metadata_separator = "-"
+
+# (bool) : Hide text when no player is available? True disables the output for no players.
+hide_output = False
+
+# Defult initialization
+current_player = None
+player_names = None
+players = None
+message = None
+display_text = ""
+display_prefix = " "
+display_suffix = ""
+last_player_name = None
+
+session_bus = dbus.SessionBus()
+
+def get_name(player_name ):
+ if player_name not in player_names:
+ return
+ name = ".".join(player_name.split(".")[3:])
+ return name
+
+def get_name_by_index(index):
+ if index >= len(player_names):
+ return
+ return get_name(player_names[index])
+
+def get_status(player):
+ status = ""
+ try:
+ status = player.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus', dbus_interface='org.freedesktop.DBus.Properties')
+ except Exception as e:
+ pass
+ return status
+
+def get_metadata(player):
+ metadata = {}
+ try:
+ metadata = player.Get('org.mpris.MediaPlayer2.Player', 'Metadata', dbus_interface='org.freedesktop.DBus.Properties')
+ except Exception as e:
+ pass
+ return metadata
+
+def update_prefix_suffix(player_name="", status=""):
+ global display_prefix, display_suffix, status_paused
+
+ player_option = ""
+ if player_name != "":
+ player_option = "-p " + player_name
+
+ prev_button = "%%{A:playerctl %s previous :}%c%%{A}" %(player_option,control_chars[0])
+ play_button = "%%{A:playerctl %s play :}%c%%{A}" %(player_option,control_chars[1])
+ pause_button = "%%{A:playerctl %s pause :}%c%%{A}" %(player_option,control_chars[2])
+ next_button = "%%{A:playerctl %s next :}%c%%{A}" %(player_option,control_chars[3])
+
+ suffix = "| " + prev_button
+ if status == "Playing":
+ suffix += " "+pause_button
+ status_paused = False
+ else:
+ suffix += " "+play_button
+ status_paused = True
+ suffix += " "+next_button
+ # print(suffix)
+ display_suffix = suffix
+
+ for key in display_player_prefix.keys():
+ if key in player_name:
+ display_prefix = display_player_prefix[key]
+ break
+ else:
+ display_prefix = display_player_prefix["default"]
+
+def update_players():
+ global player_names, players, session_bus, current_player, last_player_name
+ player_names = [service for service in session_bus.list_names() if service.startswith('org.mpris.MediaPlayer2.')]
+ players = [session_bus.get_object(service, '/org/mpris/MediaPlayer2') for service in player_names]
+ if last_player_name != get_name(current_player):
+ for index, player in enumerate(player_names):
+ if get_name(player) == last_player_name:
+ current_player = index
+
+def handle_event(*args):
+ global current_player, players, last_player_name
+ update_players()
+ if len(players) == 0:
+ return
+ current_player += 1
+ current_player %= len(players)
+ last_player_name = getname_by_index(current_player)
+# print("SIGUSR1: updated values - current_player = %d players len = %d"%(current_player,len(players)))
+
+def update_message():
+ global players, current_player,player_names, message, display_text, message_display_len, display_suffix, last_player_name
+ if len(players) == 0:
+ tmp_message = "No player available"
+ update_prefix_suffix()
+ else:
+ name = get_name_by_index(current_player)
+ status = get_status(players[current_player])
+ metadata_obj = get_metadata(players[current_player])
+ metadata_string_list = []
+ for field in metadata_fields:
+ result = metadata_obj.get(field)
+ if type(result) == dbus.Array:
+ result = result[0]
+ if not result:
+ result = "No "+field.split(":")[1]
+ metadata_string_list.append(str(result))
+ metadata_string = (" "+metadata_separator+" ").join(metadata_string_list)
+ if visual_len(metadata_string) > message_display_len:
+ metadata_string = " " + metadata_string + " |"
+ update_prefix_suffix(name,status)
+ tmp_message = ""
+ if metadata_string:
+ tmp_message += str(metadata_string)
+ last_player_name = name
+ if message != tmp_message:
+ message = tmp_message
+ display_text = message
+
+def scroll():
+ global display_text, message_display_len, status_paused
+ if not status_paused:
+ if len(display_text) > message_display_len:
+ display_text = display_text[1:] + display_text[0]
+ elif len(display_text) < message_display_len:
+ display_text += " "*(message_display_len - len(display_text))
+
+def visual_len(text):
+ visual_length = 0
+ for ch in text:
+ width = east_asian_width(ch)
+ if width == 'W' or width == 'F':
+ visual_length += 1
+ visual_length += 1
+ return visual_length
+
+def make_visual_len(text, visual_desired_length):
+ visual_length = 0
+ altered_text = ''
+ for char in text:
+ if visual_length < visual_desired_length:
+ width = east_asian_width(char)
+ if width == 'W' or width == 'F':
+ visual_length += 2
+ else:
+ visual_length += 1
+ altered_text += char
+ else:
+ break
+ if visual_length == visual_desired_length + 1:
+ altered_text = altered_text[:-1] + ' '
+ elif visual_length < visual_desired_length:
+ altered_text += ' ' * (visual_desired_length - visual_length)
+ return altered_text
+
+def print_text():
+ global display_text, message_display_len, players, player_names, display_prefix, display_suffix
+ if hide_output and len(players)==0:
+ print("", flush = True)
+ return
+ scroll()
+ print(display_prefix + " " +
+ "%%{T%d}" % (font_index) +
+ make_visual_len(display_text, message_display_len) +
+ "%{T-}" + display_suffix, flush=True)
+
+def main():
+ global current_player, players
+ update_players()
+ current_player = 0
+ while True:
+ time.sleep(update_delay)
+ update_players()
+ update_message()
+ print_text()
+
+if __name__ == '__main__':
+ signal.signal(signal.SIGUSR1, handle_event)
+ main()
diff --git a/.config/polybar/scripts/polybar_wrapper b/.config/polybar/scripts/polybar_wrapper
new file mode 100755
index 0000000..901bb28
--- /dev/null
+++ b/.config/polybar/scripts/polybar_wrapper
@@ -0,0 +1,92 @@
+#!/bin/bash
+
+DIR=$(dirname $(realpath $0))
+
+WINDOW_ID_CONKY=/tmp/conky_window_id
+WINDOW_ID_TOP=/tmp/polybar_top_window_id
+WINDOW_ID_EXPANDED=/tmp/polybar_expanded_window_id
+
+conky_launch() {
+ # Hacky X11 magic to make Conky appear above polybar
+ killall conky
+ # xdotool search can't find Conky's window but fortunately Conky outputs it
+ conky -c ~/.config/conky/config 2> /tmp/conky_out
+ # Extract the hex window id from Conky's output
+ HEX=$(awk '/drawing to created window/ {print $NF}' /tmp/conky_out | tr -d '()' | awk -Fx '{print $2}')
+ WIN_ID=$(( 16#$HEX )) # convert to decimal
+ xdotool windowunmap $WIN_ID
+ echo $WIN_ID > $WINDOW_ID_CONKY
+}
+
+polybar_launch() {
+ killall polybar
+
+ polybar top &
+ xdotool search --sync --pid $! > $WINDOW_ID_TOP
+
+ polybar expanded &
+ xdotool search --sync --pid $! > $WINDOW_ID_EXPANDED
+
+ bar_collapse
+}
+
+launch() {
+ # Temporarily disable conky until I update the config
+ # conky_launch
+ # sleep 0.2
+ polybar_launch
+}
+
+bar_expand() {
+ xdotool windowmap $(cat $WINDOW_ID_EXPANDED)
+ xdotool windowunmap $(cat $WINDOW_ID_TOP)
+}
+
+bar_collapse() {
+ xdotool windowunmap $(cat $WINDOW_ID_EXPANDED)
+ xdotool windowmap $(cat $WINDOW_ID_TOP)
+}
+
+rofi_open() {
+ options_close
+ bar_expand &
+ rofi -modi run -show run
+ bar_collapse
+}
+
+drun_open() {
+ bar_expand &
+ rofi -theme drun -modi drun -show drun -drun-categories Custom
+ bar_collapse
+}
+
+search_open() {
+ options_close
+ bar_expand &
+ rofi -theme window -modi window -show window
+ bar_collapse
+}
+
+options_open() {
+ bar_expand
+ $DIR/rofi_option_menu
+ bar_collapse
+ # echo "open" > /tmp/polybar_side_panel_state
+ # ID_CONKY=$(cat $WINDOW_ID_CONKY)
+ # xdotool windowmap $ID_CONKY
+ # xdotool windowraise $ID_CONKY
+ # ~/.config/i3/scripts/music_player show_applet
+}
+
+case "$1" in
+ rofi)
+ rofi_open;;
+ search)
+ search_open;;
+ drun)
+ drun_open;;
+ options)
+ options_open;;
+ launch)
+ launch;;
+esac
diff --git a/.config/polybar/scripts/popup-calendar.sh b/.config/polybar/scripts/popup-calendar.sh
new file mode 100755
index 0000000..4e5303c
--- /dev/null
+++ b/.config/polybar/scripts/popup-calendar.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+BAR_HEIGHT=22 # polybar height
+BORDER_SIZE=1 # border size from your wm settings
+YAD_WIDTH=222 # 222 is minimum possible value
+YAD_HEIGHT=193 # 193 is minimum possible value
+DATE="$(date +"%a %d %b, %H:%M")"
+
+case "$1" in
+--popup)
+ if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then
+ exit 0
+ fi
+
+ eval "$(xdotool getmouselocation --shell)"
+ eval "$(xdotool getdisplaygeometry --shell)"
+
+ # X
+ if [ "$((X + YAD_WIDTH / 2 + BORDER_SIZE))" -gt "$WIDTH" ]; then #Right side
+ : $((pos_x = WIDTH - YAD_WIDTH - BORDER_SIZE))
+ elif [ "$((X - YAD_WIDTH / 2 - BORDER_SIZE))" -lt 0 ]; then #Left side
+ : $((pos_x = BORDER_SIZE))
+ else #Center
+ : $((pos_x = X - YAD_WIDTH / 2))
+ fi
+
+ # Y
+ if [ "$Y" -gt "$((HEIGHT / 2))" ]; then #Bottom
+ : $((pos_y = HEIGHT - YAD_HEIGHT - BAR_HEIGHT - BORDER_SIZE))
+ else #Top
+ : $((pos_y = BAR_HEIGHT + BORDER_SIZE))
+ fi
+
+ yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
+ --width="$YAD_WIDTH" --height="$YAD_HEIGHT" --posx="$pos_x" --posy="$pos_y" \
+ --title="yad-calendar" --borders=0 >/dev/null &
+ ;;
+*)
+ echo "$DATE"
+ ;;
+esac
diff --git a/.config/polybar/scripts/rofi-power.sh b/.config/polybar/scripts/rofi-power.sh
new file mode 100755
index 0000000..87ac92c
--- /dev/null
+++ b/.config/polybar/scripts/rofi-power.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env sh
+#
+# A rofi powered menu to execute power related action.
+# Uses: amixer mpc poweroff reboot rofi rofi-prompt
+
+power_off=''
+reboot=''
+lock=''
+suspend='鈴'
+log_out=''
+
+chosen=$(printf '%s;%s;%s;%s;%s\n' "$power_off" "$reboot" "$lock" "$suspend" \
+ "$log_out" \
+ | rofi -theme '~/.config/rofi/themes/power.rasi' \
+ -dmenu \
+ -sep ';' \
+ -selected-row 2)
+
+case "$chosen" in
+ "$power_off")
+ rofi-prompt --query 'Shutdown?' && poweroff
+ ;;
+
+ "$reboot")
+ rofi-prompt --query 'Reboot?' && reboot
+ ;;
+
+ "$lock")
+ # TODO Add your lockscreen command.
+ ;;
+
+ "$suspend")
+ # Pause music and mute volume before suspending.
+ mpc --quiet pause
+ amixer set Master mute
+ # TODO Add your suspend command.
+ ;;
+
+ "$log_out")
+ # TODO Add your log out command.
+ ;;
+
+ *) exit 1 ;;
+esac
+
diff --git a/.config/polybar/scripts/scroll_spotify_status.sh b/.config/polybar/scripts/scroll_spotify_status.sh
new file mode 100755
index 0000000..74e0bfd
--- /dev/null
+++ b/.config/polybar/scripts/scroll_spotify_status.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# see man zscroll for documentation of the following parameters
+zscroll -l 20 \
+ --delay 0.1 \
+ --scroll-padding " " \
+ --match-command "$HOME/.config/polybar/scripts/get_spotify_status.sh --status" \
+ --match-text "Playing" "--scroll 1" \
+ --match-text "Paused" "--scroll 0" \
+ --update-check true "$HOME/.config/polybar/scripts/get_spotify_status.sh" &
+
+wait
diff --git a/.config/polybar/scripts/sysmenu.sh b/.config/polybar/scripts/sysmenu.sh
new file mode 100755
index 0000000..721bc1d
--- /dev/null
+++ b/.config/polybar/scripts/sysmenu.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# display a power menu to: shutdown, reboot,
+# lock, logout, and suspend. This script can be
+# executed by clicking on the polybar powermenu module
+# or with a keyboard shortcut
+
+
+# options to be displayed
+shutdown=" Shutdown"
+reboot=" Reboot"
+lock=" Lock"
+logout=" Logout"
+suspend=" Suspend"
+
+uptime=$(uptime -p | sed -e 's/up //g')
+
+# options passed into variable
+options="$shutdown\n$reboot\n$lock\n$logout\n$suspend"
+
+chosen="$(echo -e "$options" | rofi -no-lazy-grab -sep -lines 5 -hide-scrollbar true -border 0 -padding 0 -height 2px -width 15 -xoffset -8 -yoffset 28 -location 3 -columns 1 -dmenu -p 'System ' "$uptime")"
+
+case $chosen in
+$shutdown)
+ systemctl poweroff
+ ;;
+$reboot)
+ systemctl reboot
+ ;;
+$lock)
+ betterlockscreen --lock dimblur
+ ;;
+$logout)
+ bspc quit
+ ;;
+$suspend)
+ systemctl suspend
+ ;;
+esac
+
diff --git a/.config/polybar/scripts/sysmenu.shsave b/.config/polybar/scripts/sysmenu.shsave
new file mode 100755
index 0000000..00ce125
--- /dev/null
+++ b/.config/polybar/scripts/sysmenu.shsave
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# display a power menu to: shutdown, reboot,
+# lock, logout, and suspend. This script can be
+# executed by clicking on the polybar powermenu module
+# or with a keyboard shortcut
+
+
+# options to be displayed
+shutdown=" Shutdown"
+reboot=" Reboot"
+lock=" Lock"
+logout=" Logout"
+suspend=" Suspend"
+
+uptime=$(uptime -p | sed -e 's/up //g')
+
+# options passed into variable
+options="$shutdown\n$reboot\n$lock\n$logout\n$suspend"
+
+chosen="$(echo -e "$options" | rofi -no-lazy-grab -sep -lines 5 -hide-scrollbar true -border 0 -padding 0 -height 2px -width 15 -xoffset -10 -yoffset 28 -location 3 -columns 1 -dmenu -p 'System ' "$uptime")"
+
+case $chosen in
+$shutdown)
+ systemctl poweroff
+ ;;
+$reboot)
+ systemctl reboot
+ ;;
+$lock)
+ betterlockscreen --lock dimblur
+ ;;
+$logout)
+ bspc quit
+ ;;
+$suspend)
+ systemctl suspend
+ ;;
+esac
+
diff --git a/.config/polybar/scripts/system-usb-mount.sh b/.config/polybar/scripts/system-usb-mount.sh
new file mode 100755
index 0000000..63e9187
--- /dev/null
+++ b/.config/polybar/scripts/system-usb-mount.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+devices=$(lsblk -Jplno NAME,TYPE,RM,SIZE,MOUNTPOINT,VENDOR)
+
+case "$1" in
+ --mount)
+ for mount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do
+ udisksctl mount --no-user-interaction -b "$mount"
+
+ mountpoint=$(udisksctl mount --no-user-interaction -b $mount)
+ mountpoint=$(echo $mountpoint | cut -d " " -f 4- | tr -d ".")
+ kitty -e "bash -lc 'pcmanfm $mountpoint'" &
+ done
+ ;;
+ --unmount)
+ for unmount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .name'); do
+ udisksctl unmount --no-user-interaction -b "$unmount"
+ udisksctl power-off --no-user-interaction -b "$unmount"
+ done
+ ;;
+ *)
+ output=""
+ counter=0
+
+ for unmounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do
+ unmounted=$(echo "$unmounted" | tr -d "[:digit:]")
+ unmounted=$(echo "$devices" | jq -r '.blockdevices[] | select(.name == "'"$unmounted"'") | .vendor')
+ unmounted=$(echo "$unmounted" | tr -d ' ')
+
+ if [ $counter -eq 0 ]; then
+ space=""
+ else
+ space=" "
+ fi
+ counter=$((counter + 1))
+
+ output="$output$space#1 $unmounted"
+ done
+
+ for mounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .size'); do
+ if [ $counter -eq 0 ]; then
+ space=""
+ else
+ space=" "
+ fi
+ counter=$((counter + 1))
+
+ output="$output$space#2 $mounted"
+ done
+
+ echo "$output"
+ ;;
+esac
diff --git a/.config/polybar/scripts/toggle_bluetooth.sh b/.config/polybar/scripts/toggle_bluetooth.sh
new file mode 100755
index 0000000..899d5ec
--- /dev/null
+++ b/.config/polybar/scripts/toggle_bluetooth.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]
+then
+ bluetoothctl power on
+else
+ bluetoothctl power off
+fi
+