Advertisement
Guest User

xfce-perma-pywal.py

a guest
Oct 15th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #!/bin/python3
  2. import pathlib
  3.  
  4. def fcopy(src, dst):
  5. f1 = open(src, "r")
  6. f2 = open(dst, "w")
  7. f2.write(f1.read())
  8. f1.close()
  9. f2.close()
  10.  
  11.  
  12. homedir = str(pathlib.Path.home())
  13.  
  14. pywal_conf = open(homedir + "/.cache/wal/colors", "r")
  15. colors_str = str(pywal_conf.read())
  16. pywal_conf.close()
  17.  
  18. color_list = colors_str.splitlines()
  19. total = len(color_list)
  20.  
  21. fcopy(homedir + "/.config/xfce4/terminal/terminalrc", homedir + "/.config/xfce4/terminal/terminalrc.bak")
  22.  
  23. xfce_conf = open(homedir + "/.config/xfce4/terminal/terminalrc", "r")
  24. content = xfce_conf.read()
  25. xfce_conf.close()
  26.  
  27.  
  28. xfce_conf = open(homedir + "/.config/xfce4/terminal/terminalrc", "w+")
  29. new_palette = "ColorPalette=" + ";".join(color_list) #trim the last 2 colors since they're BG and FG
  30.  
  31. lines = content.splitlines()
  32. for i in range(len(lines)):
  33. if (lines[i][:len("ColorPalette")] == "ColorPalette"):
  34. lines[i] = new_palette
  35. elif (lines[i][:len("ColorForeground=")] == "ColorForeground="):
  36. lines[i] = "ColorForeground=" + color_list[len(color_list)-1]
  37. elif (lines[i][:len("ColorBackground=")] == "ColorBackground="):
  38. lines[i] = "ColorBackground=" + color_list[0]
  39.  
  40.  
  41. new_conf = "\n".join(lines)
  42. xfce_conf.write(new_conf)
  43. xfce_conf.close()
  44.  
  45. print("Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement