'Programming'에 해당되는 글 91건

  1. 2014.05.20 mplayer 이어서 보기 스크립트. 2
  2. 2012.10.19 간단하지만 유용한 쉘스크립트. 2
  3. 2011.06.23 외부접속 확인하는 간단한 스크립트
  4. 2011.05.27 포인터 연습 6
  5. 2011.05.25 [수정중] 아치리눅스에서 안드로이드 개발환경 설정 2

mplayer 이어서 보기 스크립트.

몇일동안 써 봤는데 별 문제는 없네요.


(뭐 생기면 고치면 되고...)


원리를 간단하게 설명하자면.


1,mplayer를 터미널상에서 재생시키면, 현재 재생중인 위치가 가장 마지막 위치에 나옵니다.


2, 재생전에 로그파일에 정보가 있는지 확인하고, 있으면 그곳을 시작위치로 저장해서 mplayer를 재생.


3, 이후 계속 출력 메세지를 받아놓고,


4, mplayer가 종료되면 로그의 가장 마지막줄을 읽어서 끝난 위치를 알아내는 거죠.


5, 그리고 난 다음, 로그파일에 정보가 없으면 새로운 로그 라인에 (기록초, 파일경로) 추가, 있으면 수정합니다.


(사실 원래는 중간에 메세지를 가로채서 파이프로 보내려고 했습니다만, 아무래도 뻘짓같아서...  포기하고 있다가 AUR에 mplayer-resumer(https://aur.archlinux.org/packages/mplayer-resumer/) 패키지를 보고 힌트를 얻어서 작성. (대체 왜 나는 쓸데없이 복잡한 방법을 생각해 냈을까?)


동영상 길이도 검사해서 맨뒷부분에서 exit시에는 기록을 하지 않게 만들어 놓았습니다.


저는 mplayer를 slave mode(외부에서 파이프로 mplayer 제어) 로도 사용하기 때문에 파이프를 설정하는 옵션도 들어갔습니다만, 필요없으면 없애주세요.


길이만 길다뿐이지 별거 아닙니다. 그럼 코드.


#!/bin/bash


# 필요 패키지 : bash, mplayer, ffmpeg, perl, 기타 쉘 관련 유틸리티
MPLAYER_PATH="/home/lowid/bin/mplayer"
MPLAYER_PIPE_PATH="/tmp/mplayer_pipe"
MPLAYER_LOG_FILEPATH="/share/ani/.mplayer_position.log"

# 키 후킹법 => 실패.
#while [ 1 ];do read -n 1 CMD >/dev/null;HEX="$(echo -n "$CMD" | hexdump -e \"%d\")";echo "key_down_event $HEX" > /tmp/mplayer_pipe;done
export MPLAYER_STATUS_OK_END=0
export MPLAYER_STATUS_OK_PLAYING=1
export MPLAYER_ERROR_NOT_PLAY_FILE=2
export MPLAYER_ERROR_LOG_POSITION_GET=3
export MPLAYER_ERROR_PLAYING=4

# mplayer에서 재생할 파일경로와 옵션을 분리해 냅니다
# 주의 : 각 인자를 확장자를 기준으로 분류합니다. (파싱 오류 가능성 있음!)
function Option_Parse()
{
    local Param=""
    unset OPTION_PARSE_RETURN_FILEPATH
    unset OPTION_PARSE_RETURN_OPTIONS

    for Param in "$@";do
        if [ "$(echo "$Param" | grep -E "\.mpg|\.wvx|\.rmvb|\.avi|\.mkv|\.wmv|\.mp4")" ];then

            OPTION_PARSE_RETURN_FILEPATH="$(realpath "$Param")"
        else
            OPTION_PARSE_RETURN_OPTIONS=""$OPTION_PARSE_RETURN_OPTIONS" "$Param""
        fi
    done
}

function Mplayer_Play_Duration()
{
    local Play_filepath="$1"
    local Play_file_duration=""
    local Hour=0
    local Minute=0
    local Second=""
    unset MPLAYER_PLAY_DURATION_RETURN_SECOND

    if [ ! -f "$Play_filepath" ];then
        return 1
    fi

    Play_file_duration="$(ffmpeg -i "$Play_filepath" 2>&1 | grep '^\s*Duration: [0-9][0-9]:[0-9][0-9]:[0-9][0-9]' | perl -pe 's/^.*?\: //g,s/\..*$//g')"
    Hour="$(echo "$Play_file_duration"   | cut -d ':' -f1 | perl -pe 's/^0//g')"
    Minute="$(echo "$Play_file_duration" | cut -d ':' -f2 | perl -pe 's/^0//g')"
    Second="$(echo "$Play_file_duration" | cut -d ':' -f3 | perl -pe 's/^0//g')"

    MPLAYER_PLAY_DURATION_RETURN_SECOND=$(($Hour * 60 * 60 + $Minute * 60 + $Second))

    return 0
}

function Mplayer_Log_Position_Get()
{
    local Play_filepath="$1"
    local Log_filepath="$2"
    local Log_play_file_line=""
    MPLAYER_POSITION_GET_RETURN_PLAY_SECOND=0

    if [ ! -f "$Play_filepath" ];then
        return 1
    fi

    if [ ! -f "$Log_filepath" ];then
        touch "$Log_filepath"
    fi

    Log_play_file_line="$(fgrep -n "$Play_filepath" "$Log_filepath" | cut -d ':' -f1 2>/dev/null)"
   
    if [ -n "$Log_play_file_line" ];then
        MPLAYER_POSITION_GET_RETURN_PLAY_SECOND="$(sed -n "$Log_play_file_line"'p' "$Log_filepath" | cut -d ' ' -f1)"
    fi

    return 0
}

function Mplayer_Log_Position_Set()
{
    local Play_filepath="$1"
    local Play_second="$2"
    local Log_filepath="$3"
    local Log_play_file_line=""
    local Log_play_file_data=""
    local Temp_filepath="/tmp/mpp_$RANDOM"

    if [ ! -f "$Play_filepath" ];then
        return 1
    fi

    if [ -z "$Play_second" ];then
        return 2
    fi

    if [ ! -f "$Log_filepath" ];then
        return 3
    fi

    Log_play_file_line="$(fgrep -n "$Play_filepath" "$Log_filepath" | cut -d ':' -f1 2>/dev/null)"
   
    # 없으면 뒤에 쓰고, 없으면 치환.
    if [ -z "$Log_play_file_line" ];then
        echo "$Play_second" "$Play_filepath" >> "$Log_filepath"
    else
        Log_play_file_data=""$Log_play_file_line"c "$Play_second" "$Play_filepath""
        sed -e "$Log_play_file_data" "$Log_filepath" > "$Temp_filepath"
        mv -f "$Temp_filepath" "$Log_filepath" 2>/dev/null
    fi

    return 0
}

function Mplayer_Log_Position_Delete()
{
    local Play_filepath="$1"
    local Log_filepath="$2"
    local Log_play_file_line=""
    local Temp_filepath="/tmp/mpp_$RANDOM"

    if [ ! -f "$Play_filepath" ];then
        return 1
    fi

    if [ ! -f "$Log_filepath" ];then
        return 2
    fi

    Log_play_file_line="$(fgrep -n "$Play_filepath" "$Log_filepath" | cut -d ':' -f1 2>/dev/null)"

    if [ -z "$Log_play_file_line" ];then
        return 3
    fi

    sed -e "$Log_play_file_line"'d' "$Log_filepath" > "$Temp_filepath"
    mv -f "$Temp_filepath" "$Log_filepath" 2>/dev/null

    return 0
}

function Mplayer_Play_Continue()
{
    local Options="$1"
    local Play_filepath="$2"
    local Play_position_second="$3"
    local Play_backward_second="$4"
    local Mplayer_end_second=""
    local Mplayer_start_position_second=""
    unset MPLAYER_PLAY_RETURN_POSITION

    if [ ! -f "$Play_filepath" ];then
        return 1
    fi

    if [ -z "$Play_position_second" ];then
        return 2
    fi

    if [ -z "$Play_backward_second" ];then
        return 3
    fi

    # mplayer 경로는 전역임 주의, -ss옵션에 0이 들어가도 상관 없다
    Mplayer_end_second="$("$MPLAYER_PATH" $Options -ss "$Play_position_second" "$Play_filepath" 2>/dev/null | strings | tail -2 | egrep '^A:' | perl -pe 's/^A:\s*//g,s/ V:.*//g')"

    if [ -z "$Mplayer_end_second" ];then
        return 4
    fi

    Mplayer_start_position_second="$(echo "$Mplayer_end_second" | cut -d '.' -f1)"
    if [ -z "$Mplayer_start_position_second" ];then
        return 5
    fi

    MPLAYER_PLAY_RETURN_POSITION="$(($Mplayer_start_position_second - $Play_backward_second))"
}

function Mplayer_Pipe()
{
    local Play_filepath="$1"
    local Pipe_path="$2"
    local Pipe_option=""
    unset MPLAYER_PIPE_RETURN_OPTION

    # mkv는 fifo 사용이 불가능한듯함
    if [ -z "$(echo "$Play_filepath" | grep \.mkv)" ];then
        if [ "$(file "$Pipe_path" | cut -d ' ' -f2)" != "fifo" ];then
            mkfifo "$Pipe_path"
        fi

        Pipe_option="-slave -input file="$Pipe_path""
    fi

    MPLAYER_PIPE_RETURN_OPTION="$Pipe_option"
}

function Mplayer()
{
    local Play_filepath=""
    local Options=""
    local Played_position_second=""
    local Restart_backword_second=2
    local Playing_position_second=""
    local Playing_file_duration=""
    local Restart_last_second=10
    local Return_succeed_value=0

    Option_Parse "$@"
    Play_filepath="$OPTION_PARSE_RETURN_FILEPATH"
    Options="$OPTION_PARSE_RETURN_OPTIONS"

    if [ -z "$Play_filepath" ];then
        return $MPLAYER_ERROR_NOT_PLAY_FILE
    fi

    Mplayer_Pipe "$Play_filepath" "$MPLAYER_PIPE_PATH"
    Options=""$Options" "$MPLAYER_PIPE_RETURN_OPTION""

    Mplayer_Log_Position_Get "$Play_filepath" "$MPLAYER_LOG_FILEPATH"
    if [ $? != 0 ];then
        return $MPLAYER_ERROR_LOG_POSITION_GET
    fi

    Played_position_second="$MPLAYER_POSITION_GET_RETURN_PLAY_SECOND"

    Mplayer_Play_Continue "$Options" "$Play_filepath" "$Played_position_second" "$Restart_backword_second"
    if [ $? != 0 ];then
        return $MPLAYER_ERROR_PLAYING
    fi

    Playing_position_second="$MPLAYER_PLAY_RETURN_POSITION"

    # 동영상의 재생 길이를 알때에만 기록을 한다.
    Mplayer_Play_Duration "$Play_filepath"
    if [ $? = 0 ];then
        Playing_file_duration="$MPLAYER_PLAY_DURATION_RETURN_SECOND"

        if [ $(($Playing_position_second + $Restart_last_second )) -lt "$Playing_file_duration" ];then
            Mplayer_Log_Position_Set "$Play_filepath" "$Playing_position_second" "$MPLAYER_LOG_FILEPATH"
            Return_succeed_value=$MPLAYER_STATUS_OK_PLAYING
        else
            Mplayer_Log_Position_Delete "$Play_filepath" "$MPLAYER_LOG_FILEPATH"
            Return_succeed_value=$MPLAYER_STATUS_OK_END
        fi
    fi

    return $Return_succeed_value
}


따로 설정할수 있는 부분은 전역으로 빼놨으니까 수정하시기 편할거에요.


ps; ~/.bashrc에 다음과 같이 쓰시길 추천. 아니면 따로 빼서 쓰시던지요.

alias mp='. /path/Mplayer.sh;Mplayer'




간단하지만 유용한 쉘스크립트.

엄청나게 간단하지만, 꽤 쓸만한 녀석들 모음입니다.


소스는 하도 간단해서 별로 설명할것도 없네요...


첫번째 스트립트는 터미널 영한사전처럼 간단하게(앞부분만) 위키 내용을 보여주는것.


다음 상황에서 문제가 발생하긴 해요...


1, 동의어가 발생했을때

(뭐, 이럴경우는 그냥 웹브라우저로 연결해서 보면 되긴 합니다)

2, 느리다. 특히 데이터가 많은 페이지일 경우...

(모바일페이지를 read하면 속도 향상이 있긴하겠지만, 귀찮아서...)

3, 사전에 단어가 별로 없다

(위키백과라고 해도, 단어수만 따지자면 백과사전(책)에 비해서 단어수가 후달려서 그런지 검색안되는 단어가 좀 있습니다)


[~/bin/script]$ cat wikipedia_ko.sh

#!/bin/bash

# 위키페이지는 공백대신 언더바를 쓴다
PAGE_NAME="$(echo "$*" | tr -s ' ' '_')"
LINK="http://ko.wikipedia.org/wiki/"$PAGE_NAME""
LINK_LIST_FILEPATH='/tmp/wiki_page'
BROWSER='firefox'
WIDTH=100

clear
echo '페이지 다운로드중 잠시만 기다려 주세요.'
wget "$LINK" -O "$LINK_LIST_FILEPATH" -q
clear

RESULT_DATA="$(cat "$LINK_LIST_FILEPATH" | egrep '<p>.*?<b>' | grep -v ^\\[ | head -1 | tr -d '\t' | perl -pe s/\<.*?\>//g | fmt -w "$WIDTH")"
if [ -n "$RESULT_DATA" ];then
    echo "$RESULT_DATA"
    echo
    echo "URL : "$LINK""
    echo -n '웹 브라우저에서 보시려면 <<v>> 키를 눌러주세요.'
    read -n 1 CHECKER
    echo
    if [ "$CHECKER" = 'v' ];then
        "$BROWSER" "$LINK" 1>/dev/null 2>/dev/null &
    fi
fi

rm -rf "$LINK_LIST_FILEPATH"



두번째 스크립트는 검색어/지도에서위치를 검색하는 역활을 하는겁니다.


구조는 더 간단합니다. 걍 url에 쿼리날리면 끝.


구글이나 네이버말고 다른 url query를 알면 그냥 붙여넣기 해서 쓰면 되겠죠...


일단 저는 아는게 2개밖에 없어서 일단 이렇게 만들어 봤어요.


[~/bin/script]$ cat direct_url.sh 

#!/bin/bash

BROWSER='firefox'

GOOGLE_FELLING_LUCKY_URL="http://www.google.com/search?ie=utf8&lr=lang_ko&btnI=&q="
NAVER_MAP_URL='http://map.naver.com/?query='
BASE_URL=""

while getopts 'g:m:' Option;do
    case $Option in
        g )
            BASE_URL="$GOOGLE_FELLING_LUCKY_URL"
            PARAM="$OPTARG"
            ;;
        m )
            BASE_URL="$NAVER_MAP_URL"
            PARAM="$OPTARG"
            ;;

        * )
            echo 'Usage >'
            echo ""$0" -g Query String : Google Feeling Lucky를 이용해 다이렉트 점프!"
            echo ""$0" -m Query String : Naver Map을 이용해서 주변을 검색합니다"
            ;;
    esac
