Browsing the topic linux
So, after a take on Metacity , I just went ahead and implemented the same quick workspace switching feature for KDE (namely, kwin) – with great help from Nicolas Lécureuil (a.k.a. Neoclust) of course!
Basically, it works essentially like the same feature in xfwm4 – when you switch to a different workspace via a keyboard shortcut, and press the same shortcut again while on this workspace, it will bring you back to the previous one. So you can press ctrl-f2 to switch to from workspace 1 workspace 2, and when you press ctrl-f2 again kwin will recognize that you want switch back, to whatever workspace you were before, and will do it. An extremely handy quirk which I cannot live without anymore
.
I have to assume that I have never ever coded anything for KDE until yesterday, but it turned out to be extremely simple. KDE has its flaws, its infrastructure with billions of libraries and processes everywhere is hard to understand, but I actually was surprised on how easy it was.
So, without further words, the patch for kdebase4-workspace which adds this functionality follows (sorry for the formatting, but kde has some very long lines of code..):
diff -p -up kdebase-workspace-4.5.65svn1165394/kwin/kcmkwin/kwindesktop/main.cpp.switchback kdebase-workspace-4.5.65svn1165394/kwin/kcmkwin/kwindesktop/main.cpp
--- kdebase-workspace-4.5.65svn1165394/kwin/kcmkwin/kwindesktop/main.cpp.switchback 2010-09-01 09:10:02.000000000 -0300
+++ kdebase-workspace-4.5.65svn1165394/kwin/kcmkwin/kwindesktop/main.cpp 2010-09-01 09:21:13.000000000 -0300
@@ -184,6 +184,7 @@ void KWinDesktopConfig::init()
connect( m_ui->popupHideSpinBox, SIGNAL(valueChanged(int)), SLOT(changed()));
connect( m_ui->desktopLayoutIndicatorCheckBox, SIGNAL(stateChanged(int)), SLOT(changed()));
connect( m_ui->wrapAroundBox, SIGNAL(stateChanged(int)), SLOT(changed()));
+ connect( m_ui->switchBackBox, SIGNAL(stateChanged(int)), SLOT(changed()));
connect( m_editor, SIGNAL(keyChange()), SLOT(changed()));
connect( m_ui->allShortcutsCheckBox, SIGNAL(stateChanged(int)), SLOT(slotShowAllShortcuts()));
connect( m_ui->effectComboBox, SIGNAL(currentIndexChanged(int)), SLOT(changed()));
@@ -252,6 +253,8 @@ void KWinDesktopConfig::defaults()
m_ui->wrapAroundBox->setChecked( true );
+ m_ui->switchBackBox->setChecked( false );
+
m_editor->allDefault();
emit changed(true);
@@ -285,6 +288,9 @@ void KWinDesktopConfig::load()
KConfigGroup windowConfig( m_config, "Windows" );
m_ui->wrapAroundBox->setChecked( windowConfig.readEntry<bool>( "RollOverDesktops", true ) );
+ // Quick switching back to previous desktop
+ m_ui->switchBackBox->setChecked( windowConfig.readEntry<bool>( "SwitchBackDesktops", false ) );
+
// Effect for desktop switching
// Set current option to "none" if no plugin is activated.
KConfigGroup effectconfig( m_config, "Plugins" );
@@ -341,6 +347,9 @@ void KWinDesktopConfig::save()
// Wrap Around on screen edge
KConfigGroup windowConfig( m_config, "Windows" );
windowConfig.writeEntry( "RollOverDesktops", m_ui->wrapAroundBox->isChecked() );
+ //
+ // Quickly back to previous desktop
+ windowConfig.writeEntry( "SwitchBackDesktops", m_ui->switchBackBox->isChecked() );
// Effect desktop switching
KConfigGroup effectconfig( m_config, "Plugins" );
diff -p -up kdebase-workspace-4.5.65svn1165394/kwin/kcmkwin/kwindesktop/main.ui.switchback kdebase-workspace-4.5.65svn1165394/kwin/kcmkwin/kwindesktop/main.ui
--- kdebase-workspace-4.5.65svn1165394/kwin/kcmkwin/kwindesktop/main.ui.switchback 2010-09-01 09:09:59.000000000 -0300
+++ kdebase-workspace-4.5.65svn1165394/kwin/kcmkwin/kwindesktop/main.ui 2010-09-01 09:59:02.000000000 -0300
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>572</width>
- <height>310</height>
+ <height>334</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
@@ -141,6 +141,16 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="switchBackBox">
+ <property name="whatsThis">
+ <string>Enable this option if you want to remember and recall previous desktop when switching via keyboard shortcuts. E.g., if you switched to desktop 2 by pressing its shortcut, pressing it again while on desktop 2 will bring you back to the previous desktop.</string>
+ </property>
+ <property name="text">
+ <string>Remember and recall previous desktop when switching via keyboard shortcuts</string>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
diff -p -up kdebase-workspace-4.5.65svn1165394/kwin/kwin.kcfg.switchback kdebase-workspace-4.5.65svn1165394/kwin/kwin.kcfg
--- kdebase-workspace-4.5.65svn1165394/kwin/kwin.kcfg.switchback 2010-09-01 09:10:56.000000000 -0300
+++ kdebase-workspace-4.5.65svn1165394/kwin/kwin.kcfg 2010-09-01 09:16:20.000000000 -0300
@@ -41,6 +41,7 @@
<entry key="ShadeHover" type="Bool" />
<entry key="GeometryTip" type="Bool" />
<entry key="RollOverDesktops" type="Bool" />
+ <entry key="SwitchBackDesktops" type="Bool" />
<entry key="FocusStealingPreventionLevel" type="Int" />
<entry key="Placement" type="String" />
<entry key="AutoRaise" type="Bool" />
diff -p -up kdebase-workspace-4.5.65svn1165394/kwin/options.cpp.switchback kdebase-workspace-4.5.65svn1165394/kwin/options.cpp
--- kdebase-workspace-4.5.65svn1165394/kwin/options.cpp.switchback 2010-09-01 09:12:09.000000000 -0300
+++ kdebase-workspace-4.5.65svn1165394/kwin/options.cpp 2010-09-01 09:26:40.000000000 -0300
@@ -87,6 +87,8 @@ unsigned long Options::updateSettings()
rollOverDesktops = config.readEntry("RollOverDesktops", true);
+ switchBackDesktops = config.readEntry("SwitchBackDesktops", false);
+
legacyFullscreenSupport = config.readEntry( "LegacyFullscreenSupport", false );
// focusStealingPreventionLevel = config.readEntry( "FocusStealingPreventionLevel", 2 );
diff -p -up kdebase-workspace-4.5.65svn1165394/kwin/options.h.switchback kdebase-workspace-4.5.65svn1165394/kwin/options.h
--- kdebase-workspace-4.5.65svn1165394/kwin/options.h.switchback 2010-09-01 09:12:07.000000000 -0300
+++ kdebase-workspace-4.5.65svn1165394/kwin/options.h 2010-09-01 09:22:14.000000000 -0300
@@ -215,6 +215,11 @@ class Options : public KDecorationOption
*/
bool rollOverDesktops;
+ /**
+ * whether or not quick switching back to previous desktop is allowed via keyboard shortcuts
+ */
+ bool switchBackDesktops;
+
// 0 - 4 , see Workspace::allowClientActivation()
int focusStealingPreventionLevel;
diff -p -up kdebase-workspace-4.5.65svn1165394/kwin/workspace.cpp.switchback kdebase-workspace-4.5.65svn1165394/kwin/workspace.cpp
--- kdebase-workspace-4.5.65svn1165394/kwin/workspace.cpp.switchback 2010-05-20 08:42:10.000000000 -0300
+++ kdebase-workspace-4.5.65svn1165394/kwin/workspace.cpp 2010-09-01 10:10:02.000000000 -0300
@@ -95,6 +95,7 @@ Workspace::Workspace( bool restore )
, desktopGridSize_( 1, 2 ) // Default to two rows
, desktopGrid_( new int[2] )
, currentDesktop_( 0 )
+ , prevDesktop_( 0 )
, desktopLayoutDynamicity_( false )
, tilingEnabled_( false )
// Unsorted
@@ -1403,6 +1404,15 @@ bool Workspace::setCurrentDesktop( int n
StackingUpdatesBlocker blocker( this );
int old_desktop = currentDesktop();
+
+ // Eugeni: are we trying to switch back to previous desktop?
+ if (options->switchBackDesktops && (old_desktop == new_desktop ) && (prevDesktop() > 0) )
+ {
+ // go back to previous desktop
+ new_desktop = prevDesktop();
+ kDebug(1212) << "Switching back to " << new_desktop;
+ }
+
if (new_desktop != currentDesktop() )
{
++block_showing_desktop;
@@ -1413,6 +1423,7 @@ bool Workspace::setCurrentDesktop( int n
ObscuringWindows obs_wins;
currentDesktop_ = new_desktop; // Change the desktop (so that Client::updateVisibility() works)
+ prevDesktop_ = old_desktop;
for( ClientList::ConstIterator it = stacking_order.constBegin();
it != stacking_order.constEnd();
diff -p -up kdebase-workspace-4.5.65svn1165394/kwin/workspace.h.switchback kdebase-workspace-4.5.65svn1165394/kwin/workspace.h
--- kdebase-workspace-4.5.65svn1165394/kwin/workspace.h.switchback 2010-08-11 07:08:13.000000000 -0300
+++ kdebase-workspace-4.5.65svn1165394/kwin/workspace.h 2010-08-31 23:34:01.000000000 -0300
@@ -245,6 +245,10 @@ class Workspace : public QObject, public
*/
int currentDesktop() const;
/**
+ * @returns The ID of the previous desktop.
+ */
+ int prevDesktop() const;
+ /**
* Set the current desktop to @a current.
* @returns True on success, false otherwise.
*/
@@ -314,6 +318,7 @@ class Workspace : public QObject, public
QSize desktopGridSize_;
int* desktopGrid_;
int currentDesktop_;
+ int prevDesktop_;
QString activity_;
bool desktopLayoutDynamicity_;
@@ -1142,6 +1147,11 @@ inline int Workspace::currentDesktop() c
return currentDesktop_;
}
+inline int Workspace::prevDesktop() const
+ {
+ return prevDesktop_;
+ }
+
inline int Workspace::desktopAtCoords( QPoint coords ) const
{
return desktopGrid_[coords.y() * desktopGridSize_.width() + coords.x()];
Some rpm quirks that can come quite handy sometimes. Specially for the ones who do not know how the rpm and spec files work
.
The first one goes to a quick command which displays the top packages that use the most of your hard drive:
rpm -qa --qf="%{size} %{name}\n" | sort -n
This will list all installed packages, sorting them by size. There are some limitations for that (for example, it does not works nicely with hard links), but it gives you a big picture.
The second one goes to the:
rpm -qf /path/to/some/file
This will display which package the file you are looking at belongs to.
The third complements the third, and it is:
rpm -Vf /path/to/some/file
It will discover to what package the file belongs to, and verify if this package was changed since the install. So if something suddenly stopped working, and you are unable to figure out why by looking at the configuration file, this could come handy.
Next one goes to:
rpm -qf --scripts /path-to-some-file
If you notice that some command gets executed right after a package is installed, and the only thing you know about this package is one file it provides, this will show all such commands.
Fifth is:
rpm -qa --qf '%{license}\n' | sort | uniq
This will show you all the licenses of all packages you have installed on the system.
And a bonus one goes to:
rpm -qf --changelog /path/to/a/file
which shows the whole package changelog for the package that contains a specific file. This helps you find someone to blame when a package stops working
.
I just packaged the gource package for Mandriva Cooker, so therefore it will be available in Mandriva 2010.1 – which will be released in just few weeks.
While doing so, I was playing a bit with it, and it is an impressive piece of software. I often receive comments asking about “who is really working on Mandriva-specific software”. So, just to illustrate it in details, here goes a detailed explanation of who had commited something into drakx-net (Mandriva network stack) over the past year and half:
The command to generate this video was (inside drakx-net source directory, checked out with git):
gource -640x360 -s 0.1 --stop-at-end --disable-progress --output-ppm-stream - | \
ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i - drakx-net.mp4
Every time I try to switch to a different desktop environment/window manager, there is just one simple feature which always make me go back to xfce – the possibility to quickly switch back to previous virtual desktop. A simple but extremely addictive feature, which only xfwm4 was offering…
…until yesterday! I became tired on metacity not offering this feature, so I just went ahead and implemented it overnight (learning a lot about gnome development during the process).
So, if anyone out there was missing this feature – feel free to grab this patch and apply it to the metacity source. Basically, it will add one new gconf entry (switch_to_previous_workspace), and will make metacity remember the last workspace. So you can press ctrl-f2 to switch to from workspace 1 workspace 2, and when you press ctrl-f2 again metacity will recognize that you want switch back, to whatever workspace you were before, and will do it.
Once again, this is the beauty of the open source. If there is something you need, but nobody implemented it, you always have the possibility of just doing it yourself. At least, sometimes
.
diff -p -up metacity-2.30.1/src/core/prefs.c.switch metacity-2.30.1/src/core/prefs.c
--- metacity-2.30.1/src/core/prefs.c.switch 2010-03-30 11:35:40.000000000 -0300
+++ metacity-2.30.1/src/core/prefs.c 2010-05-06 17:47:14.000000000 -0300
@@ -97,6 +97,7 @@ static char *cursor_theme = NULL;
static int cursor_size = 24;
static gboolean compositing_manager = FALSE;
static gboolean resize_with_right_button = FALSE;
+static gboolean switch_to_previous_workspace = TRUE;
static gboolean force_fullscreen = TRUE;
static MetaVisualBellType visual_bell_type = META_VISUAL_BELL_FULLSCREEN_FLASH;
@@ -412,6 +413,11 @@ static MetaBoolPreference preferences_bo
&resize_with_right_button,
FALSE,
},
+ { "/apps/metacity/general/switch_to_previous_workspace",
+ META_PREF_SWITCH_TO_PREVIOUS_WORKSPACE,
+ &switch_to_previous_workspace,
+ FALSE,
+ },
{ NULL, 0, NULL, FALSE },
};
@@ -1757,6 +1763,9 @@ meta_preference_to_string (MetaPreferenc
case META_PREF_FORCE_FULLSCREEN:
return "FORCE_FULLSCREEN";
+
+ case META_PREF_SWITCH_TO_PREVIOUS_WORKSPACE:
+ return "SWITCH_TO_PREVIOUS_WORKSPACE";
}
return "(unknown)";
@@ -2719,6 +2728,12 @@ meta_prefs_get_mouse_button_menu (void)
return resize_with_right_button ? 2: 3;
}
+guint
+meta_prefs_switch_to_previous_workspace (void)
+{
+ return switch_to_previous_workspace;
+}
+
gboolean
meta_prefs_get_force_fullscreen (void)
{
diff -p -up metacity-2.30.1/src/core/screen-private.h.switch metacity-2.30.1/src/core/screen-private.h
--- metacity-2.30.1/src/core/screen-private.h.switch 2010-01-14 22:31:32.000000000 -0200
+++ metacity-2.30.1/src/core/screen-private.h 2010-05-06 17:47:14.000000000 -0300
@@ -80,7 +80,7 @@ struct _MetaScreen
MetaUI *ui;
MetaTabPopup *tab_popup;
- MetaWorkspace *active_workspace;
+ MetaWorkspace *active_workspace, *last_workspace;
/* This window holds the focus when we don't want to focus
* any actual clients
diff -p -up metacity-2.30.1/src/core/workspace.c.switch metacity-2.30.1/src/core/workspace.c
--- metacity-2.30.1/src/core/workspace.c.switch 2010-01-14 22:31:32.000000000 -0200
+++ metacity-2.30.1/src/core/workspace.c 2010-05-06 18:00:39.000000000 -0300
@@ -377,7 +377,31 @@ meta_workspace_activate_with_focus (Meta
meta_workspace_index (workspace));
if (workspace->screen->active_workspace == workspace)
- return;
+ {
+ meta_verbose("Switching to same workspace detected, going back to previous one!!\n");
+ if (meta_prefs_switch_to_previous_workspace()) {
+ if (workspace->screen->last_workspace) {
+ meta_verbose("Going to desktop %d\n", meta_workspace_index(workspace));
+ meta_workspace_activate_with_focus(workspace->screen->last_workspace,
+ NULL, timestamp);
+ return;
+ } else {
+ meta_verbose("No old workspace..\n");
+ return;
+ }
+ } else {
+ meta_verbose("Last workspace switching disabled..\n");
+ return;
+ }
+ }
+ else
+ {
+ if (workspace->screen->active_workspace)
+ meta_verbose("Updating last workspace.. current: %d, new: %d\n",
+ meta_workspace_index(workspace->screen->active_workspace),
+ meta_workspace_index(workspace));
+ workspace->screen->last_workspace = workspace->screen->active_workspace;
+ }
if (workspace->screen->active_workspace)
workspace_switch_sound(workspace->screen->active_workspace, workspace);
diff -p -up metacity-2.30.1/src/include/prefs.h.switch metacity-2.30.1/src/include/prefs.h
--- metacity-2.30.1/src/include/prefs.h.switch 2010-01-14 22:31:32.000000000 -0200
+++ metacity-2.30.1/src/include/prefs.h 2010-05-06 17:47:14.000000000 -0300
@@ -60,7 +60,8 @@ typedef enum
META_PREF_CURSOR_SIZE,
META_PREF_COMPOSITING_MANAGER,
META_PREF_RESIZE_WITH_RIGHT_BUTTON,
- META_PREF_FORCE_FULLSCREEN
+ META_PREF_FORCE_FULLSCREEN,
+ META_PREF_SWITCH_TO_PREVIOUS_WORKSPACE
} MetaPreference;
typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
diff -p -up metacity-2.30.1/src/metacity.schemas.in.in.switch metacity-2.30.1/src/metacity.schemas.in.in
--- metacity-2.30.1/src/metacity.schemas.in.in.switch 2010-05-06 17:47:14.000000000 -0300
+++ metacity-2.30.1/src/metacity.schemas.in.in 2010-05-06 18:01:16.000000000 -0300
@@ -4,6 +4,24 @@
<!-- General preferences -->
<schema>
+ <key>/schemas/apps/metacity/general/switch_to_previous_workspace</key>
+ <applyto>/apps/metacity/general/switch_to_previous_workspace</applyto>
+ <owner>metacity</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short>Remember and recall previous workspace when switching via keyboard shortcuts</short>
+ <long>
+ Set this to true to allow to switch to previous workspace when
+ using the current workspace keybinding. For example, if you switched
+ from workspace 2 to workspace 1 by pressing keyboard shortcut for
+ workspace 1, pressing the same shortcut again while on workspace 1
+ will switch to workspace 2.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/metacity/general/mouse_button_modifier</key>
<applyto>/apps/metacity/general/mouse_button_modifier</applyto>
<owner>metacity</owner>
diff -p -up metacity-2.30.1/src/metacity.schemas.in.switch metacity-2.30.1/src/metacity.schemas.in
--- metacity-2.30.1/src/metacity.schemas.in.switch 2010-04-06 07:10:38.000000000 -0300
+++ metacity-2.30.1/src/metacity.schemas.in 2010-05-06 18:01:06.000000000 -0300
@@ -4,6 +4,24 @@
<!-- General preferences -->
<schema>
+ <key>/schemas/apps/metacity/general/switch_to_previous_workspace</key>
+ <applyto>/apps/metacity/general/switch_to_previous_workspace</applyto>
+ <owner>metacity</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short>Remember and recall previous workspace when switching via keyboard shortcuts</short>
+ <long>
+ Set this to true to allow to switch to previous workspace when
+ using the current workspace keybinding. For example, if you switched
+ from workspace 2 to workspace 1 by pressing keyboard shortcut for
+ workspace 1, pressing the same shortcut again while on workspace 1
+ will switch to workspace 2.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/metacity/general/mouse_button_modifier</key>
<applyto>/apps/metacity/general/mouse_button_modifier</applyto>
<owner>metacity</owner>
@@ -247,7 +265,7 @@
<applyto>/apps/metacity/general/theme</applyto>
<owner>metacity</owner>
<type>string</type>
- <default>Clearlooks</default>
+ <default>Ia Ora Steel</default>
<locale name="C">
<short>Current theme</short>
<long>
Improving system speed, disk life and everything else in one small command
5 Comments | Filed under Linux-Planet devel english linux mandrivaI just noticed this days that, according to smartctl, the hard disk on my notebook has reached 365 days on Power_On_Hours variable. As the notebook itself has almost 2 years of age (I bought it in March of 2008), it is almost a double birthday-combo
.
However, at this age, it is obvious that the hard disk of the notebook was not prepared to endure such challenges nicely. Both of its speed (5400 RPMs), durability, capacity, and so on were targeted on a more light use.
On the other hand, the system has 3GB of RAM, which is more than enough for most of my tasks. So after some thinking, I’ve been using some small script to automatically improve the system performance by offloading the most I/O-consuming stuff to RAM for the past few months.
How does it works? Simple. I have a small script which grabs content of a disk directory which I expect to receive heavy use (for example, /usr/lib/firefox, or the rpm BUILD/ directories which receive lots of I/O when building packages, and so on), and converts them into a RAM disk. This way, when anything inside such directory is accessed, it requires absolutely no hard disk I/O, the seek times are non-existent as well, and the throughput is incredible.
For example, if I build mozilla-thunderbird by using real hard disk BUILD directory, it takes almost 2 hours to build. If I use ramdisk for just the BUILD directory, the time required for such task drops down to about 30 minutes. The firefox startup time (both cold and hot – e.g., the first execution and consecutive ones) have the same time of about 1 second; and so on.
So, without further words, this is the script I am using:
#!/bin/bash
#
# This script remounts a directory in tmpfs (ramdisk) to speed it up
#
DIR=$1
SIZE=$2
if [ ! "$UID" = "0" ]; then
# this script must run by root. Let's try sudo'ing to root..
exec sudo $0 $*
fi
if [ ! -d $DIR ]; then
echo "Usage: $0 <full path to a directory>"
exit 1
fi
if [ "a$SIZE" = "a" ]; then
OPTIONS=""
else
OPTIONS="-o size=$SIZE"
fi
# first, copy everything somewhere to reuse it later
TMP=`mktemp`
tar cpf $TMP $DIR
# remount dir as ramdisk
mount -t tmpfs $OPTIONS $DIR $DIR
# unpack everything back
(cd / && tar xpf $TMP)
rm -f $TMP
To use it, just save it under a name like toram and use it on the directory you want to move to ramdisk. The second optional parameter is the size of the ramdisk to use – as by default tmpfs mounts itself with 50% of available ram, sometimes you may want to use more or less memory.
Just some examples on how to use it:
# toram `pwd`/BUILD (will remount current BUILD directory in RAM)
# toram /usr/lib/firefox-3.6 (will remount firefox directory in ram)
I hope this could be useful to someone
.
Well, this question appeared quite frequently to me. However, I never bothered with it, as I was either on a LAN, or had a different source from which I could resume using wget, or a file was sufficiently small to redownload it again. However, this time these approaches did not work:
- The file was big (a DVD ISO)
- The only way to access it was over a SSH connection
- The only authentication method it supported was public key authentication
- The directory from where the file was downloaded was read-only
- The link was sloooow
- I already had downloaded about 70% of the file
So I started looking for solutions. Most of ideas I found on google suggested using ‘rsync –partial –rsh=ssh‘, and indeed it could work. However, rsync tried to create a temporary file on the server, and, as the directory was read-only, it failed. There probably is some option to make it work, but I don’t have plenty of rsync experience. And this approach just looked to be over complicated.
After a bit of more googling, I found out that curl supported sftp backend. And, after a few minutes trying to figure out how to make it work with public key authentication, I finally figured it out:
curl -C - --pubkey ~/.ssh/key.pub --key ~/.ssh/key \
sftp://eugeni@somewhere/mnt/.../i586/my_precious_iso.iso \
-o my_precious_iso.iso
To shorten it up, it is possible to write a simple wrapper function (or a script) for bash:
#!/bin/bash
function scp_resume() {
URL="$1"
FILE="$2"
if [ "a$FILE" == "a" ]; then
echo "Usage: scp_resume <sftp url> <local target>"
return 1
fi
# the magic
curl -C - $URL -o $FILE
}
function scp_resume_key() {
URL="$1"
FILE="$2"
KEY="$3"
if [ "a$FILE" == "a" ]; then
echo "Usage: scp_resume <sftp url> <local target> <key file name>"
return 1
fi
# the magic
curl -C - --key $HOME/.ssh/$KEY --pubkey $HOME/.ssh/${KEY}.pub $URL -o $FILE
}
so it did the trick.
Was just playing with Google Chrome for Linux on my Mandriva installation.
In a few words – it rocks! There are still a lot of issues and non-implemented features, but even not it is:
- extremely fast
- surprisingly stable
- opens most of my favorite sites without any problems
It works pretty fine on Mandriva 2009.1/cooker, the only necessary thing is to setup the right links in /usr/lib for its libraries. But after that, it just works. I just miss the firefox extensions, like adblock, mouse gestures, stylish, twitter and delicious.com integration, but.. one cannot had it all
.
I am using MPD to play my small collection of mp3:
[eugeni@eugeni 16:53:31 ~] $ mpc stats
Artists: 787
Albums: 747
Songs: 9112
Everything is controlled by keybinding – for example, to run the play command, I press < Super >+Up; to run next command I press < Super >+Right, and so on. These shortcuts start a small client to mpd, which is nothing more than a shell script which:
- Starts MPD if it is not running (I do not start it on startup to save a few seconds of boot time)
- Runs mpdscribble in background to update the LAST.FM statistics
- Runs all required MPD commands
- And displays the results in a nice way
And it is multi-distro-oriented by the way
.
#!/bin/bash
# Is mpd running
mpc status 2> /dev/null
ret=$?
if [ ! "$ret" = "0" ]; then
notify-send -i audio "Music" "Starting mpd.."
# are we on arch linux?
if [ -x "/etc/rc.d/mpd" ]; then
sudo /etc/rc.d/mpd start
else
sudo su -c "service mpd start"
fi
# starting mpdscribble
mpdscribble
# starting sonata
sonata --hidden
fi
mpc $*
# Some black magick to get a bit more advanced mpd status
# and convert it to shell variables
eval `echo -e 'status\ncurrentsong\nclose\n' | \
nc localhost 6600 | \
sed -e '/OK/d' -e 's/: \(.*\)/="\1"/g'`
# show the results
notify-send -i audio "$Artist - $Album - $Title" \
"$(mpc status | sed -e 's/&/and/g')"
Just yet one another script which contributes to world’s entropy
.
Realmente, não tem jeito de habilitar cairo-lcd no firefox-nightly. O firefox (na sua versão atual) está usando funcionalidades de cairo que não foram integradas ao repositório oficial ainda.
Embora o 3.1 (e o 3.2a1) são MUITO mais rápidos que o firefox 3 comum, a aparence do firefox3 usando system-cairo dá de 10×0 neles.
Ahh que dúvida difícil.. Será que fico com o firefox lento+bonitinho, ou rápido+pouco legível??
Descobriremos nos próximos capítulos de Eugeni vs Firefox!
O que a falta do que fazer não faz..
Estava eu, feliz e contente, usando Arch Linux (que, por definição, só vem com pacotes mais recentes) durante os últimos 2 anos, junto com o firefox-nightly compilado manualmente. Mas, recentemente, passei para mandriva 2009. Mas.. senti que falta alguma coisa nele. Como Mandriva 2009 é uma versão “estável”, as coisas novas demoram para aparecer.. O problema de firefox foi fácil de se resolver (já tem todos os scripts prontos para compilá-lo mesmo), mas e os outros pacotes??
A decisão foi passar para o cooker – versão unstable do Mandriva. Precisou baixar 700MB de pacotes, atualizar metade do sistema, e remover alguns dos programas que eu uso direto (por exemplo, texlive-latex e xfce-cpufreq-plugin). Mas nada impossível de resolver na mão. E também, alguns dos meus softwares favoritos do Arch não estavam inclusos na distro (mas também, nada que um rpmbuild não resolva).
O que eu tiro como conclusão parcial? Que o esquema de pacotes de Arch é o melhor que todos os outros, de longe! Mas, com um pouco de sacrifício, dá para se acostumar com os SPEC’s, e criar RPMs na mão.
Agora estou de volta à vida on-the-bleeding-edge!
Depois de longos meses usando os Nightly Builds do Firefox 3 (até o lançamento oficial dele), voltei à vida on-the-edge. Agora estou usando a versão do Firefox 3.1, compilada manualmente a partir do mercurial!
Isso sim é apelado
.
O pior é que até agora não consegui fazer com que ele usasse o system-cairo direito.. Daí as fontes ficam bem diferentes do resto do sistema..
Quem usa o netspeed-applet do gnome e atualizou ele para versão 0.15, descobriu que esta versão não permite mais modificar o tamanho da fonte. Para mim isso é essencial (as fontes que vem pode padrão são muito grandes), por isso decidi fazer um patch para dar suporte a isso.
Para quem usa ArchLinux, o PKGBUILD já está no AUR
.
Para quem não usa ele, esse é o patch:
netspeed-applet with editable font size option
diff -ru netspeed_applet-0.15.2/src/netspeed.c netspeed_applet-0.15.2.fontsize/src/netspeed.c
--- netspeed_applet-0.15.2/src/netspeed.c 2008-09-13 16:59:52.000000000 -0300
+++ netspeed_applet-0.15.2.fontsize/src/netspeed.c 2008-10-23 14:57:41.000000000 -0200
@@ -85,6 +85,7 @@
gboolean show_sum, show_bits;
gboolean change_icon, auto_change_device;
GdkColor in_color, out_color;
+ int font_size;
int width;
GtkWidget *inbytes_text, *outbytes_text;
@@ -664,8 +665,11 @@
/* Refresh the text of the labels and tooltip */
if (applet->show_sum) {
+ add_markup_size(&applet->devinfo.sum_rate, applet->font_size);
gtk_label_set_markup(GTK_LABEL(applet->sum_label), applet->devinfo.sum_rate);
} else {
+ add_markup_size(&applet->devinfo.rx_rate, applet->font_size);
+ add_markup_size(&applet->devinfo.tx_rate, applet->font_size);
gtk_label_set_markup(GTK_LABEL(applet->in_label), applet->devinfo.rx_rate);
gtk_label_set_markup(GTK_LABEL(applet->out_label), applet->devinfo.tx_rate);
}
@@ -891,6 +895,7 @@
return;
}
panel_applet_gconf_set_string(PANEL_APPLET(applet->applet), "device", applet->devinfo.name, NULL);
+ panel_applet_gconf_set_int(PANEL_APPLET(applet->applet), "font_size", applet->font_size, NULL);
panel_applet_gconf_set_bool(PANEL_APPLET(applet->applet), "show_sum", applet->show_sum, NULL);
panel_applet_gconf_set_bool(PANEL_APPLET(applet->applet), "show_bits", applet->show_bits, NULL);
panel_applet_gconf_set_bool(PANEL_APPLET(applet->applet), "change_icon", applet->change_icon, NULL);
@@ -901,6 +906,15 @@
applet->settings = NULL;
}
+/* Set the font size to the new value
+ */
+static void
+font_size_adjust_cb(GtkSpinButton *spinbutton, NetspeedApplet *applet)
+{
+ applet->font_size = gtk_spin_button_get_value_as_int(spinbutton);
+ applet->width = 0;
+}
+
/* Called when the showsum checkbutton is toggled...
*/
static void
@@ -944,7 +958,12 @@
GtkWidget *category_header_label;
GtkWidget *network_device_hbox;
GtkWidget *network_device_label;
+ GtkWidget *label_font_size_hbox;
+ GtkWidget *label_font_size_hbox2;
+ GtkWidget *label_font_size_label;
+ GtkWidget *label_font_size_spinbutton;
GtkWidget *indent_label;
+ GtkWidget *points_label;
GtkWidget *show_sum_checkbutton;
GtkWidget *show_bits_checkbutton;
GtkWidget *change_icon_checkbutton;
@@ -1033,6 +1052,31 @@
gtk_combo_box_set_active(GTK_COMBO_BOX(applet->network_device_combo), active);
g_object_set_data_full(G_OBJECT(applet->network_device_combo), "devices", devices, (GDestroyNotify)free_devices_list);
+ label_font_size_hbox = gtk_hbox_new(FALSE, 6);
+ gtk_box_pack_start(GTK_BOX(controls_vbox), label_font_size_hbox, TRUE, TRUE, 0);
+
+ label_font_size_label = gtk_label_new_with_mnemonic(_("Label _font size:"));
+ gtk_label_set_justify(GTK_LABEL(label_font_size_label), GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment(GTK_MISC(label_font_size_label), 0.0f, 0.5f);
+ gtk_size_group_add_widget(category_label_size_group, label_font_size_label);
+ gtk_box_pack_start(GTK_BOX(label_font_size_hbox), label_font_size_label, FALSE, FALSE, 0);
+
+ label_font_size_hbox2 = gtk_hbox_new(FALSE, 6);
+ gtk_box_pack_start(GTK_BOX(label_font_size_hbox), label_font_size_hbox2, TRUE, TRUE, 0);
+
+ label_font_size_spinbutton = gtk_spin_button_new_with_range (5.0, 32.0, 1.0);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(label_font_size_spinbutton), (double) applet->font_size);
+ gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(label_font_size_spinbutton), TRUE);
+ gtk_spin_button_set_digits(GTK_SPIN_BUTTON (label_font_size_spinbutton), 0);
+ gtk_label_set_mnemonic_widget(GTK_LABEL(label_font_size_label), label_font_size_spinbutton);
+ gtk_box_pack_start(GTK_BOX(label_font_size_hbox2), label_font_size_spinbutton, TRUE, TRUE, 0);
+
+ points_label = gtk_label_new(_("points"));
+ gtk_label_set_justify(GTK_LABEL (points_label), GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment(GTK_MISC (points_label), 0.0f, 0.5f);
+ gtk_size_group_add_widget(category_units_size_group, points_label);
+ gtk_box_pack_start(GTK_BOX (label_font_size_hbox2), points_label, FALSE, FALSE, 0);
+
show_sum_checkbutton = gtk_check_button_new_with_mnemonic(_("Show _sum instead of in & out"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_sum_checkbutton), applet->show_sum);
gtk_box_pack_start(GTK_BOX(controls_vbox), show_sum_checkbutton, FALSE, FALSE, 0);
@@ -1048,6 +1092,9 @@
g_signal_connect(G_OBJECT (applet->network_device_combo), "changed",
G_CALLBACK(device_change_cb), (gpointer)applet);
+ g_signal_connect(G_OBJECT (label_font_size_spinbutton), "value-changed",
+ G_CALLBACK(font_size_adjust_cb), (gpointer)applet);
+
g_signal_connect(G_OBJECT (show_sum_checkbutton), "toggled",
G_CALLBACK(showsum_change_cb), (gpointer)applet);
@@ -1343,6 +1390,30 @@
}
}
+/* Tries to get the desktop font size out of gconf
+ * database
+ */
+static int
+get_default_font_size(void)
+{
+ int ret = 12;
+ char *buf, *ptr;
+
+ GConfClient *client = NULL;
+ client = gconf_client_get_default();
+ if (!client)
+ return 12;
+ buf = gconf_client_get_string(client, "/desktop/gnome/interface/font_name", NULL);
+ if (!buf)
+ return 12;
+ ptr = strrchr(buf, ' ');
+ if (ptr)
+ sscanf(ptr, "%d", &ret);
+ g_free(buf);
+
+ return ret;
+}
+
static gboolean
applet_button_press(GtkWidget *widget, GdkEventButton *event, NetspeedApplet *applet)
{
@@ -1526,6 +1597,7 @@
applet->show_sum = FALSE;
applet->show_bits = FALSE;
applet->change_icon = TRUE;
+ applet->font_size = -1;
applet->auto_change_device = TRUE;
/* Set the default colors of the graph
@@ -1553,6 +1625,9 @@
applet->show_bits = panel_applet_gconf_get_bool(applet_widget, "show_bits", NULL);
applet->change_icon = panel_applet_gconf_get_bool(applet_widget, "change_icon", NULL);
applet->auto_change_device = panel_applet_gconf_get_bool(applet_widget, "auto_change_device", NULL);
+ applet->font_size = panel_applet_gconf_get_int(applet_widget, "font_size", NULL);
+ if (!applet->font_size)
+ applet->font_size = -1;
tmp = panel_applet_gconf_get_string(applet_widget, "device", NULL);
if (tmp && strcmp(tmp, ""))
@@ -1587,6 +1662,9 @@
}
}
+ if (applet->font_size < 1)
+ applet->font_size = get_default_font_size();
+
if (!applet->devinfo.name) {
GList *ptr, *devices = get_available_devices();
ptr = devices;
Hoje decidi gastar um tempo para aprender a fazer panoramas (em outras palavras, fotos compostas de forma contínua a partir de fotos menores). Por exemplo, você quer tirar foto da paisagem inteira, mas.. a sua camera só consegue pegar 1/3 dela. Solução? Tirar 3 fotos e juntar todas elas depois.
Para fazer isso, usei o Hugin. Usei 2 fotos que eu tirei no fim da semana, juntando-as para formar uma paisagem só.
Para a minha surpresa, foi absurdamente fácil o processo. Demorou menos de 5 minutos, sendo que o Hugin conseguiu fazer tudo sozinho (encontrar os pontos comuns entre as figuras, juntar elas, ajustar a exposição, etc).
Dá para ver o resultado da brincadeira no flickr.
Ahh, e tutorial que ensina a fazer tudo isso está aqui.
Bem, hoje saiu nova versão “estável” de Mandriva – Mandriva 2009. Aproveitando que estava com conexão rápida, baixei o CD de instalação (Mandriva ONE, versão que vem com Gnome) e instalei no meu note.
Concluindo em poucas palavras – essa versão de Mandriva não se deu bem com o meu notebook (ASUS G1S). Logo após a instalação, na hora de reiniciar o micro, o notebook travou de vez. Ao bootar, ele pediu para adicionar usuários (eu já tinha montado o meu /home antigo na instalação), e decidi usar o mesmo UID para o meu usuário, para continuar com os arquivos que eu tenho. Assim que eu adicionei um usuário, ele ficou mexendo sem parar no disco, rodando algum comando gigante com um grep e consumindo 100% de CPU. Aparentemente, ele quis mudar todos os arquivos do meu $HOME (tem 100GB.. hehehe) para.. para.. para algo o que eu não consegui descobrir
. Quando matei o grep, tudo continuo normalmente, até carregar o gnome.
Carregando o gnome, a tela tornou-se pouca usável – ao mexer o mouse, o display fica cheio de pequenos pixels pretos (algo parecido acontecia com antigas placas de vídeo da S3, onde o driver de video corrompia a memória de vídeo das placas). Pelo que eu vi, Mandriva usa o driver beta de Nvidia, o que causa este problema. Entretanto, no meu notebook eu usei todos os drivers beta também (173.08, 173.14.09, 177.13, 177.67, 177.70, 177.78 e 177.80), e nunca deu esse problema.
Também por algum motivo ele detectou 2 bluetooth’es e não detectou placa de wireless (iwl4965). Durante o boot, dá a impressão de que ele fica se divertindo com o sistema – a tela apaga e acende, e depois fica com menos brilho (será que é o notebook mode?), a webcam integrada pisca, liga e desliga…
Enfim, a primeira impressão que eu tive é que o mandriva 2009 não gostou do meu notebook. Vou esperar alguns dias para sair updates, aí eu tento atualizar, para ver se melhora alguma coisa. No entanto, continuo com o meu querido Arch Linux já faz 1 ano e meio! Até então o recorde foi do Slackware (4 anos consecutivos), mas ele perdeu justamente para o Arch Linux.
Linus Torvalds, o criador de Linux, também tem um blog.
E, logo neste blog, ele anunciou mais um software que ele fez nos últimos tempos – tracker, um sistema para monitorar o tempo que as crianças ficam na internet, desconectando-as depois de um tempo determinado.
O cara realmente é demais.. Faz o kernel do Linux, num fim da semana faz o GIT, e no outro desenvolve mais um software simples e eficiente como esse..
Além disso, lá tem uma bom review dos novos discos SSD de Intel, falando bem a verdade sobre o estado dos SSDs hoje em dia. Realmente, até Intel entrar neste mercado, discos SSD eram mais “moda” de que tecnologia. Agora as coisas estão diferente – só acompanhar as notícias dos novos lançamentos que grandes empresas logo depois do lançamento dos modelos da Intel. Só esperar abaixar o preço agora (umas 10x
).
Depois de apanhar muito do openoffice (tanto 2.4.1 quanto do 3.00_m6), decidi experimentar o IBM Lotus Symphony – conjunto de aplicações de escritório de IBM. Diz a lenda que ele é baseado no OpenOffice 1.1.
A alma corajosa que tem vontade de ver como que ele funciona, precisa passar por diversos desafíos:
- Primeiro, é necessário baixar um arquivo de 300MB, passando por diversas páginas que pedem seu registro no IBM.
- Segundo, é necessário dar um jeito de instalar o arquivo auto-executável que vem com alguns problemas embutidos (por exemplo, mktemp usa alguns parâmetros que o meu ArchLinux não suporta.. Por isso precisei extrair os arquivos na mão – nada que less + awk não resolva
). - Finalmente, tem que instalar ele.
Bem, neste item 3 que começam os problemas. A aplicação inteira é em Java. Se você achava que o OpenOffice é lento (nota rápida – OpenOffice 3 é MUITO mais rápido que o 2.4!), você vai se delirar com o Lotus Symphony. Eu acho que ele foi o 1o software que conseguiu travar o meu asus g1s (core 2 duo 2.0, 3GB de RAM) por mais de 1 minuto só para se iniciar.
Logo após iniciar, ele conseguiu se confundir internamente, mostrando diversos exceptions na tela (não no log, no meio da tela mesmo!).
Testando ele com os arquivos do OpenOffice e Office, também não consegui muito sucesso. Os arquivos .DOC/.ODT ele abriu certo. Mas com as apresentações ele se confundiu feio. Perdeu toda a formatação, fontes, itens, etc.
Visualmente, a interface dele é bem diferente do OpenOffice, e é parecida com o StarOffice original (tem tipo um menu “Iniciar”, e todos os documentos ficam abertos em tabs). O lado bom é que ele tem um menu com ações mais comuns de lado direito – algo que faz falta no OpenOffice.
Na tentativa de fechar os tabs ou sair, ele deu diversos exceptions e permaneceu aberto, não querendo abandonar este mundo cruel e injusto
. Ele também é praticamente impossível de ser iniciado a partir da linha de comando – o comando para iniciar a aplicação é: /opt/ibm/lotus/Symphony/framework/shared/eclipse/plugins/com.ibm.productivity.tools.standalone.launcher.linux.x86_1.5.0.20080827-1548/IBM\ Lotus\ Symphony
Resumindo, depois dessa breve experiência negativa que eu tive com ele, acabei voltando para o OpenOffice 3 que estava usando. Ele tem seus problemas existenciais (não tem dicionários, não tem como definir a língua do documento de jeito “convencional”, documentos ODF que ele salva são parcialmente incompatíveis com o OpenOffice 2 e 1), mas pelo menos dá para usar ele sem precisar ficar treinando paciência.
Infelizmente, até agora o Office 2007 da Microsoft é o melhor ambiente de escritório que já usei
. Tirando Latex, é claro, mas aí já é outra história..
Apareceu hoje:
[29716.863265] TCP: Treason uncloaked! Peer 125.46.3.227:17140/60001 shrinks window 2742629828:2742629837. Repaired.
Essa é melhor que lp0 on fire!











