Switched to using spotify and other minor fixes

This commit is contained in:
Jesper Fussing Mørk 2019-02-15 14:23:02 +01:00
parent 3e8e5b42d3
commit 501b0dbbb7
9 changed files with 164 additions and 28 deletions

View File

@ -181,8 +181,10 @@ alias tdc="cd /home/jfm/Customers/TDC"
alias prod="ssh -fN sochi" alias prod="ssh -fN sochi"
alias top="htop" alias top="htop"
alias ssh="TERM=xterm-256color ssh" alias ssh="TERM=xterm-256color ssh"
alias vim="nvr -s --remote" alias rvim="nvr -s --remote"
alias vim="nvim"
alias vi="nvim" alias vi="nvim"
alias k9s="/home/jfm/Tools/k9s/k9s"
alias buildtool="/home/jfm/.buildtool/bin/buildtool" alias buildtool="/home/jfm/.buildtool/bin/buildtool"
alias vpnup="nmcli con up id \"YouSee VPN\"" alias vpnup="nmcli con up id \"YouSee VPN\""
alias vpndown="nmcli con down id \"YouSee VPN\"" alias vpndown="nmcli con down id \"YouSee VPN\""

View File

@ -125,7 +125,7 @@
# %n progress value if set without any extra characters # %n progress value if set without any extra characters
# %% Literal % # %% Literal %
# Markup is allowed # Markup is allowed
format = "<b>%a</b>\n%b" format = "<b>%a</b>\n%b\n%s"
# Alignment of message text. # Alignment of message text.
# Possible values are "left", "center" and "right". # Possible values are "left", "center" and "right".

View File

@ -51,6 +51,11 @@ bindsym Print exec --no-startup-id scrot '%Y-%m-%d_$wx$h_scrot.png' -e 'mv $f ~/
bindsym $mod+Print --release exec --no-startup-id scrot -u '%Y-%m-%d_$wx$h_scrot.png' -e 'mv $f ~/Pictures/screenshots/' bindsym $mod+Print --release exec --no-startup-id scrot -u '%Y-%m-%d_$wx$h_scrot.png' -e 'mv $f ~/Pictures/screenshots/'
bindsym $mod+Shift+Print --release exec --no-startup-id scrot -s '%Y-%m-%d_$wx$h_scrot.png' -e 'mv $f ~/Pictures/screenshots/' bindsym $mod+Shift+Print --release exec --no-startup-id scrot -s '%Y-%m-%d_$wx$h_scrot.png' -e 'mv $f ~/Pictures/screenshots/'
# Music Control
bindsym $mod+Ctrl+Mod1+9 exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
bindsym $mod+Ctrl+Mod1+0 exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"
bindsym $mod+Ctrl+Mod1+8 exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous"
# focus_follows_mouse no # focus_follows_mouse no
# alternatively, you can use the cursor keys: # alternatively, you can use the cursor keys:
@ -158,11 +163,12 @@ bindsym $mod+Ctrl+9 exec --no-startup-id ~/.config/i3/workspaces/ws09.sh
bindsym $mod+Ctrl+0 exec --no-startup-id ~/.config/i3/workspaces/ws00.sh bindsym $mod+Ctrl+0 exec --no-startup-id ~/.config/i3/workspaces/ws00.sh
# Open specific applications in floating mode # Open specific applications in floating mode
for_window [class="^.*"] border pixel 0 for_window [class="^.*"] border pixel 2
for_window [class="Nitrogen"] floating enable sticky enable border none for_window [class="Nitrogen"] floating enable sticky enable border none
for_window [class="feh"] floating enable sticky enable border none for_window [class="feh"] floating enable sticky enable border none
for_window [class="mpv"] floating enable sticky enable border none for_window [class="mpv"] floating enable sticky enable border none
for_window [class="Arandr"] floating enable sticky enable border none for_window [class="Arandr"] floating enable sticky enable border none
for_window [class="Sms.py"] floating enable sticky enable border none
#for_window [class="^jetbrains-.+"][window_type=dialog] focus #for_window [class="^jetbrains-.+"][window_type=dialog] focus
#for_window [instance="sun-awt-X11-XWindowPeer"] border pixel 0 #for_window [instance="sun-awt-X11-XWindowPeer"] border pixel 0
@ -176,10 +182,11 @@ bindsym $mod+Shift+r restart
bindsym $mod+l exec --no-startup-id light-locker-command -l bindsym $mod+l exec --no-startup-id light-locker-command -l
# Autostart applications # Autostart applications
exec --no-startup-id compton --config /home/jfm/.config/compton/compton.conf #exec --no-startup-id compton --config /home/jfm/.config/compton/compton.conf
exec --no-startup-id nm-applet exec --no-startup-id nm-applet
exec --no-startup-id pasystray exec --no-startup-id pasystray
exec --no-startup-id light-locker exec --no-startup-id light-locker
exec --no-startup-id indicator-kdeconnect
# Color palette used for the terminal ( ~/.Xresources file ) # Color palette used for the terminal ( ~/.Xresources file )
# Colors are gathered based on the documentation: # Colors are gathered based on the documentation:
@ -214,10 +221,10 @@ set_from_resource $term_color15 color15
# Theme colors # Theme colors
# class border backgr. text indic. child_border # class border backgr. text indic. child_border
client.focused #556064 #556064 #80FFF9 #b58900 #b58900 client.focused #5E81AC #556064 #80FFF9 #b58900 #5E81AC
client.focused_inactive #2F3D44 #2F3D44 #1ABC9C #454948 client.focused_inactive #2E3440 #2E3440 #1ABC9C #454948
client.unfocused #2F3D44 #2F3D44 #1ABC9C #454948 client.unfocused #2E3440 #2E3440 #1ABC9C #454948
client.urgent #CB4B16 #FDF6E3 #1ABC9C #268BD2 client.urgent #2E3440 #FDF6E3 #1ABC9C #268BD2
client.placeholder #000000 #0c0c0c #ffffff #000000 client.placeholder #000000 #0c0c0c #ffffff #000000
client.background #2B2C2B client.background #2B2C2B