done

"$BROWSER" "$BASE_URL""$PARAM" 1>/dev/null 2>/dev/null &


alias에서 터미널에서 바로 검색하면 정말 편하더군여

$go 네이버 메일

이런식으로 하면 LastPass랑 연동되서 바로 이메일 확인도 할수 있고...


$map 구청

이러면 집주변의 구청위치도 알수 있고...


여튼 일일이 브라우저 열어서 검색하고 귀찮게 안하고 명령어 한줄로 끝낼 수 있다는게 굉장이 편리해요...


ps; 네이버 open API를 사용하면 인기검색어 뷰어같은 괴상망측(...)한것도 만들수 있습니다..

http://dev.naver.com/openapi/apis/search/rank

저도 만들긴 했는데 별 쓸모는 없더군요... 그냥 심심했을때 한번 쳐보는 거 정도...


이외에도 많이 있긴한데, 나머지는 xml 파싱하는 스크립트도 넣어야 해서 귀찮아서 그냥 이정도로.

외부접속 확인하는 간단한 스크립트


ssh로 로긴해서 들어갔을때에도 무식하게 X를 당당히 띄어버리는 문제 발생.

그래서 아래 스크립트를 작성하여 일단 문젠 봉합해둠.

이하, 현재 쉘이 외부에서 접속했는지 확인하는 간단한 스크립트

#!/bin/bash
pts_id="pts/$(basename $(tty))"

# 쓸데없는 기교 (...)
if [ -n "$(who | grep -E ^"$USER"'.*'$pts_id'.*\([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\)$')" ];then
    echo "외부접속"
fi

일단은 잘 작동하는거 같은데... 함 두고보자.

포인터 연습


요즘엔 쉘 스크립트만 붙잡고 노는지라, C는 안한지 몇달이 다되가네여.

포인터도 좀 마니 까먹은듯?

친구가 다중배열 넘기는 방법을 물어보길래 함 짜보네여,

옛날에도 2차원 배열, 2차원포인터로 넘기는건 기본이고 3차원 포인터(!) 까지 쓰고 그랬는데 요즘엔 영 기억이 안난다는

(이게다 스크립트 언어만 만지기 때문임 ㅠㅠ)

친구가 준 소스를 수정 ( 다 바꿨지만)해서 만든 완성본

자세한 설명은 생략, 뭐 어짜피 이블로그 오는사람은 이정도는 다 알겠져.
#include <stdio.h>

#define MAX_ROW 4
#define MAX_COL 5

int PArray_Type (int *array)
{
    int i;

    for(i = 0;i < MAX_COL;i ++){
        printf("%d\n", array[i]);
    }  
}

// 통채로 넘겼으므로, (보낸 배열과 같게)열의 크기를 정해줘야한다.
int PArray_Type2 (int (*array)[MAX_COL])
{
    int i,
        j; 

    for(i = 0;i < MAX_ROW;i ++){
        for(j = 0;j < MAX_COL;j ++){
            printf("%d\n", array[i][j]);
        }  
    }  
}

int main (int *argc, int argv[])
{
    int array[MAX_ROW][MAX_COL] = {{5,7,0,1,3},
                                   {8,2,3,7,0},
                                   {1,6,3,8,4},
                                   {1,2,4,8,3}},
        *array2,
        i; 

    for(i = 0;i < MAX_ROW;i ++){
        array2 = array[i]; // 각 row 의 맨앞 주소만 넘김
        PArray_Type(array2);
    }  

    puts("--");
    PArray_Type2(array);

    return 0;
}  

응용해서.. 다음과 같은것도 넘기는것도 가능합니다.

포인터 배열을 넘길때에는 받는 함수쪽에서 괄호를 주의하도록 합시다.
#include <stdlib.h>    
#include <stdio.h>    
#define FUNCTION_KEY_COUNT 12

char *keysym_function[FUNCTION_KEY_COUNT] = { "F1", "F2", "F3", "F4", "F5", "F6",   
                                                                             "F7", "F8", "F9", "F10", "F11", "F12"};   

void KeyArray_String(char (*array_keycode[FUNCTION_KEY_COUNT]))
{   
    int i;   
   
    for(i = 0;i < FUNCTION_KEY_COUNT;i ++){   
        printf("%s\n", array_keycode[i]);
    }   
}   

int main(int argc, char **argv)
{
    KeyArray_String(keysym_function);
}


'Programming > C' 카테고리의 다른 글

간단한 디버그 함수  (0) 2010.08.16
오늘도 실수.. iconv  (0) 2010.06.24
아아 또 실수~!  (4) 2009.06.22
주의력 부족  (2) 2009.06.22
이진트리를 만들고나서....아 망했어요...  (2) 2009.05.25

[수정중] 아치리눅스에서 안드로이드 개발환경 설정

1. SDK 설치
1) 다음 패키지를 설치합니다.
yaourt -S android-sdk android-sdk-platform-tools

2) PATH를 설정해 줍니다.
다음 경로들을 추가해 주면 됩니다.

/opt/android-sdk/tools
/opt/android-sdk/platform-tools:

만약 JAVA_HOME이 설정이 안되 있다면,  이것도 추가 합시다.

/opt/java

export PATH="$PATH:/opt/java/bin:/usr/local/bin:/opt/android-sdk/tools:/opt/android-sdk/platform-tools:"
export JAVA_HOME="/opt/java"
export CLASSPATH="."

3)SDK/AVD 관리자를 실행시킵니다
  #android

4)Available packages 에서 원하는 패키지를 선택합니다.
뭐 다 선택해도 무방 합니다만......
그리고 Install Selected 하심 끝입니다.


5) 뭐 저는 어짜피 프로요까지 밖에 못쓰니깐 이정도만 설치했습니다. 참조해 주세요.


2. 물리 장치 인식
Virtual device가 아니라 실제 장치를 인식시키는 과정입니다

1) 스마트폰에서 다음과 같이 설정합니다 (프로요 기준)
홈 -> 설정 -> 응용프로그램 ->개발 ->USB 디버깅을 켜줍니다.
(나머지 옵션도 켜주시면 좋습니다)

