Advertisement
Kimarite

cb-x-www-browser-pipemenu

Dec 27th, 2015
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.92 KB | None | 0 0
  1. #!/bin/bash
  2. # ---------------------------------------------------------------------
  3. # Written for CrunchBang Linux <http://crunchbang.org/>
  4. # by Philip Newborough (aka corenominal) <corenominal@corenominal.org>
  5. # ---------------------------------------------------------------------
  6.  
  7. pathto=$(readlink -f "$0" | sed 's%/*[^/]\+/*$%%')
  8.  
  9. if [[ -f $pathto/cb-include.cfg ]]
  10. then
  11. source "$pathto/cb-include.cfg"
  12. else
  13. echo " Failed to locate cb-include.cfg"
  14. exit 1
  15. fi
  16.  
  17. google_key_url_1='https://dl-ssl.google.com/linux/linux_signing_key.pub'
  18. google_key_url_2='http://packages.crunchbang.org/waldorf-files/apt-keys/google-chrome.key'
  19. opera_key_url_1='http://deb.opera.com/archive.key'
  20. opera_key_url_2='http://packages.crunchbang.org/waldorf-files/apt-keys/opera.key'
  21. I=0
  22.  
  23. if [ "$1" = "--chromium-browser" ]; then
  24. terminator --title="Install Chromium Browser" --command="cb-x-www-browser-pipemenu --install-chromium-browser"
  25. exit 0
  26. fi
  27.  
  28. if [ "$1" = "--iceweasel" ]; then
  29. terminator --title="Install Iceweasel Browser" --command="cb-x-www-browser-pipemenu --install-iceweasel"
  30. exit 0
  31. fi
  32.  
  33. if [ "$1" = "--google-chrome" ]; then
  34. terminator --title="Install Google Chrome" --command="cb-x-www-browser-pipemenu --install-google-chrome"
  35. exit 0
  36. fi
  37.  
  38. if [ "$1" = "--opera" ]; then
  39. terminator --title="Install Opera Browser" --command="cb-x-www-browser-pipemenu --install-opera"
  40. exit 0
  41. fi
  42.  
  43. if [ "$1" = "--install-chromium-browser" ]; then
  44. clear
  45. echo ""
  46. echo " INSTALL CHROMIUM BROWSER"
  47. echo " ------------------------"
  48. echo " This script will install Chromium."
  49. echo ""
  50. echo -n " Run the installer now? (Y|n) > "
  51. read a
  52. if [ "$a" = "y" ] || [ "$a" = "Y" ] || \
  53. [ "$a" = "" ]; then
  54.  
  55. connectiontest
  56. clear
  57. echo " Updating sources..."
  58. sleep 2s
  59. sudo apt-get update
  60. clear
  61.  
  62.  
  63. if ! sudo apt-get install -y chromium-browser; then
  64. clear
  65. echo ""
  66. echo " There was a problem installing Chromium."
  67. echo ""
  68. echo " Hit any key to try again, or \"q\" to quit..."
  69. read -n1 a
  70. if [ "$a" = "q" ] || [ "$a" = "Q" ]; then
  71. clear
  72. exit 0
  73. else
  74. cb-x-www-browser-pipemenu --install-chromium-browser
  75. exit 0
  76. fi
  77. else
  78. clear
  79. echo ""
  80. echo " Chromium has been installed successfully."
  81. echo ""
  82. echo " Hit any key to exit..."
  83. read -n1 a
  84. exit 0
  85. fi
  86. else
  87. exit 0
  88. fi
  89. fi
  90.  
  91. if [ "$1" = "--install-iceweasel" ]; then
  92. clear
  93. echo ""
  94. echo " INSTALL ICEWEASEL BROWSER"
  95. echo " -------------------------"
  96. echo " This script will install Iceweasel."
  97. echo ""
  98. echo -n " Run the installer now? (Y|n) > "
  99. read a
  100. if [ "$a" = "y" ] || [ "$a" = "Y" ] || \
  101. [ "$a" = "" ]; then
  102.  
  103. connectiontest
  104. clear
  105. echo " Updating sources..."
  106. sleep 2s
  107. sudo apt-get update
  108. clear
  109.  
  110.  
  111. if ! sudo apt-get install -y iceweasel; then
  112. clear
  113. echo ""
  114. echo " There was a problem installing Iceweasel."
  115. echo ""
  116. echo " Hit any key to try again, or \"q\" to quit..."
  117. read -n1 a
  118. if [ "$a" = "q" ] || [ "$a" = "Q" ]; then
  119. clear
  120. exit 0
  121. else
  122. cb-x-www-browser-pipemenu --install-iceweasel
  123. exit 0
  124. fi
  125. else
  126. clear
  127. echo ""
  128. echo " Iceweasel has been installed successfully."
  129. echo ""
  130. echo " Hit any key to exit..."
  131. read -n1 a
  132. exit 0
  133. fi
  134. else
  135. exit 0
  136. fi
  137. fi
  138.  
  139. if [ "$1" = "--install-google-chrome" ]; then
  140. clear
  141. echo ""
  142. echo " INSTALL GOOGLE CHROME WWW BROWSER"
  143. echo " ---------------------------------"
  144. echo " This script will install Google Chrome."
  145. echo ""
  146. echo -n " Run the installer now? (Y|n) > "
  147. read a
  148. if [ "$a" = "y" ] || [ "$a" = "Y" ] || \
  149. [ "$a" = "" ]; then
  150.  
  151. connectiontest
  152.  
  153. #add apt-key
  154. clear
  155. echo " Adding APT key..."
  156. sleep 2s
  157. if ! wget -O google.key ${google_key_url_1} 2> /dev/null
  158. then
  159. # Fallback to packages.crunchbang.org.
  160. if ! wget -O google.key ${google_key_url_2} 2> /dev/null
  161. then
  162. echo " Failed to retrieve APT key from Google Inc."
  163. clear
  164. exit 1
  165. fi
  166. fi
  167. sudo apt-key add google.key
  168. rm -f google.key
  169.  
  170. #create sources file
  171. echo " Creating APT sources file..."
  172. sleep 2s
  173. if [ -f "/etc/apt/sources.list.d/google-chrome.list" ]; then
  174. sudo rm -f /etc/apt/sources.list.d/google-chrome.list
  175. fi
  176. echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list.d/google-chrome.list
  177.  
  178. #update sources
  179. echo " Updating sources..."
  180. sleep 2s
  181. sudo apt-get update
  182. clear
  183.  
  184.  
  185. if ! sudo apt-get install -y google-chrome-stable; then
  186. clear
  187. echo ""
  188. echo " There was a problem installing Google Chrome."
  189. echo ""
  190. echo " Hit any key to try again, or \"q\" to quit..."
  191. read -n1 a
  192. if [ "$a" = "q" ] || [ "$a" = "Q" ]; then
  193. clear
  194. exit 0
  195. else
  196. cb-x-www-browser-pipemenu --install-google-chrome
  197. exit 0
  198. fi
  199. else
  200. clear
  201. echo ""
  202. echo " Google Chrome has been installed successfully."
  203. echo ""
  204. echo " Hit any key to exit..."
  205. read -n1 a
  206. exit 0
  207. fi
  208. else
  209. exit 0
  210. fi
  211. fi
  212.  
  213. if [ "$1" = "--install-opera" ]; then
  214. clear
  215. echo ""
  216. echo " INSTALL OPERA WWW BROWSER"
  217. echo " -------------------------"
  218. echo " This script will install Opera."
  219. echo ""
  220. echo -n " Run the installer now? (Y|n) > "
  221. read a
  222. if [ "$a" = "y" ] || [ "$a" = "Y" ] || \
  223. [ "$a" = "" ]; then
  224.  
  225. connectiontest
  226.  
  227. #add apt-key
  228. clear
  229. echo " Adding APT key..."
  230. sleep 2s
  231. if ! wget -O opera.key ${opera_key_url_1} 2> /dev/null
  232. then
  233. # Fallback to packages.crunchbang.org.
  234. if ! wget -O opera.key ${opera_key_url_2} 2> /dev/null
  235. then
  236. echo " Failed to retrieve APT key from Opera Software ASA."
  237. clear
  238. exit 1
  239. fi
  240. fi
  241. sudo apt-key add opera.key
  242. rm -f opera.key
  243.  
  244. #create sources file
  245. echo " Creating APT sources file..."
  246. sleep 2s
  247. if [ -f "/etc/apt/sources.list.d/opera.list" ]; then
  248. sudo rm -f /etc/apt/sources.list.d/opera.list
  249. fi
  250. echo "deb http://deb.opera.com/opera/ stable non-free" | sudo tee -a /etc/apt/sources.list.d/opera.list
  251. #update sources
  252. echo " Updating sources..."
  253. sleep 2s
  254. sudo apt-get update
  255. clear
  256.  
  257.  
  258. if ! sudo apt-get install -y opera; then
  259. clear
  260. echo ""
  261. echo " There was a problem installing Opera."
  262. echo ""
  263. echo " Hit any key to try again, or \"q\" to quit..."
  264. read -n1 a
  265. if [ "$a" = "q" ] || [ "$a" = "Q" ]; then
  266. clear
  267. exit 0
  268. else
  269. cb-x-www-browser-pipemenu --install-opera
  270. exit 0
  271. fi
  272. else
  273. clear
  274. echo ""
  275. echo " Opera has been installed successfully."
  276. echo ""
  277. echo " Hit any key to exit..."
  278. read -n1 a
  279. exit 0
  280. fi
  281. else
  282. exit 0
  283. fi
  284. fi
  285. # Start pipemenu
  286. echo " <openbox_pipe_menu>"
  287.  
  288. # Chromium
  289. if [ -x "/usr/bin/chromium-browser" ];then
  290. I=$((I+1))
  291. cat << _menu_
  292. <item label="Chromium Browser">
  293. <action name="Execute">
  294. <command>
  295. chromium-browser
  296. </command>
  297. </action>
  298. </item>
  299. <item label="Chromium Browser (Private Mode)">
  300. <action name="Execute">
  301. <command>
  302. chromium-browser --incognito
  303. </command>
  304. </action>
  305. </item>
  306. _menu_
  307. else
  308. cat << _menu_
  309. <item label="Install Chromium Browser">
  310. <action name="Execute">
  311. <command>
  312. cb-x-www-browser-pipemenu --chromium-browser
  313. </command>
  314. </action>
  315. </item>
  316. _menu_
  317. fi
  318.  
  319. # Iceweasel
  320. if [ -x "/usr/bin/iceweasel" ];then
  321. I=$((I+1))
  322. cat << _menu_
  323. <item label="Iceweasel">
  324. <action name="Execute">
  325. <command>
  326. iceweasel
  327. </command>
  328. </action>
  329. </item>
  330. <item label="Firefox">
  331. <action name="Execute">
  332. <command>
  333. /home/kim/.mozilla/firefox_m/firefox
  334. </command>
  335. </action>
  336. </item>
  337. <item label="Firefox ESR">
  338. <action name="Execute">
  339. <command>
  340. /home/kim/.mozilla/firefox_esr/firefox
  341. </command>
  342. </action>
  343. </item>
  344. <item label="Firefox Aurora">
  345. <action name="Execute">
  346. <command>
  347. /home/kim/.mozilla/firefox_a/firefox
  348. </command>
  349. </action>
  350. </item>
  351. <item label="Firefox Beta">
  352. <action name="Execute">
  353. <command>
  354. /home/kim/.mozilla/firefox_b/firefox
  355. </command>
  356. </action>
  357. </item>
  358. <item label="Firefox Boot2Gecko">
  359. <action name="Execute">
  360. <command>
  361. /home/kim/.mozilla/firefox_boot2gecko/b2g
  362. </command>
  363. </action>
  364. </item>
  365. _menu_
  366. else
  367. cat << _menu_
  368. <item label="Install Iceweasel">
  369. <action name="Execute">
  370. <command>
  371. cb-x-www-browser-pipemenu --iceweasel
  372. </command>
  373. </action>
  374. </item>
  375. _menu_
  376. fi
  377.  
  378. # Iceape
  379. if [ -x "/usr/bin/iceape" ];then
  380. I=$((I+1))
  381. cat << _menu_
  382. <item label="Iceape">
  383. <action name="Execute">
  384. <command>
  385. iceape
  386. </command>
  387. </action>
  388. </item>
  389. <item label="Seamonkey">
  390. <action name="Execute">
  391. <command>
  392. /home/kim/.mozilla/seamonkey_st/seamonkey
  393. </command>
  394. </action>
  395. </item>
  396. _menu_
  397. fi
  398.  
  399. # Google Chrome
  400. if [ -x "/usr/bin/google-chrome" ];then
  401. I=$((I+1))
  402. cat << _menu_
  403. <item label="Google Chrome">
  404. <action name="Execute">
  405. <command>
  406. google-chrome
  407. </command>
  408. </action>
  409. </item>
  410. <item label="Google Chrome (Private Mode)">
  411. <action name="Execute">
  412. <command>
  413. google-chrome --incognito
  414. </command>
  415. </action>
  416. </item>
  417. _menu_
  418. else
  419. cat << _menu_
  420. <item label="Install Google Chrome">
  421. <action name="Execute">
  422. <command>
  423. cb-x-www-browser-pipemenu --google-chrome
  424. </command>
  425. </action>
  426. </item>
  427. _menu_
  428. fi
  429.  
  430. # Opera
  431. if [ -x "/usr/bin/opera" ];then
  432. I=$((I+1))
  433. cat << _menu_
  434. <item label="Opera">
  435. <action name="Execute">
  436. <command>
  437. opera
  438. </command>
  439. </action>
  440. </item>
  441. _menu_
  442. else
  443. cat << _menu_
  444. <item label="Install Opera">
  445. <action name="Execute">
  446. <command>
  447. cb-x-www-browser-pipemenu --opera
  448. </command>
  449. </action>
  450. </item>
  451. _menu_
  452. fi
  453.  
  454. # Configure default
  455. if [ $I -gt 1 ];then
  456. cat << _menu_
  457. <separator/>
  458. <item label="Select default browser">
  459. <action name="Execute">
  460. <command>
  461. terminator --command="sudo update-alternatives --config x-www-browser"
  462. </command>
  463. </action>
  464. </item>
  465. _menu_
  466. fi
  467. # End pipemenu
  468. echo " </openbox_pipe_menu>"
  469. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement