Spotify support for polybar

clean_emacs
TuDatTr 2018-03-08 01:13:52 +01:00
parent e6575b94c2
commit 709020c441
No known key found for this signature in database
GPG Key ID: 0DA1B0B23302CA72
8 changed files with 96 additions and 61 deletions

View File

@ -257,6 +257,27 @@ Globaly highlight the current line in a slightly darker shade of grey.
** Ledger ** Ledger
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(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.
'(ledger-reports
(quote
(("budget" "ledger -f MyBudget.ledger bal Brieftasche$ Girokonto$")
("bal" "%(binary) -f %(ledger-file) bal")
("reg" "%(binary) -f %(ledger-file) reg")
("payee" "%(binary) -f %(ledger-file) reg @%(payee)")
("account" "%(binary) -f %(ledger-file) reg %(account)"))))
'(package-selected-packages
(quote
(ledger-mode smartparens rainbow-mode rainbow-delimiters ox-twbs material-theme google-this flycheck eclim counsel auto-complete-auctex auto-complete auctex anaconda-mode use-package))))
(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.
)
#+END_SRC #+END_SRC

View File

@ -1,16 +1,2 @@
(package-initialize) (package-initialize)
(org-babel-load-file "~/.emacs.d/config.org") (org-babel-load-file "~/.emacs.d/config.org")
(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.
'(package-selected-packages
(quote
(ledger-mode smartparens rainbow-mode rainbow-delimiters ox-twbs material-theme google-this flycheck eclim counsel auto-complete-auctex auto-complete auctex anaconda-mode use-package))))
(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.
)

View File

@ -114,6 +114,7 @@ exec --no-startup-id emacs --daemon
exec --no-startup-id udiskie exec --no-startup-id udiskie
exec --no-startup-id polybar beep -r exec --no-startup-id polybar beep -r
exec --no-startup-id polybar boop -r exec --no-startup-id polybar boop -r
exec --no-startup-id setxkbmap -option "ctrl:swapcaps"
############################################################################### ###############################################################################
################################# Keybindings ################################# ################################# Keybindings #################################
############################################################################### ###############################################################################

1
i3/.scripts/playstate Normal file
View File

@ -0,0 +1 @@
1

24
i3/.scripts/spotify-play.py Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/python
import subprocess
import time
def main():
state = -1
while 1:
with open('/home/tuan/.scripts/playstate', 'r') as f:
try:
file_state = int(f.readline().strip('\n'))
except ValueError:
pass
if state != file_state:
state = file_state
if state == 0:
print("")
subprocess.run(["playerctl","pause"])
elif state == 1:
print("")
subprocess.run(["playerctl","play"])
time.sleep(0.5)
if __name__ == '__main__':
main()

View File

@ -29,16 +29,16 @@ background = #00000000
foreground = ${colors.foreground} foreground = ${colors.foreground}
module-margin-left = 1 module-margin-left = 1
module-margin-right = 10 module-margin-right = 1
font-0 = fixed:pixelsize=10;1 font-0 = fixed:pixelsize=10;1
font-1 = unifont:fontformat=truetype:size=8:antialias=false;0 font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
font-2 = siji:pixelsize=10;1 font-2 = siji:pixelsize=10;1
font-3 = FontAwesome:style=Regular:pixelsize=10 font-3 = FontAwesome:style=Regular:pixelsize=10
modules-left = mpd modules-left = spotify
modules-center = modules-center = spotify-prev spotify-play spotify-stop spotify-next
modules-right = xkeyboard volume xbacklight wlan eth battery modules-right = xkeyboard volume xbacklight wlan eth battery date
cursor-click = pointer cursor-click = pointer
cursor-scroll = ns-resize cursor-scroll = ns-resize
@ -55,6 +55,7 @@ background = ${colors.background}
foreground = ${colors.foreground} foreground = ${colors.foreground}
line-size = 0 line-size = 0
line-color = ${colors.blue} line-color = ${colors.blue}
border-size = 0 border-size = 0
@ -71,15 +72,15 @@ font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
font-2 = siji:pixelsize=10;1 font-2 = siji:pixelsize=10;1
font-3 = FontAwesome:style=Regular:pixelsize=10 font-3 = FontAwesome:style=Regular:pixelsize=10
modules-left = i3 modules-left =
modules-center = modules-center = i3
modules-right = date powermenu modules-right = powermenu
cursor-click = pointer cursor-click = pointer
cursor-scroll = ns-resize cursor-scroll = ns-resize
[module/xkeyboard] [module/xkeyboard]
type = internal/xkeyboard pptype = internal/xkeyboard
blacklist-0 = num lock blacklist-0 = num lock
format-prefix = " " format-prefix = " "
@ -94,6 +95,37 @@ label-indicator-margin = 1
label-indicator-background = ${colors.magenta} label-indicator-background = ${colors.magenta}
label-indicator-underline = ${colors.magenta} label-indicator-underline = ${colors.magenta}
[module/spotify]
type = custom/script
exec-if = pgrep -x spotify
exec = echo "$(playerctl metadata xesam:artist) - $(playerctl metadata xesam:title)"
[module/spotify-prev]
type = custom/script
exec-if = pgrep -x spotify
exec = echo ""
click-left = bash -c "playerctl previous"
[module/spotify-next]
type = custom/script
exec-if = pgrep -x spotify
exec = echo ""
click-left = bash -c "playerctl next"
[module/spotify-play]
type = custom/script
exec-if = pgrep -x spotify
exec = python -u /home/tuan/.scripts/spotify-play.py
tail = true
click-left = bash -c "if [ `cat /home/tuan/.scripts/playstate` = 0 ]; then echo '1'>/home/tuan/.scripts/playstate;else echo '0'>/home/tuan/.scripts/playstate;fi"
[module/spotify-stop]
type = custom/script
exec-if = pgrep -x spotify
exec = echo ""
tail = true
click-left = bash -c "playerctl stop && echo '0'>/home/tuan/.scripts/playstate"
[module/i3] [module/i3]
type = internal/i3 type = internal/i3
@ -122,7 +154,7 @@ ws-icon-5 = 6;
ws-icon-6 = 7; ws-icon-6 = 7;
ws-icon-7 = 8; ws-icon-7 = 8;
ws-icon-8 = 9; ws-icon-8 = 9;
ws-icon-default = \ ws-icon-default = 
format = <label-state> format = <label-state>
@ -148,35 +180,6 @@ label-urgent-foreground = ${colors.black}
label-urgent-background = ${colors.red} label-urgent-background = ${colors.red}
label-urgent-padding = 4 label-urgent-padding = 4
[module/mpd]
type = internal/mpd
format-online = <icon-prev> <icon-stop> <toggle> <icon-next> <icon-repeat> <icon-random> <bar-progress> <label-time> <label-song>
icon-prev = 
icon-stop = 
icon-play = 
icon-pause = 
icon-next = 
icon-random = 
icon-repeat = 
toggle-on-foreground =
toggle-on-background = #55
bar-progress-width = 45
bar-progress-format = %{A4:mpdseek+2: A5:mpdseek_2:}%fill%%indicator%%empty%%{A A}
bar-progress-indicator = |
bar-progress-indicator-foreground = #ff
bar-progress-indicator-font = 3
bar-progress-fill = ─
bar-progress-fill-foreground = #bb
bar-progress-fill-font = 3
bar-progress-empty = ─
bar-progress-empty-font = 3
bar-progress-empty-foreground = #44
[module/xbacklight] [module/xbacklight]
type = internal/xbacklight type = internal/xbacklight

View File

@ -1,8 +1,8 @@
[options] [options]
#allow_bold = true allow_bold = true
#audible_bell = false #audible_bell = false
#clickable_url = true #clickable_url = true
#dynamic_title = true dynamic_title = true
font = Dejavu Sans Mono 12 font = Dejavu Sans Mono 12
#fullscreen = true #fullscreen = true
#geometry = 640x480 #geometry = 640x480
@ -12,8 +12,8 @@ mouse_autohide = true
#scroll_on_keystroke = true #scroll_on_keystroke = true
# Length of the scrollback buffer, 0 disabled the scrollback buffer # Length of the scrollback buffer, 0 disabled the scrollback buffer
# and setting it to a negative value means "infinite scrollback" # and setting it to a negative value means "infinite scrollback"
scrollback_lines = 10000 scrollback_lines = -1
#search_wrap = true search_wrap = true
#urgent_on_bell = true #urgent_on_bell = true
hyperlinks = true hyperlinks = true
@ -21,7 +21,7 @@ hyperlinks = true
#browser = xdg-open #browser = xdg-open
# "system", "on" or "off" # "system", "on" or "off"
#cursor_blink = system cursor_blink = system
# "block", "underline" or "ibeam" # "block", "underline" or "ibeam"
cursor_shape = ibeam cursor_shape = ibeam
@ -45,7 +45,7 @@ scrollbar = off
foreground = #eceff1 foreground = #eceff1
foreground_bold = #eceff1 foreground_bold = #eceff1
cursor = #eceff1 cursor = #eceff1
background = rgba(38, 50, 56, 0.8) background = rgba(38, 50, 56, 0.7)
# black # black
color0 = #263238 color0 = #263238

View File

@ -24,7 +24,7 @@ POWERLEVEL9K_STATUS_ERROR_FOREGROUND="red"
POWERLEVEL9K_TIME_BACKGROUND="black" POWERLEVEL9K_TIME_BACKGROUND="black"
POWERLEVEL9K_TIME_FOREGROUND="color7" POWERLEVEL9K_TIME_FOREGROUND="color7"
POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S}" POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S}"
# Alias # Alias
alias df="df -h" alias df="df -h"
@ -37,8 +37,7 @@ alias -s cpp=e
alias org="e ~/Nextcloud/orgs/man.org" alias org="e ~/Nextcloud/orgs/man.org"
alias neofetch="neofetch --block_range 0 16" alias neofetch="neofetch --block_range 0 16"
alias diff="diff -s" alias diff="diff -s"
alias ebudget="e ~/Nextcloud/orgs/Budget/MyBudget.ledger" alias budget="e ~/Nextcloud/orgs/Budget/MyBudget.ledger"
alias budget="ledger -f ~/Nextcloud/orgs/Budget/MyBudget.ledger"
source $ZSH/oh-my-zsh.sh source $ZSH/oh-my-zsh.sh
# Variables # Variables