Guest User

Untitled

a guest
May 19th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. picker ()
  5.  
  6. {
  7. echo "Pick background color"
  8. back=$(yad --color --title "Choose background color")
  9.  
  10. echo "Pick foreground color"
  11. forg=$(yad --color --title "Choose foreground color")
  12. }
  13.  
  14.  
  15. adjust ()
  16. {
  17. ##backgr
  18. printf "XCalc.ti.Command.background: $back
  19. " >> ~/.xapps-col
  20. printf "XCal*background: $back
  21. " >> ~/.xapps-col
  22. printf "XFontSel*background: $back
  23. " >> ~/.xapps-col
  24. printf "display.background: $back
  25. " >> ~/.xapps-col
  26. printf "Xman*background: $back
  27. " >> ~/.xapps-col
  28. ##forg
  29. printf "XCalc.ti.Command.foreground: $forg
  30. " >> ~/.xapps-col
  31. printf "XCal*foreground: $forg
  32. " >> ~/.xapps-col
  33. printf "Xman*foreground: $forg
  34. " >> ~/.xapps-col
  35. printf "XFontSel*foreground: $forg
  36. " >> ~/.xapps-col
  37. printf "display.foreground: $forg
  38. " >> ~/.xapps-col
  39. }
  40.  
  41. grepcol ()
  42. {
  43. ### First locate theme dir
  44. cat ~/.gtkrc-2.0 | grep gtk-theme-name | awk -F= '/gtk-theme-name/ {print $2}' >> /tmp/theme
  45. theme=$(sed 's/.//;s/.$//' /tmp/theme)
  46. (cat /tmp/theme)
  47. rm /tmp/theme
  48.  
  49. #### then extract the colors
  50.  
  51. if [ ! -f ~/.themes/$theme/gtk-2.0/gtkrc ]
  52. then
  53. col_bg=$(cat /usr/share/themes/$theme/gtk-2.0/gtkrc | grep scheme | head -n1 | awk -Fnbg_color: '/#/ {print $2}' | head -c 7)
  54. col_fg=$(cat /usr/share/themes/$theme/gtk-2.0/gtkrc | grep scheme | head -n1 | awk -Ffg_color: '/#/ {print $2}' | head -c 7)
  55. path=/usr/share/themes/$theme/gtk-2.0/gtkrc
  56. echo $path
  57. else
  58. col_bg=$(cat ~/.themes/$theme/gtk-2.0/gtkrc | grep scheme | head -n1 | awk -Fnbg_color: '/#/ {print $2}' | head -c 7)
  59. col_fg=$(cat ~/.themes/$theme/gtk-2.0/gtkrc | grep scheme | head -n1 | awk -Ffg_color: '/#/ {print $2}' | head -c 7)
  60. path=~/.themes/$theme/gtk-2.0/gtkrc
  61. echo $path
  62. fi
  63.  
  64.  
  65. echo $col_bg
  66.  
  67. echo $col_fg
  68.  
  69.  
  70. if [[ -z $col_bg || -z $col_fg ]]; then
  71. echo 'One or more colors are undefined, please set it manually'
  72. leafpad $path &
  73. echo "Please enter background color : "
  74. read col_bg
  75. echo "You entered: $col_bg"
  76. echo "Please enter foreground color : "
  77. read col_fg
  78. echo "You entered: $col_fg"
  79. fi
  80.  
  81. back=$col_bg
  82. forg=$col_fg
  83. }
  84.  
  85. grepx ()
  86. {
  87. back=#$(colr bg)
  88. echo $back
  89. forg=#$(colr fg)
  90. echo $forg
  91. }
  92.  
  93. read -p "Do you want to adjust the Xapp's look manually (y) , or apply GTK-colors (n) , or add the Xcolors (x) ? (y/n/x)?" choice
  94. case "$choice" in
  95. y|Y )rm ~/.xapps-col
  96. picker
  97. adjust
  98. xrdb load ~/.Xdefaults
  99. echo "Added the colors of your choise"
  100. exit 0
  101. ;;
  102. n|N )rm ~/.xapps-col
  103. grepcol
  104. adjust
  105. xrdb load ~/.Xdefaults
  106. echo "Added the GTK colors"
  107. exit 0
  108. ;;
  109. x|X )rm ~/.xapps-col
  110. grepx
  111. adjust
  112. xrdb load ~/.Xdefaults
  113. echo "added Xcolors"
  114. exit 0
  115. ;;
  116. * ) echo "Fuck you bastard. RTFM."
  117. exit 1
  118. esac
  119. exit
Advertisement
Add Comment
Please, Sign In to add comment