Code Tray

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
User avatar
rockedge
Site Admin
Posts: 5827
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2079 times
Been thanked: 2174 times
Contact:

Code Tray

Post by rockedge »

This tool written, developed and released by @fredx181 should be in one's toolbox.
Original post -> https://oldforum.puppylinux.com/viewtop ... a27f484f89

*** Code Tray ***

Update 2020-07-03 Some improvements, by misko_2083 http://murga-linux.com/puppy/viewtopic. ... 77#1062177
Update 2020-06-17 version 2, attached code_tray2.sh.tar.gz, see changes here

Often I need to try out code snippets, e.g. from text file, from here or anywhere else on the web.
As I wanted a convenient way to do that and also the ability to save, edit them quickly, I made this for my own use, perhaps it's useful for others too.
I know there are different ways to do similar, e.g. by using geany (but frankly I didn't explore them much)
Took some parts from 'trans_tray' and from examples in the 'YAD - tips' thread, thanks misko, mochimoppel, vovchik, stemsee and others.

Attached is: code_tray.sh.tar.gz, extract and run code_tray.sh, then just highlight a piece of code and left-click the tray icon to run it.
Depends on yad and xclip. (yad needs to be version 0.37 or higher)
(preferences, geometry settings and saved codes are stored in ~/.code_tray)
The terminal to use is set to 'xterm' by default, some puppies don't have it perhaps, then change in the settings to e.g. urxvt or e.g. lxterminal.

From Help (right-click menu):

- Select some code (bash) (no need to copy, just select it), e.g. in browser or text file.
Then by left-clicking the icon, a terminal will appear running the code.

- From menu (right-click) there are some other options, e.g:
- Preferences, to change some default settings, e.g. texteditor, terminal, set font
- Show selected code, save to a file if you wish
(can be handy to edit it, select it, then run it by left-clicking the icon)
- View saved codes (located in ~/.code_tray/saved)

Hint: If you need to edit selected code, run 'Show selected code' from menu,
then edit it, select it and run by left-clicking the icon

Required is to have 'xclip' installed.

It could be that there's a limit for the amount of lines, I tried with 1000+ lines of code and still works ok though.

Any opinions, suggestions to improve are welcome!

Fred

code-tray.jpg
code-tray.jpg (38.3 KiB) Viewed 275 times
code-tray-settings.jpg
code-tray-settings.jpg (34.54 KiB) Viewed 275 times
code_tray.sh.tar.gz
(5.35 KiB) Downloaded 24 times
code_tray2.sh.tar.gz
(5.56 KiB) Downloaded 33 times
Post Reply

Return to “Programming”