all repos — dotfiles @ c1ce7111ba5c4260e38c655aeabe57caf18b0818

linux dotfiles

I am lazy commit
prithugoswami prithugoswami524@gmail.com
Wed, 03 Oct 2018 22:28:20 +0530
commit

c1ce7111ba5c4260e38c655aeabe57caf18b0818

parent

9c557a55519cee5538462c4249acedd8ee02391a

6 files changed, 59 insertions(+), 32 deletions(-)

jump to
M .vimrc.vimrc

@@ -81,10 +81,3 @@ if exists('$TMUX')

let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" endif - -" js-beautify plugin -autocmd FileType javascript noremap <buffer> <c-f> :call JsBeautify()<cr> -autocmd FileType json noremap <buffer> <c-f> :call JsonBeautify()<cr> -autocmd FileType jsx noremap <buffer> <c-f> :call JsxBeautify()<cr> -autocmd FileType html noremap <buffer> <c-f> :call HtmlBeautify()<cr> -autocmd FileType css noremap <buffer> <c-f> :call CSSBeautify()<cr>
M i3/configi3/config

@@ -133,7 +133,7 @@ bindsym $mod+Ctrl+b exec terminal -e 'bmenu'

bindsym $mod+d exec "rofi -show run -lines 3 -padding 25" # Desktop application launcher #bindsym $mod+Shift+d exec --no-startup-id "rofi -show drun" -bindsym $mod+Shift+d exec --no-startup-id "dmenu_extended_run" +bindsym $mod+Shift+d exec --no-startup-id "runa -a" bindsym $mod+i exec --no-startup-id "qutebrowser" # PD bindsym $mod+p exec st -e "pd"

@@ -377,6 +377,7 @@ #}}}

### Autostart Applications/Scripts ###{{{ +exec --no-startup-id setxkbmap -layout us,in -option "grp:alt_caps_toggle" exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 exec --no-startup-id compton -b exec --no-startup-id nm-applet
M i3/i3status.confi3/i3status.conf

@@ -19,7 +19,8 @@ #order += "run_watch VPN"

#order += "wireless _first_" #order += "ethernet _first_" order += "battery 0" -order += "tztime local" +order += "tztime local_date" +order += "tztime local_time" wireless _first_ { format_up = "  %essid %quality "

@@ -36,8 +37,8 @@ battery 0 {

format = "%status %percentage %remaining " path = "/sys/class/power_supply/BAT1/uevent" status_chr = " " - status_bat = "  " - status_full = "  " + status_bat = "" + status_full = "" last_full_capacity = true low_threshold = 30 integer_battery_capacity = true

@@ -52,8 +53,12 @@ run_watch VPN {

pidfile = "/var/run/vpnc/pid" } -tztime local { - format = " %a, %d %b %Y | %I:%M:%p" +tztime local_date { + format = " %a, %d %b %Y " +} + +tztime local_time { + format = " %I:%M:%p " } load {

@@ -61,5 +66,5 @@ format = " %1min "

} disk "/" { - format = "  %avail " + format = " %avail " }
M packages.txtpackages.txt

@@ -20,6 +20,7 @@ youtube-dl

pandoc texlive-core cmus +nethogs --------------------- AUR
M ranger/rifle.confranger/rifle.conf

@@ -96,6 +96,7 @@ ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1"

ext nes, has fceux, X = fceux "$1" ext exe = wine "$1" name ^[mM]akefile$ = make +ext m3u8 = mpv "$1" #-------------------------------------------- # Code
M scripts/playlist-syncscripts/playlist-sync

@@ -6,7 +6,7 @@ # ===================================================

# # Author: Prithu Goswami # Email: prithugoswami524@gmail.com -# Date: 17 Sep 2018 +# Date: 21 Sep 2018 # # Description: # This script syncs playlist from spotify using the spotify-downloader

@@ -42,7 +42,7 @@ # A new playlist entry is created by giving the `-a` option to the script

# followed by the id and a local path where the music will be downloaded # # Example: -# $ playlist-sync -a <playlist-id> <path-to-directory> +# $ playlist-sync -a <playlist-id> <absolute-path-to-directory> import json

@@ -69,18 +69,24 @@ client_secret=client_secret)

sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager) config={} -if os.path.exists(config_path): - with open(config_path, 'r') as jsonfile: - config = json.load(jsonfile) -else: - ans=input('Config file does not exist. Create it? [y/n] >') - if ans == y: - print("created") +def create_config(): + ans = input("Config file does not exist. Create it? [y/n] ") + if ans in "yY": + with open(config_path, 'w') as jsonfile: + config_data={'playlists':[]} + json.dump(config_data, jsonfile, indent=4) + ans = input("\nWould you also like to add a playlist? [y/n] ") + if ans in "yY": + pl_id=input('\nPlaylist Id > ') + pl_path=input('Playlist local path (absolute path) > ') + add_playlist(pl_id, pl_path) + else: + print('\nYou can add a playlist by passing the `-a` option to the' + 'script\n\nsyntax: $ playlist-sync -a <playlist-id> ' + '<absolute-path-to-directory>') + exit(0) else: - print("could not") - - -playlists=config['playlists'] + exit(0) def add_playlist(plid, path):

@@ -93,7 +99,6 @@

playlist= { "name": pl['name'], "id": pl['id'], - "owner_id": ' ', "location": path, "snapshot_id": ' ', "last_updated": 'never'

@@ -104,9 +109,10 @@ json.dump(config, jsonfile, indent=4)

print('Added playlist: {} \n' 'Sync path: {}'.format(pl['name'], path)) - print('updated config') + print('\nUpdated config file') if not os.path.exists(path): os.mkdir(path) + print('Created directory: {}'.format(path)) def requires_update(playlist_data, playlist): return playlist_data['snapshot_id'] != playlist['snapshot_id']

@@ -166,18 +172,23 @@ m3ufile.write(track_string)

def update_playlist(playlist_data, playlist): + print("Updating Playlist: " + playlist['name'] + "\n") + track_urls=get_need_to_download(playlist_data, playlist) + with open("/tmp/spotdllist.txt", 'w') as f: for a in track_urls: f.write(a+'\n') - print('written files to /tmp/spotdllist.txt:\n') + print('Written files to /tmp/spotdllist.txt') + print('Track links to downalod:') for m in track_urls: print(m) + command=('spotdl --list /tmp/spotdllist.txt -f {} --trim-silence --overwrite skip' .format(playlist['location'])) args=shlex.split(command) - print('calling spotdl') + print('\nCalling spotdl') p = subprocess.Popen(args, universal_newlines=True) p_out, p_err = p.communicate() if p.returncode!=0:

@@ -200,6 +211,21 @@ json.dump(config, jsonfile, indent=4)

print('updated config') return + +if not os.path.exists(config_path): + create_config() +else: + with open(config_path, 'r') as jsonfile: + config = json.load(jsonfile) + +playlists=config['playlists'] +if not playlists: + print('There are no playlists to process') + print('Add playlist by passing the `-a` option.\n\nsyntax: ' + '$ playlist-sync -a <playlist-id> <absolute-path-to-directory>') + exit(0) + + if len(sys.argv)>1: if sys.argv[1]=='-a': add_id=sys.argv[2]

@@ -208,6 +234,6 @@ add_playlist(add_id, add_id_path)

exit(0) for playlist in playlists: - playlist_data=sp.user_playlist(playlist['owner_id'], playlist_id=playlist['id']) + playlist_data=sp.user_playlist(' ', playlist_id=playlist['id']) if requires_update(playlist_data, playlist): update_playlist(playlist_data, playlist)