2) 스마트폰을 USB에 연결합니다.

3) 다음 명령어를 사용하여 vid, pid를 알아냅니다.
빨간게 vid, 파랑색이 pid 입니다.
[~]$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0000:9999   ..........
......
Bus 002 Device 003: ID 0000:9999  ..........
......
Bus 002 Device 011: ID 1111:2222 Motorola PCS Droid/Milestone (Debug mode)

4) 루트로 다음 파일을 편집합니다. (아마 파일이 없을겁니다. 생성합시다)
이번에도 udev 설정입니다. alsa랑 별 다를바 없어요.
#  vi /etc/udev/rules.d/90-android.rules
SUBSYSTEM=="usb", SYSFS{idVendor}=="1111", MODE="0666"

SUBSYSTEM=="usb",ATTR{idVendor}=="1111",ATTR{idProduct}=="2222",SYMLINK+="android_adb"
SUBSYSTEM=="usb",ATTR{idVendor}=="1111",ATTR{idProduct}=="2222",SYMLINK+="android_fastboot"

5) udev를 재시작 합니다
#udevadm control --reload-rules

6) 확인해 봅니다
[~]$ adb devices
List of devices attached
FFFFFFFFFFFFFFFF        device

참고:
http://developer.android.com/guide/developing/device.html
https://wiki.archlinux.org/index.php/Android

2. Eclipse 설치
많이 사용하는 IDE 이클립스를 설정해 보겠습니다. 설치방법은 다음과 같습니다.

일반 eclipse 패키지를 설치하지말고, 꼭 eclipse-android  패키지로 설치하도록 합니다.

아니면 뒤에 삽질좀 더 해야 하거든요.
#yaourt -S eclipse-android

1. 한글 언어팩 설치
다음은 자세한 설치과정입니다. 제가 나중에 잊어버렸을때를 대비해서 -_-.. 자세하게 적어 놨습니다.
메뉴 -> help -> Install New Software

work with : 에

http://download.eclipse.org/technology/babel/update-site/R0.8.0/helios

http://download.eclipse.org/technology/babel/update-site/R0.10.1/juno

를 넣고 기다립니다. 시간이 좀 걸리네요

저는 한 십분 걸린듯


2) Babel Langauge Packs in Korean을 선택합니다.


3) 저는 다 선택 했으므로 하위 패키지들이 모두 나옵니다.


4) 단체 accept 해 줍니다. finish!


5) 알아서 설치 합니다.


6) OK!


7) 재시작 을 합니다.


8) 완료



2,
AUR에서 eclipse-android 패키지에 문제가 있으실경우, 다음과 같이 수동으로 설치 해 주세요.

제대로 패키지를 설치하였다면, 이 부분은 무시해 주세요.

(!) 설치시 일부 메뉴의 사용이 불가능(disable)되어버리는 문제가 발생하므로
가급적 아래의 방법은 사용하시자 마시기 바랍니다.


3. 커맨드를 사용한 컴파일/실행 방법

1) 컴파일을 하기위해서 ant 패키지 설치
[/tmp]# yaourt -S apache-ant

2) PATH 추가
위와 같이 "/usr/share/java/apache-ant/bin"를 경로에 추가해 줍니다.
export PATH="$PATH:/opt/java/bin:/usr/local/bin:/opt/android-sdk/tools:/opt/android-sdk/platform-tools:/usr/share/java/apache-ant/bin:"

3) 기본 템플릿 파일 만들기
자세한 설명은 생략하겠습니다. 파라매터에 설명이 다 나와 있으니까요.
[/tmp]$ ./android create project \
--target 1 \
--name hello \
--path Project/hello \
--activity hello \
--package example.hello

3) 만든 디렉토리로 이동한 이후에 컴파일 합니다.
[/tmp]$ cd Project/hello
[/tmp/Project/hello]$ ant install

4) 실행
[/tmp/Project/hello]$ adb shell 'am start -n example.hello/.hello'

5) 스마트폰을 확인해 보세요. 프로그램이 실행되어 있을겁니다.

4. 이클립스를 Vim 처럼 사용하기

터미널에서 작업하고 싶은데(Eclim이 안되 ㅠ) eclipse의 자동완성 기능이 부러우신분,

또는, 이클립스 내부에서 vi를 사용하고 싶은분은 다음과 같이 해 주세요.