View File

@ -37,7 +37,7 @@
"y": 0 "y": 0
}, },
"name": "shell1", "name": "shell1",
"percent": 0.7, "percent": 0.5,
"swallows": [ "swallows": [
{ {
"class": "^Termite$", "class": "^Termite$",
@ -57,7 +57,7 @@
"y": 0 "y": 0
}, },
"name": "shell2", "name": "shell2",
"percent": 0.3, "percent": 0.5,
"swallows": [ "swallows": [
{ {
"class": "^Termite$", "class": "^Termite$",

View File

@ -90,7 +90,7 @@
"swallows": [ "swallows": [
{ {
"class": "^Termite$", "class": "^Termite$",
"title": "^ranger$" "title": "^shell2$"
} }
], ],
"type": "con" "type": "con"

View File

@ -7,14 +7,14 @@ then
i3-msg "workspace 4:; exec google-chrome-stable --proxy-pac-url=file:///home/jfm/Customers/TDC/Scripts/tdcproxy.js --no-default-browser-check --new-window" i3-msg "workspace 4:; exec google-chrome-stable --proxy-pac-url=file:///home/jfm/Customers/TDC/Scripts/tdcproxy.js --no-default-browser-check --new-window"
i3-msg "workspace 4:; exec termite -t vim -e 'nvr -s --remote' --hold" i3-msg "workspace 4:; exec termite -t vim -e 'nvr -s --remote' --hold"
i3-msg "workspace 4:; exec termite -t shell" i3-msg "workspace 4:; exec termite -t shell"
i3-msg "workspace 4:; exec termite -t ranger -e ~/.config/ranger/ranger.sh --hold" i3-msg "workspace 4:; exec termite -t shell2"
# i3-msg "workspace 4:; exec google-chrome-stable --app=http://netflix.com" # i3-msg "workspace 4:; exec google-chrome-stable --app=http://netflix.com"
i3-msg "workspace 4:; exec termite -t weechat -e weechat" i3-msg "workspace 4:; exec termite -t weechat -e weechat"
i3-msg "workspace 4:; move workspace to output $PRIMARY" i3-msg "workspace 4:; move workspace to output $PRIMARY"
else else
i3-msg "workspace 4:; append_layout ~/.config/i3/layouts/workspace4-work.json" i3-msg "workspace 4:; append_layout ~/.config/i3/layouts/workspace4-work.json"
i3-msg "workspace 4:; exec termite -t shell1" i3-msg "workspace 4:; exec termite -t shell1"
i3-msg "workspace 4:; exec termite -t shell2 -e ~/.config/ranger/ranger.sh --hold" i3-msg "workspace 4:; exec termite -t shell2"
i3-msg "workspace 4:; exec termite -t vim -e 'nvr -s --remote' --hold" i3-msg "workspace 4:; exec termite -t vim -e 'nvr -s --remote' --hold"
i3-msg "workspace 4:; move workspace to output $PRIMARY" i3-msg "workspace 4:; move workspace to output $PRIMARY"
fi fi

View File

@ -18,6 +18,8 @@ set rtp^=/usr/share/vim/vimfiles/
call plug#begin('~/.local/share/nvim/plugged') call plug#begin('~/.local/share/nvim/plugged')
Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes' Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'Valloric/YouCompleteMe' Plug 'Valloric/YouCompleteMe'
Plug 'vim-syntastic/syntastic' Plug 'vim-syntastic/syntastic'
Plug 'luochen1990/rainbow' Plug 'luochen1990/rainbow'
@ -28,6 +30,10 @@ Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets' Plug 'honza/vim-snippets'
Plug 'jonsmithers/vim-html-template-literals' Plug 'jonsmithers/vim-html-template-literals'
Plug 'pangloss/vim-javascript' Plug 'pangloss/vim-javascript'
Plug 'alvan/vim-closetag'
Plug 'shime/vim-livedown'
Plug 'w0rp/ale'
Plug 'ambv/black'
call plug#end() call plug#end()
colorscheme nord colorscheme nord
@ -39,7 +45,7 @@ let g:Powerline_symbols='unicode'
let g:airline_theme='nord' let g:airline_theme='nord'
"YCM "YCM
let mapleader = "," let mapleader = "½"
let g:ycm_server_python_interpreter = 'python3' let g:ycm_server_python_interpreter = 'python3'
let g:ycm_autoclose_preview_window_after_completion=1 let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_min_num_of_chars_for_completion=3 let g:ycm_min_num_of_chars_for_completion=3
@ -53,13 +59,27 @@ let g:syntastic_python_checkers = ['python']
let g:rainbow_active = 1 let g:rainbow_active = 1
" Ultisnips " Ultisnips
let g:UltiSnipsExpandTrigger="<C-Space>" let g:UltiSnipsExpandTrigger="<c-v>"
let g:UltiSnipsJumpForwardTrigger="<c-b>" let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" NerdTree
map <M-1> :NERDTreeToggle<CR>
let g:NERDTreeWinSize=40
let NERDTreeShowBookmarks=1
let NERDTreeMinimalUI=1
" HTML " HTML
let g:closetag_filenames = '*.html,*.js'
let g:html_indent_style1 = "inc" let g:html_indent_style1 = "inc"
" LiveDown
let g:livedown_browser = '"google-chrome-stable --new-window --app=http://localhost:1337"'
nmap gm :LivedownToggle<CR>
" Black
autocmd BufWritePre *.py execute ':Black'
"Mappings "Mappings
:nmap <c-s> :w<CR> :nmap <c-s> :w<CR>
:imap <c-s> <Esc>:w<CR>a :imap <c-s> <Esc>:w<CR>a
@ -70,10 +90,11 @@ nnoremap <C-H> <C-W><C-H>
nnoremap <F7> :bp<CR> nnoremap <F7> :bp<CR>
nnoremap <F8> :bn<CR> nnoremap <F8> :bn<CR>
nnoremap <F9> :%!jq '.' nnoremap <F9> :%!jq '.'
noremap <Up> <NOP> "noremap <Up> <NOP>
noremap <Down> <NOP> "noremap <Down> <NOP>
noremap <Left> <NOP> "noremap <Left> <NOP>
noremap <Right> <NOP> "noremap <Right> <NOP>
"AutoCommands "AutoCommands
au BufWinEnter * set number au BufWinEnter * set number
au FileType xml setlocal equalprg=xmllint\ --format\ --recover\ -\ 2>/dev/null au FileType xml setlocal equalprg=xmllint\ --format\ --recover\ -\ 2>/dev/null

View File

@ -103,7 +103,7 @@ font-1 = FontAwesome:pixelsize=12;1
modules-left = i3 modules-left = i3
modules-center = modules-center =
modules-right = mpd gpmdp modules-right = gpmdp spotify
[bar/laptop] [bar/laptop]
monitor = ${env:LAPTOP} monitor = ${env:LAPTOP}
@ -309,18 +309,18 @@ type = custom/script
exec = ~/.config/polybar/scripts/gpmdp.sh exec = ~/.config/polybar/scripts/gpmdp.sh
interval = 5 interval = 5
[module/mpd]
type = internal/mpd
host = 127.0.0.1
port = 6600
interval = 2
icon-play = ⏵ icon-play = ⏵
icon-pause = ⏸ icon-pause = ⏸
icon-stop = ⏹ icon-stop = ⏹
icon-prev = ⏮ icon-prev = ⏮
icon-next = ⏭ icon-next = ⏭
[module/spotify]
type = custom/script
interval = 1
format = <label>
exec = python ~/.config/polybar/scripts/spotify_status.py -p ',' -f '{play_pause} {artist} - {song}'
[global/wm] [global/wm]
margin-top = 5 margin-top = 5
margin-bottom = 5 margin-bottom = 5

View File

@ -0,0 +1,106 @@
#!/bin/python
import sys
import dbus
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--trunclen", type=int, metavar="trunclen")
parser.add_argument(
"-f", "--format", type=str, metavar="custom format", dest="custom_format"
)
parser.add_argument(
"-p", "--playpause", type=str, metavar="play-pause indicator", dest="play_pause"
)
parser.add_argument(
"--font",
type=str,
metavar="the index of the font to use for the main label",
dest="font",
)
parser.add_argument(
"--playpause-font",
type=str,
metavar="the index of the font to use to display the playpause indicator",
dest="play_pause_font",
)
args = parser.parse_args()
def fix_string(string):
# corrects encoding for the python version used
if sys.version_info.major == 3:
return string
else:
return string.encode("utf-8")
# Default parameters
output = fix_string(u"{play_pause} {artist}: {song}")
trunclen = 25
play_pause = fix_string(u"\u25B6,\u23F8") # first character is play, second is paused
label_with_font = "%{{T{font}}}{label}%{{T-}}"
font = args.font
play_pause_font = args.play_pause_font
# parameters can be overwritten by args
if args.trunclen is not None:
trunclen = args.trunclen
if args.custom_format is not None:
output = args.custom_format
if args.play_pause is not None:
play_pause = args.play_pause
try:
session_bus = dbus.SessionBus()
spotify_bus = session_bus.get_object(
"org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2"
)
spotify_properties = dbus.Interface(spotify_bus, "org.freedesktop.DBus.Properties")
metadata = spotify_properties.Get("org.mpris.MediaPlayer2.Player", "Metadata")
status = spotify_properties.Get("org.mpris.MediaPlayer2.Player", "PlaybackStatus")
# Handle play/pause label
play_pause = play_pause.split(",")
if status == "Playing":
play_pause = play_pause[0]
elif status == "Paused":
play_pause = play_pause[1]
else:
play_pause = str()
if play_pause_font:
play_pause = label_with_font.format(font=play_pause_font, label=play_pause)
# Handle main label
artist = fix_string(metadata["xesam:artist"][0]) if metadata["xesam:artist"] else ""
song = fix_string(metadata["xesam:title"]) if metadata["xesam:title"] else ""
if not artist and not song:
print("")
else:
if len(song) > trunclen:
song = song[0:trunclen]
song += "..."
if ("(" in song) and (")" not in song):
song += ")"
if font:
artist = label_with_font.format(font=font, label=artist)
song = label_with_font.format(font=font, label=song)
print(output.format(artist=artist, song=song, play_pause=play_pause))
except Exception as e:
if isinstance(e, dbus.exceptions.DBusException):
print("")
else:
print(e)