Is there any way to change the font size of terminal window(GNOME or KDE) from inside a shell script
Actually I want to display a file in a particular format on screens of all sizes.
Can i do it using scripts??
For KDE, you can use dcop to set your font size.
For example:
dcop konsole-8540 session-6 setFont Monospace,20,-1,5,50,0,0,0,0,0
(the 20 in the example above is the font size)
I for one would surely not want a shell script (or any other program for that matter) to change my terminal settings! If it were to find a way to do so, I would use it exactly once and them remove it from my machine.
Seriously: This is something you should not do, because the user will probably have set his or her screen size to the way it is for a reason that is probably better than yours for changing it. Consider handicapped people who might need a specific font or very large letters to be able to read the screen at all.
Better try and make your application suitable for any terminal layout - there are variables for telling you how many characters wide and how many lines high your current environment is.
Related
What I want to do is to set the default color (like if output \e[0m) for EVERY output. For some reasons I can’t change it in terminal settings and only hope that Bash can
One way I think it might be possible is to redirect output to temporary file (or file descriptor, or function if possible) and print everything char-by-char or something and removing the reset sequence, but I’m not sure it’s the best way
So can Bash or Zsh do it quickly?
I only need to set a color that will only effect a particular directory not globally.
If you are using Bash in a terminal that supports colors and would like to change the default color for text output to the terminal (not specifically the output of ls) while inside this directory, there is one thing you could do.
The PROMPT_COMMAND variable can be set to execute a command just before printing the prompt. You could use that to check for the current directory and change the terminal color (for instance by assigning the PS1 variable with a prompt that contains non-displayable special codes for selecting a color or echoing said special codes).
PROMPT_COMMAND is documented in the Bash manual: https://www.gnu.org/software/bash/manual/bashref.html
As for how to assign colors, you should look that up if interested.
This solution may not be what you are looking for, will probably have side effects, and generally speaking, I am not sure it will be that useful changing terminal colors depending on the current directory. The usual solution is to have a prompt that shows the current directory path (or at least the last portion of the path).
I use something similar to the above to change text color depending on which machine I am executing Bash on, as I use ssh a lot from one machine to another over several terminal windows, and color (on a black background) is a good way to remember what machine any given window is connected to.
I'm trying to make a bash script that behaves differently based on the terminal program that someone is using (Putty, mobaxterm, etc). Is there any way to retrieve this kind of information from a bash script?
I was searching around online but I was not able to find anything (or I'm just wording it incorrectly, which could be a distinct possibility).
thank you
You need to understand that these are terminal emulators. There is a simple, crude identification function for (most?) modern line terminals (now that's an oxymoron!) but it will return something like vt102 or xterm i.e. whatever the emulator is emulating; not the identity of the program performing this emulation. Incidentally, this is usually used when the session is initiated, and reflected in the value of the $TERM environment variable.
The common way to do this is the environment variable TERM. Try
echo $TERM
That should output the terminal emulator's type, indicating its capabilities. Often, though not always, the value of TERM will be the name of the terminal emulator. For example, xterm may set TERM to xterm, or to xterm-color, depending on configuration.
Note that the user can change this variable, so it may contain something completely different.
That said, if you want to do fancy things with the terminal from a script, you don't need to build support for different terminals by hand. There are various libraries that offer all the usual functions (clear terminal, resize window, change font etc.). The most popular one is terminfo; there are various packages that build on terminfo.
I've created a couple of very simple bash scripts for a home-made games arcade (input configuration, updating stuff etc). I've got a launcher, so it's not a problem to direct the user to run the wanted shell script, but while running a bash script functionality-wise gives me everything I need, the default low-res text-on-black look scares the end user.
What is the simplest way to "prettify" fullscreen shell scripts? Something that'll run the script in 1080p, use bigger bubbly antialiased fonts, add a fancy animated background etc., but still pretty much lets me stick to write good-old shell scripts?
I guess another way to ask is: Does a prettier, more modern GUI-looking alternative to whiptail exist?
I am running from the terminal, so the GUI library it would have to be as fully self-contained as possible.
The ability of a shell script to display a quit within the terminal window itself is limited entirely to the graphical capabilities of the terminal (and to what termcap/terminfo has support for).
Most terminals max out at 256 colors (though supposedly konsole has support for arbitrary RGB colors somehow).
Control over font sizing/etc. from the shell is limited to the escape sequences that the terminal is willing to respond to (and I don't know if those are at all standard or discoverable at runtime).
The best option for this might be to have your script re-exec itself in a new terminal window to which it passes appropriate arguments to control font selection, window geometry, color selection, etc.
That being said even reliably doing that isn't necessarily the easiest thing in the world (I'm not sure how portable the command line options are between different terminal emulators or how many more advanced features they expose).
You could use python with the library Gooey that makes easy to turn CLI applications to GUI:
It can be customized and it takes only one line for the magic to happen:
from gooey import Gooey
#Gooey <--- all it takes! :)
def main():
# rest of code
I'm using the LaTeX-Beamer class for making presentations. Every once in a while I need to include screenshots. Those graphics are pixel-based, of course. I use includegraphics like this:
\begin{figure}
\includegraphics[width= \paperwidth]{img/analyzer.png}
\end{figure}
or usually something like this:
\begin{figure}
\includegraphics[width= 0.8\linewidth]{img/analyzer.png}
\end{figure}
This leads to pretty bad readibility of the contained text, so I'm asking for your best practices: How would you include screenshots containing text considering, that I will do the output PDF with pdflatex?
EDIT: I suppose I'm looking for something like an 1:1 presetation of the image within beamer. However, [scale = 1.0] doesn't achieve what I'm looking for.
Your best bet is to scale the image outside of Latex for inclusion, and include it in 1:1 ratio. The scaling done by graphics packages in Latex isn't going to be anywhere near as good as possible from other tools. Latex (Tex) has limited floating-point arithmetic capabilities, whereas an external tool can use sophisticated algorithms to get the scaling better.
Another option is to use only a part of the screenshot, the one you want to concentrate on.
Edit: If you can change the font size before taking the screenshot, that's another option—just increase the font size for the screenshots.
Of course, you can combine the two methods.
I have done exactly what you do and e.g defined
\newcommand{\screenshot}[1]{\centerline{%
\includegraphics[height=7.8cm,transparent]{#1}}} % 7.8in
which worked with whatever style I was using at the time. The files included with this macro were all PNGs created with one the usual Linux screen capture tools.
Edit: You may have to play with the size (height and width) of your input files. It came out rather nice for me (and this was from a presentation in 2006).
How about scaling it as follows:
\includegraphics[scale=0.5]{images/myimage.jpg}
This works for me.
Have you tried to convert the image to .eps or .pdf file and use this file in LaTeX?
Maybe try also latex, dvips and ps2pdf.
Problem might be in used viewer, in Linux I use Document viewer or ePDFViewer and output is much worse than in Adobe Reader or Acrobat, which I use in Windows...