먼저, 터미널에서 eclim을 사용하는 경우를 먼저 설명하겠습니다.

1) Eclim 사용하기

이클립스를 데몬으로 돌려서 일부의 기능을 vim쪽으로 끌어오는(!) 방식으로 작동하는 녀석입니다.

컴파일하기도 힘들고, 설명 패키지로 만들어서 설치를 한다고 해도, 제대로 작동하지가 않네요.

그래도 업데이트는 잘되는 편이던데...... 데체 이걸 어케 사용하는거야 다들?;;

뭐 나중에 해결책이 나오면 이어서 포스팅할꼐요. 지금은 영 안되겠습니다.

2) vrapper 사용하기

그나마 젤 사용할만합니다. (사실 이것말고는 선택사항이 없......)

설치하기도 매우 쉽고요. 앞에서 하던데로 하면 됩니다.

도움말 -> Install New Software

Work with: http://vrapper.sourceforge.net/update-site/stable



다음엔 다 아시죠? 여태까지 해 왔던대로 다음 버튼누르고 라이센스 동의 하고 확인 몇번 눌른후,

이클립스를 다시 시작 하면 설치과정은 끝입니다.

이제 재시작이 완료 되었으면, 툴바에서 gVim 아이콘을 누르고 그냥 사용하면 됩니다.

더이상 따로 건드려줘야 할건 없습니다. 심플하죠.

이것도 좀 부족한게 있는데 왜냐하면 몇몇 자주쓰는 기능이 빠져 있기때문입니다.

아직 지원하지 않는 명령은 (제가 대충 찾아본 결과)

버퍼 관련 명령들, '-', '+', '%' 들여쓰기 정렬,  페이지 이동, gd, 이정도가 되겠습니다.

이점 참조 하시길 바랍니다.

결론적으로, 그냥저냥 파일내부에서 기초적인 편집과 커서이동은 가능하구나 생각하시면 됩니다.

hjkl의 자유를 얻은것만으로 만족합시다;


2) ViPlugin 사용하기

유로로 돈내고 사야합니다 (......), 가 아니라 일단 무료로 쓸수 있긴 한거 같습니다.

문제라면 귀찮도록 나오는 경고 메세지 입니다

(라이센스가 없으니깐 사주세여 어쩌고......)

그런데 아직까지 별로 써본적이 없기때문에,

무슨 기능상 무슨 제한이 있는지, 아니면 날짜 제한이 있는지는 아직은 모르겠네요

어쨌던 라이센스를 얻으라면 페이팔에서 결제를 해야합니다. 얼마냐구여? 15 유로네요.

www.viplugin.com

1유로가 1545원이니까...  (유로가 달러보다 비쌌군요; ) 한 23000원 하네요.

그런다해도 구글에 찾아보면 해적판! 크랙판! 을 쉽게 찾을수 있습니다.

(버전이 좀 낮습니다만...... 업데이트가 따로 되는지 안되는지는 모르겠네요)

설치방법은
1. 위의 링크를 타고 들어가서 "오른쪽에 거대한 페이팔 로고" 아래에 보면 다운 링크가 있습니다.
 
2, 파일을 받고

3, ~/.eclipse/org.eclipse.platform_VERSION 에 압축을 풀어주시고

4, 이클립스 재시작 하면 됩니다.

위에 나오는 vrapper 보다는 기능이 좀더! 있습니다.

ps; 키가 충돌할 수도 있으므로, 하나만 정해서 사용하는것이 나을겁니다. 아마도.


5. XML 파일을 쉽게 편집하기

1) 이클립스의 도움 없이 xml을 편집하는 방법입니다만...... 그다지 추천은 하지 않습니다;
#yaourt -S droiddraw

2) droiddraw를 실행합니다.

3) 메뉴에서 File -> Open 을 선택하고  PorjectDirectory/rss/layout/main.xml을 선택합니다.

ex>
/tmp/Project/hello/rss/layout/main.xml

4) 수정을 시작합니다.

5) 저장합니다.

6) 재 컴파일 하고 실행.

ps; 아 양 장난아니게 많네여, 조금씩 조금씩 해서 오늘에서야 끝!


'Programming > Android' 카테고리의 다른 글

리눅스 + 이클립스 트러블슈팅  (2) 2011.05.24
prev 1 2 3 4 ··· 19 next